diff --git a/.gitignore b/.gitignore index 1e6486a..51af000 100644 --- a/.gitignore +++ b/.gitignore @@ -4,11 +4,7 @@ *~ *# -/media/archives/* -/media/images/* -/media/documents/* -/media/original_images/* -/media/admin +/media/picture /recensements/ /venv/ diff --git a/annuaire/settings.py b/annuaire/settings.py index 614c878..32af7e0 100644 --- a/annuaire/settings.py +++ b/annuaire/settings.py @@ -103,7 +103,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'fr-fr' TIME_ZONE = 'UTC' @@ -118,3 +118,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/dev/howto/static-files/ STATIC_URL = '/static/' + +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + +MEDIA_URL = '/media/' \ No newline at end of file diff --git a/annuaire/urls.py b/annuaire/urls.py index 125db47..0c8e865 100644 --- a/annuaire/urls.py +++ b/annuaire/urls.py @@ -16,8 +16,12 @@ Including another URLconf from django.conf import settings from django.contrib import admin from django.urls import path, include +from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('fiche/', include('fiches.urls')) ] + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/fiches/migrations/0002_auto_20190408_1929.py b/fiches/migrations/0002_auto_20190408_1929.py new file mode 100644 index 0000000..6b5f8eb --- /dev/null +++ b/fiches/migrations/0002_auto_20190408_1929.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2 on 2019-04-08 19:29 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('fiches', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='phone', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil'), + ), + migrations.AlterField( + model_name='social', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil'), + ), + ] diff --git a/fiches/models.py b/fiches/models.py index beeac8d..9324314 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -26,23 +26,31 @@ 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=1023, verbose_name=_("nom du département")) + def __str__(self): + return self.name class Phone(models.Model): - profile = models.OneToOneField( + profile = models.ForeignKey( Profile, on_delete=models.CASCADE, verbose_name=_("profil") ) name = models.CharField(max_length=1023, verbose_name=_("type")) number = models.CharField(max_length=1023, verbose_name=_("numéro")) + def __str__(self): + return "{} : {}".format(self.name, self.number) class Social(models.Model): - profile = models.OneToOneField( + profile = models.ForeignKey( Profile, on_delete=models.CASCADE, verbose_name=_("profil") ) name = models.CharField(max_length=1023, verbose_name=_("type")) content = models.CharField(max_length=1023, verbose_name=_("contenu")) + def __str__(self): + return "{} : {}".format(self.name, self.content) \ No newline at end of file diff --git a/fiches/static/fiches/css/style.css b/fiches/static/fiches/css/style.css index 63a70ef..a5780d0 100644 --- a/fiches/static/fiches/css/style.css +++ b/fiches/static/fiches/css/style.css @@ -1,12 +1,11 @@ html { - background: url(../images/background-motif.png) repeat; + background-color: black; color: #FFF; font-family: Verdana, Verdana, Geneva, sans-serif; } body { margin: 0 0 0.8em 0; - background: transparent url(../images/background.png) no-repeat center top; min-height: 538px; } diff --git a/fiches/templates/fiches/fiche.html b/fiches/templates/fiches/fiche.html index ee8a4db..f51cb68 100644 --- a/fiches/templates/fiches/fiche.html +++ b/fiches/templates/fiches/fiche.html @@ -1 +1,66 @@ -{% extends "fiches/base.html" %} \ No newline at end of file +{% 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.thurne %} ++ Thurne : {{ profile.thurne }} +
+ {% endif %} ++ Champ libre : {{ profile.text_field }} +
+ {% endif %} +