Changements divers
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / forms.py
1 # -*- encoding: utf-8 -*-
2 from django import forms
3 from models import *
4 from models import Utilisateur
5
6 class PersonneForm(forms.ModelForm):
7 password = forms.CharField(widget=forms.PasswordInput(), label="Mot de passe")
8 genre = forms.ChoiceField(widget=forms.RadioSelect(), choices=GENRE_CHOICES)
9 class Meta:
10 model = Utilisateur
11 fields = ('nom', 'prenom', 'courriel', 'password', 'genre')
12
13 class GroupeForm(forms.ModelForm):
14 class Meta:
15 model = Chercheur
16 fields = ('groupes',)
17
18 class ChercheurForm(forms.ModelForm):
19 class Meta:
20 model = Chercheur
21 fields = ('fonction', 'diplome',)
22
23 class PublicationForm(forms.ModelForm):
24 class Meta:
25 model = Publication
26 fields = ('titre', 'annee', 'revue', 'editeur', 'lieu_edition', 'nb_pages', 'url')
27
28 class TheseForm(PublicationForm):
29 titre = forms.CharField(required=True, label="Titre")
30 annee = forms.IntegerField(required=False, label="Année de soutenance")
31 class Meta:
32 model = Publication
33 fields = ('titre', 'annee', 'revue', 'editeur', 'lieu_edition', 'nb_pages', 'url')
34
35 class EtablissementForm(forms.ModelForm):
36 class Meta:
37 model = Chercheur
38 fields = ('etablissement',)
39
40 class EtablissementAutreForm(forms.ModelForm):
41 class Meta:
42 model = Chercheur
43 fields = ('etablissement_autre_nom', 'etablissement_autre_pays', )
44
45 class DisciplineForm(forms.ModelForm):
46 class Meta:
47 model = Chercheur
48 fields = ('discipline', 'expertise', 'mots_cles', 'url_site_web', 'url_blog', 'url_facebook', 'url_linkedin')
49
50 class PersonneEditForm(forms.ModelForm):
51 class Meta:
52 model = Personne
53 fields = ('nom', 'prenom', 'genre')
54
55
56 class RepertoireSearchForm (forms.Form):
57 mots_cles = forms.CharField (required = False, label="Mots-clés")
58 discipline = forms.ModelChoiceField(queryset=Discipline.objects.all(), required=False, label="Discipline", empty_label="Tous")
59 domaine = forms.ModelChoiceField(queryset=Groupe.objects.all(), required=False, label="Domaine de recherche", empty_label="Tous")
60 fonction = forms.ChoiceField(choices=(('','Tous'),)+FONCTION_CHOICES, required=False, label="Fonction")
61 pays = forms.ModelChoiceField(queryset=Pays.objects.all().order_by("nom"), required=False, label="Localisation", empty_label="Tous")
62
63 class SendPasswordForm(forms.Form):
64 email = forms.EmailField(required=True, label="courriel")
65 def clean_email(self):
66 cleaned_data = self.cleaned_data
67 email = cleaned_data.get("email")
68 if email:
69 try:
70 Utilisateur.objects.get(courriel=email)
71 except:
72 raise forms.ValidationError("Ce courriel n'existe pas dans notre base de données.")
73 return email
74