Merge branch 'master' of gitosis@git.auf:auf_savoirs_en_partage_django
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / forms.py
CommitLineData
932eef9a
AJ
1# -*- encoding: utf-8 -*-
2from django import forms
3from models import *
0e9597af 4from models import Utilisateur
13146d99 5
932eef9a 6class PersonneForm(forms.ModelForm):
c18af6bd
AJ
7 password = forms.CharField(widget=forms.PasswordInput(), label="Mot de passe")
8 genre = forms.ChoiceField(widget=forms.RadioSelect(), choices=GENRE_CHOICES)
932eef9a 9 class Meta:
dab519fa
AJ
10 model = Utilisateur
11 fields = ('nom', 'prenom', 'courriel', 'password', 'genre')
5ecd9e43 12
3eb00212
AJ
13class GroupeForm(forms.ModelForm):
14 class Meta:
15 model = Chercheur
16 fields = ('groupes',)
932eef9a
AJ
17
18class ChercheurForm(forms.ModelForm):
19 class Meta:
20 model = Chercheur
3eb00212 21 fields = ('fonction', 'diplome',)
7c596de2 22
00755d9b
AJ
23class PublicationForm(forms.ModelForm):
24 class Meta:
25 model = Publication
6befc7c9 26 fields = ('titre', 'annee', 'revue', 'editeur', 'lieu_edition', 'nb_pages', 'url')
f810842d
AJ
27
28class TheseForm(PublicationForm):
2a36714f 29 titre = forms.CharField(required=True, label="Titre de la thèse ou du mémoire")
3eb00212 30 annee = forms.IntegerField(required=False, label="Année de soutenance")
2a36714f
AJ
31 editeur = forms.CharField(required=False, label="Directeur de thèse")
32 lieu_edition = forms.CharField(required=False, label="Établissement de soutenance")
e8e9e4fd
AJ
33 class Meta:
34 model = Publication
2a36714f
AJ
35 fields = ('titre', 'annee', 'editeur', 'lieu_edition', 'nb_pages', 'url')
36
37
dab519fa 38
7c596de2
AJ
39class EtablissementForm(forms.ModelForm):
40 class Meta:
41 model = Chercheur
42 fields = ('etablissement',)
43
00755d9b
AJ
44class EtablissementAutreForm(forms.ModelForm):
45 class Meta:
46 model = Chercheur
47 fields = ('etablissement_autre_nom', 'etablissement_autre_pays', )
48
7c596de2
AJ
49class DisciplineForm(forms.ModelForm):
50 class Meta:
51 model = Chercheur
5ecd9e43 52 fields = ('discipline', 'expertise', 'mots_cles', 'url_site_web', 'url_blog', 'url_facebook', 'url_linkedin')
13146d99 53
b3e1079e
AJ
54class PersonneEditForm(forms.ModelForm):
55 class Meta:
56 model = Personne
57 fields = ('nom', 'prenom', 'genre')
58
13146d99
AJ
59
60class RepertoireSearchForm (forms.Form):
0e9597af
AJ
61 mots_cles = forms.CharField (required = False, label="Mots-clés")
62 discipline = forms.ModelChoiceField(queryset=Discipline.objects.all(), required=False, label="Discipline", empty_label="Tous")
63 domaine = forms.ModelChoiceField(queryset=Groupe.objects.all(), required=False, label="Domaine de recherche", empty_label="Tous")
64 fonction = forms.ChoiceField(choices=(('','Tous'),)+FONCTION_CHOICES, required=False, label="Fonction")
65 pays = forms.ModelChoiceField(queryset=Pays.objects.all().order_by("nom"), required=False, label="Localisation", empty_label="Tous")
66
67class SendPasswordForm(forms.Form):
68 email = forms.EmailField(required=True, label="courriel")
69 def clean_email(self):
70 cleaned_data = self.cleaned_data
71 email = cleaned_data.get("email")
72 if email:
73 try:
74 Utilisateur.objects.get(courriel=email)
75 except:
76 raise forms.ValidationError("Ce courriel n'existe pas dans notre base de données.")
e427f068
AJ
77 return email
78
79class NewPasswordForm(forms.Form):
80 password = forms.CharField(widget=forms.PasswordInput(), required=True, label="Mot de passe")
81 password_repeat = forms.CharField(widget=forms.PasswordInput(), required=True, label="Confirmez mot de passe")
82 def clean_password_repeat(self):
83 cleaned_data = self.cleaned_data
84 password = cleaned_data.get("password")
85 password_repeat = cleaned_data.get("password_repeat")
86 if password and password_repeat:
87 if password != password_repeat:
88 raise forms.ValidationError("Les mots de passe ne concordent pas")
89 return password_repeat
0e9597af 90