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',
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
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
|
||||||
|
@ -17,5 +18,6 @@ class ProfileForm(forms.ModelForm):
|
||||||
"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,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,15 +1,15 @@
|
||||||
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
|
||||||
|
@ -19,20 +19,22 @@ def fiche_modif(request):
|
||||||
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:
|
else:
|
||||||
form = ProfileForm(instance=profile)
|
form = ProfileForm(instance=profile)
|
||||||
|
|
||||||
return render(request,'fiches/fiches_modif.html',{"form":form})
|
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)
|
||||||
|
context = {"form": form, "result": result}
|
||||||
|
return render(request, 'fiches/search.html', context)
|
||||||
else:
|
else:
|
||||||
form = SearchForm()
|
form = SearchForm()
|
||||||
return render(request,'fiches/search.html',{"form":form})
|
return render(request, 'fiches/search.html', {"form": form})
|
||||||
|
|
Loading…
Reference in a new issue