Cosmetic whitespace changes
This commit is contained in:
parent
674d41172e
commit
cac6bd390b
11 changed files with 149 additions and 137 deletions
|
@ -86,7 +86,8 @@ DATABASES = {
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
'NAME':
|
||||||
|
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
@ -121,4 +122,4 @@ STATIC_URL = '/static/'
|
||||||
|
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||||
|
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|
|
@ -24,4 +24,4 @@ urlpatterns = [
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
|
@ -7,10 +7,9 @@ from fiches.models import Mail
|
||||||
from fiches.models import Address
|
from fiches.models import Address
|
||||||
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
admin.site.register(Profile)
|
admin.site.register(Profile)
|
||||||
admin.site.register(Department)
|
admin.site.register(Department)
|
||||||
admin.site.register(Phone)
|
admin.site.register(Phone)
|
||||||
admin.site.register(Social)
|
admin.site.register(Social)
|
||||||
admin.site.register(Mail)
|
admin.site.register(Mail)
|
||||||
admin.site.register(Address)
|
admin.site.register(Address)
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from fiches.models import Profile
|
from fiches.models import Profile
|
||||||
|
|
||||||
|
|
||||||
class ProfileForm(forms.ModelForm):
|
class ProfileForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Profile
|
model = Profile
|
||||||
fields = [
|
fields = [
|
||||||
"full_name",
|
"full_name",
|
||||||
"nickname",
|
"nickname",
|
||||||
"picture",
|
"picture",
|
||||||
"department",
|
"department",
|
||||||
"promotion",
|
"promotion",
|
||||||
"birth_date",
|
"birth_date",
|
||||||
"thurne",
|
"thurne",
|
||||||
"text_field",
|
"text_field",
|
||||||
"printing",
|
"printing",
|
||||||
"keep_me"
|
"keep_me"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class SearchForm(forms.Form):
|
class SearchForm(forms.Form):
|
||||||
name = forms.CharField(label='search name', max_length=1023)
|
name = forms.CharField(label='search name', max_length=1023)
|
||||||
|
|
|
@ -6,7 +6,10 @@ from django.contrib.auth.models import User
|
||||||
|
|
||||||
class Profile(models.Model):
|
class Profile(models.Model):
|
||||||
user = models.OneToOneField(
|
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"))
|
full_name = models.CharField(max_length=1023, verbose_name=_("nom"))
|
||||||
nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom"))
|
nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom"))
|
||||||
|
@ -26,12 +29,14 @@ class Profile(models.Model):
|
||||||
keep_me = models.BooleanField(
|
keep_me = models.BooleanField(
|
||||||
default=False, verbose_name=_("conserver la fiche annuaire ?")
|
default=False, verbose_name=_("conserver la fiche annuaire ?")
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.full_name
|
return self.full_name
|
||||||
|
|
||||||
|
|
||||||
class Department(models.Model):
|
class Department(models.Model):
|
||||||
name = models.CharField(max_length=255, verbose_name=_("nom du département"))
|
name = models.CharField(max_length=255, verbose_name=_("nom du département"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -42,6 +47,7 @@ class Phone(models.Model):
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=255, verbose_name=_("type"))
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
||||||
number = models.CharField(max_length=1023, verbose_name=_("numéro"))
|
number = models.CharField(max_length=1023, verbose_name=_("numéro"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} : {}".format(self.name, self.number)
|
return "{} : {}".format(self.name, self.number)
|
||||||
|
|
||||||
|
@ -52,23 +58,28 @@ class Social(models.Model):
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=255, verbose_name=_("type"))
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
||||||
content = models.CharField(max_length=1023, verbose_name=_("contenu"))
|
content = models.CharField(max_length=1023, verbose_name=_("contenu"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} : {}".format(self.name, self.content)
|
return "{} : {}".format(self.name, self.content)
|
||||||
|
|
||||||
|
|
||||||
class Mail(models.Model):
|
class Mail(models.Model):
|
||||||
profile = models.ForeignKey(
|
profile = models.ForeignKey(
|
||||||
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=255, verbose_name=_("type"))
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
||||||
mail = models.CharField(max_length=1023, verbose_name=_("adresse mail"))
|
mail = models.CharField(max_length=1023, verbose_name=_("adresse mail"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} : {}".format(self.name, self.mail)
|
return "{} : {}".format(self.name, self.mail)
|
||||||
|
|
||||||
|
|
||||||
class Address(models.Model):
|
class Address(models.Model):
|
||||||
profile = models.ForeignKey(
|
profile = models.ForeignKey(
|
||||||
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=255, verbose_name=_("type"))
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
||||||
content = models.CharField(max_length=1023, verbose_name=_("adresse"))
|
content = models.CharField(max_length=1023, verbose_name=_("adresse"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} : {}".format(self.name, self.content)
|
return "{} : {}".format(self.name, self.content)
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
{% extends "fiches/base.html" %}
|
{% extends "fiches/base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div>
|
<div>
|
||||||
<div style="width:200px;height:200px;overflow:hidden;" >
|
<div style="width:200px;height:200px;overflow:hidden;" >
|
||||||
<img src="{{ profile.picture.url }}" width="200px" height="auto"/>
|
<img src="{{ profile.picture.url }}" width="200px" height="auto"/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3>{{ profile.full_name }}
|
<h3>{{ profile.full_name }}
|
||||||
({{ profile.promotion }})
|
({{ profile.promotion }})
|
||||||
{% if profile.nickname %}
|
{% if profile.nickname %}
|
||||||
<em>alias:</em>{{ profile.nickname }})</h3>
|
<em>alias:</em>{{ profile.nickname }})</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>
|
<p>
|
||||||
{% if profile.department.exists %}
|
{% if profile.department.exists %}
|
||||||
<em>Département{{ profile.department.count|pluralize}} :</em>
|
<em>Département{{ profile.department.count|pluralize}} :</em>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for dep in profile.department.all %}
|
{% for dep in profile.department.all %}
|
||||||
{{ dep }}
|
{{ dep }}
|
||||||
{% if not forloop.last %}
|
{% if not forloop.last %}
|
||||||
,
|
,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if profile.birth_date %}
|
{% if profile.birth_date %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{% if profile.phone_set.exists %}
|
{% if profile.phone_set.exists %}
|
||||||
<em>Téléphone{{ profile.phone_set.count|pluralize}} :</em>
|
<em>Téléphone{{ profile.phone_set.count|pluralize}} :</em>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for ph in profile.phone_set.all %}
|
{% for ph in profile.phone_set.all %}
|
||||||
{{ ph }}
|
{{ ph }}
|
||||||
{% if not forloop.last %}
|
{% if not forloop.last %}
|
||||||
,<br/>
|
,<br/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{% if profile.social_set.exists %}
|
{% if profile.social_set.exists %}
|
||||||
<em>{{ profile.social_set.count|pluralize:"Réseau social,Réseaux sociaux"}} :</em>
|
<em>{{ profile.social_set.count|pluralize:"Réseau social,Réseaux sociaux"}} :</em>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for ph in profile.social_set.all %}
|
{% for ph in profile.social_set.all %}
|
||||||
{{ ph }}
|
{{ ph }}
|
||||||
{% if not forloop.last %}
|
{% if not forloop.last %}
|
||||||
,<br/>
|
,<br/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<em>Date de naissance :</em> {{ profile.birth_date }}
|
<em>Date de naissance :</em> {{ profile.birth_date }}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if profile.thurne %}
|
{% if profile.thurne %}
|
||||||
<p>
|
<p>
|
||||||
<em>Thurne :</em> {{ profile.thurne }}
|
<em>Thurne :</em> {{ profile.thurne }}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% if profile.text_field %}
|
{% if profile.text_field %}
|
||||||
<p>
|
<p>
|
||||||
<b>Champ libre :</b> {{ profile.text_field }}
|
<b>Champ libre :</b> {{ profile.text_field }}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{% extends "fiches/base.html" %}
|
{% extends "fiches/base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Modifier ma page d'annuaire</h2>
|
<h2>Modifier ma page d'annuaire</h2>
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Enregistrer">
|
<input type="submit" value="Enregistrer">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
{% extends "fiches/base.html" %}
|
{% extends "fiches/base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h2> Chercher quelqu'un.e dans l'annuaire </h2>
|
<h2> Chercher quelqu'un.e dans l'annuaire </h2>
|
||||||
<form method='post' action="">
|
<form method='post' action="">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Recherche">
|
<input type="submit" value="Recherche">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
{% for profile in result %}
|
{% for profile in result %}
|
||||||
<li><a href="{% url 'fiche' profile.id %}">{{profile.full_name}} {{profile.departement}}
|
<li><a href="{% url 'fiche' profile.id %}">{{profile.full_name}} {{profile.departement}}
|
||||||
</a> </li>
|
</a> </li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -2,7 +2,7 @@ from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('<int:id>',views.fiche, name='fiche'),
|
path('<int:id>', views.fiche, name='fiche'),
|
||||||
path('edit',views.fiche_modif, name='fiche_modif'),
|
path('edit', views.fiche_modif, name='fiche_modif'),
|
||||||
path('search',views.search, name='search')
|
path('search', views.search, name='search'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,38 +1,40 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.shortcuts import get_object_or_404,redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from fiches.models import Profile
|
from fiches.models import Profile
|
||||||
from fiches.forms import ProfileForm, SearchForm
|
from fiches.forms import ProfileForm, SearchForm
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
@login_required
|
@login_required
|
||||||
def fiche(request,id):
|
def fiche(request, id):
|
||||||
profile=get_object_or_404(Profile,id=id)
|
profile = get_object_or_404(Profile, id=id)
|
||||||
return render(request,'fiches/fiche.html',{"profile":profile})
|
return render(request, 'fiches/fiche.html', {"profile": profile})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def fiche_modif(request):
|
def fiche_modif(request):
|
||||||
profile = request.user.profile
|
profile = request.user.profile
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = ProfileForm(request.POST, instance=profile)
|
form = ProfileForm(request.POST, instance=profile)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.save()
|
form.save()
|
||||||
return redirect(reverse('fiche',args=(profile.id,)))
|
return redirect(reverse('fiche', args=(profile.id,)))
|
||||||
|
else:
|
||||||
|
form = ProfileForm(instance=profile)
|
||||||
|
|
||||||
|
return render(request, 'fiches/fiches_modif.html', {"form": form})
|
||||||
|
|
||||||
else:
|
|
||||||
form = ProfileForm(instance=profile)
|
|
||||||
|
|
||||||
return render(request,'fiches/fiches_modif.html',{"form":form})
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def search(request):
|
def search(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = SearchForm(request.POST)
|
form = SearchForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
result = Profile.objects.filter(full_name__icontains=form.cleaned_data['name'])
|
name = form.cleaned_data["name"]
|
||||||
return render(request,'fiches/search.html',{"form":form,"result":result})
|
result = Profile.objects.filter(full_name__icontains=name)
|
||||||
else:
|
context = {"form": form, "result": result}
|
||||||
form = SearchForm()
|
return render(request, 'fiches/search.html', context)
|
||||||
return render(request,'fiches/search.html',{"form":form})
|
else:
|
||||||
|
form = SearchForm()
|
||||||
|
return render(request, 'fiches/search.html', {"form": form})
|
||||||
|
|
Loading…
Reference in a new issue