From a672e439e8079fcf20058a6d548556bff9ec8343 Mon Sep 17 00:00:00 2001 From: Juliette Luiselli Date: Mon, 8 Apr 2019 21:47:50 +0200 Subject: [PATCH] page fiche (html) --- .gitignore | 6 +- annuaire/settings.py | 6 +- annuaire/urls.py | 4 ++ fiches/migrations/0002_auto_20190408_1929.py | 24 +++++++ fiches/models.py | 12 +++- fiches/static/fiches/css/style.css | 3 +- fiches/templates/fiches/fiche.html | 67 ++++++++++++++++++- fiches/urls.py | 2 +- fiches/views.py | 9 ++- picture/pnmadela2.jpg | Bin 3561 -> 0 bytes 10 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 fiches/migrations/0002_auto_20190408_1929.py delete mode 100644 picture/pnmadela2.jpg 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 %} +
+
+ +
+
+

{{ profile.full_name }} + ({{ profile.promotion }}) + {% if profile.nickname %} + alias:{{ profile.nickname }})

+ {% 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 %} +
+
+
+ {% if profile.text_field %} +

+ Champ libre : {{ profile.text_field }} +

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/fiches/urls.py b/fiches/urls.py index a155217..c9dd17a 100644 --- a/fiches/urls.py +++ b/fiches/urls.py @@ -2,5 +2,5 @@ from django.urls import path from . import views urlpatterns = [ - path('',views.fiche, name='fiche') + path('',views.fiche, name='fiche') ] \ No newline at end of file diff --git a/fiches/views.py b/fiches/views.py index 367322e..214d33f 100644 --- a/fiches/views.py +++ b/fiches/views.py @@ -1,6 +1,11 @@ from django.shortcuts import render +from django.shortcuts import get_object_or_404 +from .models import Profile # Create your views here. -def fiche(request): - return render(request,'fiches/fiche.html',{}) \ No newline at end of file +def fiche(request,id): + profile=get_object_or_404(Profile,id=id) + return render(request,'fiches/fiche.html',{"profile":profile}) + + diff --git a/picture/pnmadela2.jpg b/picture/pnmadela2.jpg deleted file mode 100644 index d53a11a8b697e9915f32863b1025675c954a5de3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3561 zcmbW%XHXMbn+Nbf5}HU6f`AxefJ;*@VCYqPPH&qzM>-NRbjD5~T(%(tAe) z1TIJoQj`{&AU#y2OA%S_`|j+{?5ExRKXcBP=b1C-H)rOYPn^#I*z|RfIsh6P0D$JA z0O!*HO#lNO9X%bGfu5e8k&%Ikne#I9rAy2_S2$QXuk-Rluk-Tp!2~6QVep#*e0(Bu zqBkX_5C{anu!4%bw6er)g!Dg$&@eJGGGAimzI>Tm`Uc+(>Hl-i+W_ngfD8Z@NCOAZ zveN+BY0f(V{1^8G)BG!d{|pT+5Co>9XJBNybTLrJ2B4(@0%<`&Fc<{7m=3w<13>KH zD>tO>&~cbJ(8GN=rNfBX3<4U}A0ehg+k&?peZv`Z@CyAQEFvm~kdc*>S5VZ{ z($>+{L+YEM%q=XftnWKHKXP$(Lu35>p9BO3J;g>uzKDvBiN(KulbDp8lA1=!$<50z zC@d;2si}Qe_rAWN@k4t@XIFO*x%boX$mkeld}4BHeqnKGd4;;Vw!X8ww|{W>^XT~G z9~TV(_;1$5{%_d-aIs&wXh9$#i2ffJ4Q=4X0BvU+%chd@Zo?LL|G#Aa1^aK;6o45>bMbgUc7Ph-P<7vAHXQxj zG~(U>qJf?SNJpeUFA0>Zp0;VOkwo2j?M`Uk8H<$o?O#qHN53(h!J9mGYTg51EA10J zdc*BuGx28CI_3;h*2*puCHx5wvY$|jH+mOqKd4&~1%2mL$!`=xYEQ7s^$3^}J812k z?u31I=co*(EqH}yJM=i<8+K_JxV@lC#C{b1h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