diff --git a/annuaire/urls.py b/annuaire/urls.py index 8fb9c48..a26909d 100644 --- a/annuaire/urls.py +++ b/annuaire/urls.py @@ -17,14 +17,14 @@ from django.conf import settings from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static -from fiches.views import home, birthday +from fiches.views import BirthdayView, HomeView import django_cas_ng.views as cas_views urlpatterns = [ path('admin/', admin.site.urls), path('fiche/', include('fiches.urls')), - path('', home, name='home'), - path('birthday', birthday, name='birthday'), + path('', HomeView.as_view(), name='home'), + path('birthday', BirthdayView.as_view(), name='birthday'), path('accounts/login/', cas_views.LoginView.as_view(), name='cas_ng_login'), path('logout', cas_views.LogoutView.as_view(), name='cas_ng_logout'), ] diff --git a/fiches/forms.py b/fiches/forms.py index 8c10468..6273c99 100644 --- a/fiches/forms.py +++ b/fiches/forms.py @@ -1,23 +1,11 @@ from django import forms -from fiches.models import Profile, Department +from fiches.models import Profile, Department, Phone, Social, Mail, Address class ProfileForm(forms.ModelForm): class Meta: model = Profile - fields = [ - "full_name", - "nickname", - "pronoun", - "picture", - "department", - "promotion", - "birth_date", - "thurne", - "text_field", - "printing", - "keep_me", - ] + exclude = ["user"] class SearchForm(forms.Form): @@ -35,3 +23,29 @@ class SearchForm(forms.Form): and not cleaned_data["department"] ): raise forms.ValidationError(("Tous les champs sont vides"), code="invalid") + + +class PhoneForm(forms.BaseModelFormSet): + class Meta: + model = Phone + exclude = [] + + + +class SocialForm(forms.ModelForm): + class Meta: + model = Social + exclude = [] + + +class MailForm(forms.ModelForm): + class Meta: + model = Mail + exclude = [] + + +class AddressForm(forms.ModelForm): + class Meta: + model = Address + exclude = [] + diff --git a/fiches/models.py b/fiches/models.py index 3dbc3cf..26b367e 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -49,7 +49,7 @@ class Department(models.Model): class Phone(models.Model): profile = models.ForeignKey( - Profile, on_delete=models.CASCADE, verbose_name=_("profil") + Profile, related_name="numeros", on_delete=models.CASCADE, verbose_name=_("profil") ) name = models.CharField(max_length=255, verbose_name=_("type")) number = models.CharField(max_length=1023, verbose_name=_("numéro")) diff --git a/fiches/templates/fiches/fiches_modif.html b/fiches/templates/fiches/fiches_modif.html index 5de135b..ecbfdb9 100644 --- a/fiches/templates/fiches/fiches_modif.html +++ b/fiches/templates/fiches/fiches_modif.html @@ -6,6 +6,7 @@