diff --git a/monstage/static/style.css b/monstage/static/style.css index e59ae20..63566f9 100644 --- a/monstage/static/style.css +++ b/monstage/static/style.css @@ -42,6 +42,7 @@ header li { header h1 { float:left; color:#fff; + margin:20px; } header h1 a { diff --git a/monstage/templates/monstage/search.html b/monstage/templates/monstage/search.html index e772df0..1e8e9af 100644 --- a/monstage/templates/monstage/search.html +++ b/monstage/templates/monstage/search.html @@ -8,7 +8,6 @@ {% endblock %} {% block content %} -

Retour

Rechercher des stages

- {% if resultats %} -

{{ resultats|length }} stage(s) trouvé(s)

+ {% if resultats != None %} +

{{ resultats|length }} stage(s) trouvé(s)

{% for stage in resultats %}

{{ stage.sujet }}

diff --git a/monstage/views.py b/monstage/views.py index db41e7e..e9713c2 100644 --- a/monstage/views.py +++ b/monstage/views.py @@ -76,6 +76,13 @@ class StageForm(forms.ModelForm): model = Stage fields = ("type_stage", "start_date", "end_date", "matieres", "sujet", "thematiques", "encadrants") + def __init__(self, *args, **kwargs): + super(StageForm, self).__init__(*args, **kwargs) + self.fields['matieres'].label = "Matières" + self.fields['thematiques'].help_text = "Une liste de tags séparés par des virgules (ou des espaces)" + self.fields['start_date'].widget.attrs['placeholder'] = "JJ/MM/AAAA" + self.fields['end_date'].widget.attrs['placeholder'] = "JJ/MM/AAAA" + @login_required def stage_add(request): if request.POST: @@ -271,13 +278,13 @@ def detail(request, question_id): from django.db.models import Q class SearchForm(forms.Form): - matiere = forms.ChoiceField(label='Matière :', required=False, choices=tuple([('','Toute matière')] + [(mat.id, mat.name) for mat in StageMatiere.objects.all()])) + matiere = forms.ModelChoiceField(label='Matière :', required=False, queryset = StageMatiere.objects.all(), empty_label="Toute matière") thematiques = forms.CharField(label='Thématiques :', required=False) latitude = forms.DecimalField(widget=HiddenInput(), required=False) longitude = forms.DecimalField(widget=HiddenInput(), required=False) - tolerance = forms.DecimalField(label='Dans un rayon de (en km) :', initial=100, required=False) lieu = forms.CharField(label=u'A proximité de :', required=False) + tolerance = forms.DecimalField(label='Dans un rayon de (en km) :', initial=100, required=False) @login_required def search(request): @@ -297,7 +304,7 @@ def search(request): stages = stages.filter(lieux__in=lieux) matiere = form.cleaned_data['matiere'] if matiere: - stages = stages.filter(matieres__pk=matiere) + stages = stages.filter(matieres=matiere) thematiques = form.cleaned_data['thematiques'].split(',') if thematiques: q = Q()