diff --git a/annuaire/settings.py b/annuaire/settings.py index 32af7e0..657cae3 100644 --- a/annuaire/settings.py +++ b/annuaire/settings.py @@ -86,7 +86,8 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + 'NAME': + 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', @@ -121,4 +122,4 @@ STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') -MEDIA_URL = '/media/' \ No newline at end of file +MEDIA_URL = '/media/' diff --git a/annuaire/urls.py b/annuaire/urls.py index 0c8e865..5697b50 100644 --- a/annuaire/urls.py +++ b/annuaire/urls.py @@ -24,4 +24,4 @@ urlpatterns = [ ] if settings.DEBUG: - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/fiches/admin.py b/fiches/admin.py index 9da72e0..b059338 100644 --- a/fiches/admin.py +++ b/fiches/admin.py @@ -7,10 +7,9 @@ from fiches.models import Mail from fiches.models import Address -# Register your models here. admin.site.register(Profile) admin.site.register(Department) admin.site.register(Phone) admin.site.register(Social) admin.site.register(Mail) -admin.site.register(Address) \ No newline at end of file +admin.site.register(Address) diff --git a/fiches/forms.py b/fiches/forms.py index 2ebe60b..8a487a3 100644 --- a/fiches/forms.py +++ b/fiches/forms.py @@ -1,21 +1,23 @@ from django import forms from fiches.models import Profile + class ProfileForm(forms.ModelForm): - class Meta: - model = Profile - fields = [ - "full_name", - "nickname", - "picture", - "department", - "promotion", - "birth_date", - "thurne", - "text_field", - "printing", - "keep_me" - ] + class Meta: + model = Profile + fields = [ + "full_name", + "nickname", + "picture", + "department", + "promotion", + "birth_date", + "thurne", + "text_field", + "printing", + "keep_me" + ] + class SearchForm(forms.Form): - name = forms.CharField(label='search name', max_length=1023) \ No newline at end of file + name = forms.CharField(label='search name', max_length=1023) diff --git a/fiches/models.py b/fiches/models.py index 4bd9c44..7793fdb 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -6,7 +6,10 @@ from django.contrib.auth.models import User class Profile(models.Model): user = models.OneToOneField( - User, on_delete=models.CASCADE, verbose_name=_("utilisateur"), related_name='profile' + User, + on_delete=models.CASCADE, + verbose_name=_("utilisateur"), + related_name="profile", ) full_name = models.CharField(max_length=1023, verbose_name=_("nom")) nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom")) @@ -26,12 +29,14 @@ class Profile(models.Model): keep_me = models.BooleanField( default=False, verbose_name=_("conserver la fiche annuaire ?") ) + def __str__(self): return self.full_name class Department(models.Model): name = models.CharField(max_length=255, verbose_name=_("nom du département")) + def __str__(self): return self.name @@ -42,6 +47,7 @@ class Phone(models.Model): ) name = models.CharField(max_length=255, verbose_name=_("type")) number = models.CharField(max_length=1023, verbose_name=_("numéro")) + def __str__(self): return "{} : {}".format(self.name, self.number) @@ -52,23 +58,28 @@ class Social(models.Model): ) name = models.CharField(max_length=255, verbose_name=_("type")) content = models.CharField(max_length=1023, verbose_name=_("contenu")) + def __str__(self): return "{} : {}".format(self.name, self.content) + class Mail(models.Model): profile = models.ForeignKey( Profile, on_delete=models.CASCADE, verbose_name=_("profil") ) name = models.CharField(max_length=255, verbose_name=_("type")) mail = models.CharField(max_length=1023, verbose_name=_("adresse mail")) + def __str__(self): return "{} : {}".format(self.name, self.mail) + class Address(models.Model): profile = models.ForeignKey( Profile, on_delete=models.CASCADE, verbose_name=_("profil") ) name = models.CharField(max_length=255, verbose_name=_("type")) content = models.CharField(max_length=1023, verbose_name=_("adresse")) + def __str__(self): - return "{} : {}".format(self.name, self.content) \ No newline at end of file + return "{} : {}".format(self.name, self.content) diff --git a/fiches/templates/fiches/fiche.html b/fiches/templates/fiches/fiche.html index a21c0be..7458f52 100644 --- a/fiches/templates/fiches/fiche.html +++ b/fiches/templates/fiches/fiche.html @@ -1,66 +1,66 @@ {% extends "fiches/base.html" %} {% block content %} -
- {% if profile.department.exists %} - Département{{ profile.department.count|pluralize}} : - {% endif %} - {% for dep in profile.department.all %} - {{ dep }} - {% if not forloop.last %} - , - {% endif %} - {% endfor %} - {% if profile.birth_date %} -
-
- {% if profile.phone_set.exists %}
- Téléphone{{ profile.phone_set.count|pluralize}} :
- {% endif %}
- {% for ph in profile.phone_set.all %}
- {{ ph }}
- {% if not forloop.last %}
- ,
- {% endif %}
- {% endfor %}
-
- {% if profile.social_set.exists %}
- {{ profile.social_set.count|pluralize:"Réseau social,Réseaux sociaux"}} :
- {% endif %}
- {% for ph in profile.social_set.all %}
- {{ ph }}
- {% if not forloop.last %}
- ,
- {% endif %}
- {% endfor %}
-
- Date de naissance : {{ profile.birth_date }} -
- {% endif %} ++ {% if profile.department.exists %} + Département{{ profile.department.count|pluralize}} : + {% endif %} + {% for dep in profile.department.all %} + {{ dep }} + {% if not forloop.last %} + , + {% endif %} + {% endfor %} + {% if profile.birth_date %} +
+
+ {% if profile.phone_set.exists %}
+ Téléphone{{ profile.phone_set.count|pluralize}} :
+ {% endif %}
+ {% for ph in profile.phone_set.all %}
+ {{ ph }}
+ {% if not forloop.last %}
+ ,
+ {% endif %}
+ {% endfor %}
+
+ {% if profile.social_set.exists %}
+ {{ profile.social_set.count|pluralize:"Réseau social,Réseaux sociaux"}} :
+ {% endif %}
+ {% for ph in profile.social_set.all %}
+ {{ ph }}
+ {% if not forloop.last %}
+ ,
+ {% endif %}
+ {% endfor %}
+
+ Date de naissance : {{ profile.birth_date }} +
+ {% endif %} - {% if profile.thurne %} -- Thurne : {{ profile.thurne }} -
- {% endif %} -- Champ libre : {{ profile.text_field }} -
- {% endif %} -+ Thurne : {{ profile.thurne }} +
+ {% endif %} ++ Champ libre : {{ profile.text_field }} +
+ {% endif %} +