From b730c75e29b05b6a3138b7eb63ab296835d7efa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ar=C4=B1c=C4=B1?= Date: Sun, 13 Feb 2011 08:56:53 +0000 Subject: [PATCH] A better date selector in query page. --- .../mustafa_branch/djagen/collector/views.py | 26 ++++++++++--- .../djagen/templates/main/query.html | 39 +++++++++++-------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/DJAGEN/branches/mustafa_branch/djagen/collector/views.py b/DJAGEN/branches/mustafa_branch/djagen/collector/views.py index b3e465a..c0d5caa 100755 --- a/DJAGEN/branches/mustafa_branch/djagen/collector/views.py +++ b/DJAGEN/branches/mustafa_branch/djagen/collector/views.py @@ -123,19 +123,33 @@ def query(request): # Determine if all of them were valid. if (form.is_valid()): + cdata = form.cleaned_data + ## If Yes: - q_author_name = request.POST['q_author_name'] - q_author_surname = request.POST['q_author_surname'] - q_text = request.POST['q_text'] - q_date_year = request.POST['q_date_year'] - q_date_month = request.POST['q_date_month'] - q_date_day = request.POST['q_date_day'] + #q_author_name = request.POST.get('q_author_name','') + q_author_name = cdata.get('q_author_name','') + q_author_surname = cdata.get('q_author_surname','') + q_text = cdata.get('q_text','') + + q_date = cdata.get('q_date','') + if (q_date != None): + + q_date_year = str(q_date.year) + q_date_month = str(q_date.month) + q_date_day = str(q_date.day) + else: + + q_date_year,q_date_month,q_date_day = None,None,None + + # Redirect or call /archive/ view with the existing POST arguments. #++ Complex string operations in order to form needed target_url. args_part = "?q_author_name=%s&q_author_surname=%s&q_text=%s" % (q_author_name,q_author_surname,q_text) date_part = '' + + if (q_date_year): date_part = q_date_year if(q_date_month): diff --git a/DJAGEN/branches/mustafa_branch/djagen/templates/main/query.html b/DJAGEN/branches/mustafa_branch/djagen/templates/main/query.html index 3e96059..eeac925 100755 --- a/DJAGEN/branches/mustafa_branch/djagen/templates/main/query.html +++ b/DJAGEN/branches/mustafa_branch/djagen/templates/main/query.html @@ -1,29 +1,36 @@ {% extends "main/base.html" %} {% block body %} -{% comment %} -
- Yazar
Adı:
- ve/veya - Soyadı:
- veya
- Aradığınız Metin: - -
-{% endcomment %}
+ {% for field in q_form %} +
- {% if field.errors %} - {{ field.errors }} - {% endif %} - {{ field.label_tag }} +
+ + {% if field.help_text %} - {{ field.help_text }} + {% endif %} - {{ field }} + {% if field.errors %} + + {% endif %} + + + {% endfor %} +
{{ field.label_tag }} + {{ field }} + + + {{ field.help_text }} + + + + {{ field.errors }} + +