A better date selector in query page.

This commit is contained in:
Mustafa Arıcı 2011-02-13 08:56:53 +00:00
parent 1c78d6a0d1
commit b730c75e29
2 changed files with 43 additions and 22 deletions

View File

@ -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):

View File

@ -1,29 +1,36 @@
{% extends "main/base.html" %}
{% block body %}
{% comment %}
<form action="{{ BASE_URL }}/query" method='GET'>
<b>Yazar<br> Adı:</b><input type="text" name="q_author_name">
ve/veya
<b>Soyadı:</b><input type="text" name="q_author_surname"><br>
veya<br>
<b>Aradığınız Metin:</b><input type="text" name="q_text">
<input type="submit" value="Listele">
</form>
{% endcomment %}
<form action="{{ BASE_URL }}/query/" method="POST" enctype="multipart/form-data">
<table border="0px">
{% for field in q_form %}
<tr>
<div class="fieldWrapper">
{% if field.errors %}
<span class="error">{{ field.errors }}</span>
{% endif %}
{{ field.label_tag }}
<td>{{ field.label_tag }}</td>
<td>
{{ field }}
</td>
{% if field.help_text %}
<span class="small">{{ field.help_text }}</span>
<td>
<span class="small">
{{ field.help_text }}
</span>
</td>
{% endif %}
{{ field }}
{% if field.errors %}
<td>
<span class="error">
{{ field.errors }}
</span>
</td>
{% endif %}
</div>
</tr>
{% endfor %}
</table>
<div class="spacer"></div>
<input type="submit" value="Listele" />
</form>