Chercher quelqu'un.e dans l'annuaire
+ + + +-
+ {% for profile in result %}
+
- {{profile.full_name}} {{profile.departement}} + + {% endfor %} +
diff --git a/annuaire/urls.py b/annuaire/urls.py index 5697b50..17f0e1d 100644 --- a/annuaire/urls.py +++ b/annuaire/urls.py @@ -17,10 +17,12 @@ 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 urlpatterns = [ path('admin/', admin.site.urls), - path('fiche/', include('fiches.urls')) + path('fiche/', include('fiches.urls')), + path('', home, name='home') ] if settings.DEBUG: diff --git a/fiches/forms.py b/fiches/forms.py index 8a487a3..83c20c0 100644 --- a/fiches/forms.py +++ b/fiches/forms.py @@ -1,5 +1,5 @@ from django import forms -from fiches.models import Profile +from fiches.models import Profile, Department class ProfileForm(forms.ModelForm): @@ -20,4 +20,11 @@ class ProfileForm(forms.ModelForm): class SearchForm(forms.Form): - name = forms.CharField(label='search name', max_length=1023) + name = forms.CharField(label='Nom/Surnom', max_length=1023, required=False) + year = forms.IntegerField(label='Promotion', required=False) + department = forms.ModelMultipleChoiceField(queryset=Department.objects.all(), required=False) + + def clean(self): + cleaned_data = super().clean() + if (not cleaned_data['name'] and not cleaned_data['year'] and not cleaned_data['department']): + raise forms.ValidationError(('Tous les champs sont vides'), code='invalid') \ No newline at end of file diff --git a/fiches/migrations/0003_auto_20200108_2306.py b/fiches/migrations/0003_auto_20200108_2306.py new file mode 100644 index 0000000..014794e --- /dev/null +++ b/fiches/migrations/0003_auto_20200108_2306.py @@ -0,0 +1,47 @@ +# Generated by Django 2.2.9 on 2020-01-08 23:06 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('fiches', '0002_auto_20190408_1929'), + ] + + operations = [ + migrations.AlterField( + model_name='department', + name='name', + field=models.CharField(max_length=255, verbose_name='nom du département'), + ), + migrations.AlterField( + model_name='phone', + name='name', + field=models.CharField(max_length=255, verbose_name='type'), + ), + migrations.AlterField( + model_name='social', + name='name', + field=models.CharField(max_length=255, verbose_name='type'), + ), + migrations.CreateModel( + name='Mail', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, verbose_name='type')), + ('mail', models.CharField(max_length=1023, verbose_name='adresse mail')), + ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), + migrations.CreateModel( + name='Address', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, verbose_name='type')), + ('content', models.CharField(max_length=1023, verbose_name='adresse')), + ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), + ] diff --git a/fiches/templates/fiches/base.html b/fiches/templates/fiches/base.html index dcfe049..9c076eb 100644 --- a/fiches/templates/fiches/base.html +++ b/fiches/templates/fiches/base.html @@ -18,13 +18,19 @@