Mise en commun form edit et create chercheur
[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
5b9abc81 21 fields = ('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")
5b9abc81 30 annee = forms.IntegerField(required=False, label="Année de soutenance (réalisée ou prévue)")
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
5b9abc81
AJ
37class ExpertiseForm(forms.ModelForm):
38 class Meta:
39 model = Expertise
40 fields = ('nom', 'date', 'organisme_demandeur', 'organisme_demandeur_visible')
dab519fa 41
7c596de2
AJ
42class EtablissementForm(forms.ModelForm):
43 class Meta:
44 model = Chercheur
45 fields = ('etablissement',)
46
00755d9b
AJ
47class EtablissementAutreForm(forms.ModelForm):
48 class Meta:
49 model = Chercheur
5b9abc81 50 fields = ('etablissement_autre_nom', 'etablissement_autre_pays', 'enseignant' )
00755d9b 51
7c596de2
AJ
52class DisciplineForm(forms.ModelForm):
53 class Meta:
54 model = Chercheur
5b9abc81 55 fields = ('discipline', 'theme_recherche', 'mots_cles', 'url_site_web', 'url_blog', 'url_facebook', 'url_linkedin')
13146d99 56
b3e1079e
AJ
57class PersonneEditForm(forms.ModelForm):
58 class Meta:
59 model = Personne
60 fields = ('nom', 'prenom', 'genre')
5b9abc81 61
13146d99 62class RepertoireSearchForm (forms.Form):
0e9597af
AJ
63 mots_cles = forms.CharField (required = False, label="Mots-clés")
64 discipline = forms.ModelChoiceField(queryset=Discipline.objects.all(), required=False, label="Discipline", empty_label="Tous")
65 domaine = forms.ModelChoiceField(queryset=Groupe.objects.all(), required=False, label="Domaine de recherche", empty_label="Tous")
8ea92a0d 66 fonction = forms.ChoiceField(choices=(('','Tous'),('chercheur','Chercheur'), ('enseignant','Enseignant-Chercheur'), ('expert','Expert')), required=False, label="Fonction")
0e9597af
AJ
67 pays = forms.ModelChoiceField(queryset=Pays.objects.all().order_by("nom"), required=False, label="Localisation", empty_label="Tous")
68
69class SendPasswordForm(forms.Form):
70 email = forms.EmailField(required=True, label="courriel")
71 def clean_email(self):
72 cleaned_data = self.cleaned_data
73 email = cleaned_data.get("email")
74 if email:
75 try:
76 Utilisateur.objects.get(courriel=email)
77 except:
78 raise forms.ValidationError("Ce courriel n'existe pas dans notre base de données.")
e427f068
AJ
79 return email
80
81class NewPasswordForm(forms.Form):
82 password = forms.CharField(widget=forms.PasswordInput(), required=True, label="Mot de passe")
83 password_repeat = forms.CharField(widget=forms.PasswordInput(), required=True, label="Confirmez mot de passe")
84 def clean_password_repeat(self):
85 cleaned_data = self.cleaned_data
86 password = cleaned_data.get("password")
87 password_repeat = cleaned_data.get("password_repeat")
88 if password and password_repeat:
89 if password != password_repeat:
90 raise forms.ValidationError("Les mots de passe ne concordent pas")
91 return password_repeat
0e9597af 92