Merging latest changes done to my branch into trunk.

This commit is contained in:
Mustafa Arıcı 2010-07-16 08:05:10 +00:00
parent 04d76c5349
commit f5416a259d
8 changed files with 141 additions and 75 deletions

View File

@ -16,6 +16,6 @@ class ContactForm(forms.Form):
captcha = CaptchaField(label="Captcha Alanı", help_text='Gördüğünü karakterleri aynen yazınız', error_messages={'required': 'Hatalı yazdınız!'})
class QueryForm(forms.Form):
name = forms.CharField(max_length=25, required = False, label = 'Adı')
surname = forms.CharField(max_length=25, required = False, label = 'Soyadı')
text = forms.CharField(required = False, label = 'Aradığınız metin', widget = forms.widgets.Textarea() )
q_author_name = forms.CharField(max_length=25, required = False, label = 'Adı')
q_author_surname = forms.CharField(max_length=25, required = False, label = 'Soyadı')
q_text = forms.CharField(required = False, label = 'Aradığınız metin', widget = forms.widgets.Textarea() )

View File

@ -117,7 +117,12 @@ def list_members(request):
def query(request):
return render_response(request,'main/query.html',{'BASE_URL' : BASE_URL})
q_form = QueryForm()
return render_response(request,'main/query.html',{
'BASE_URL' : BASE_URL,
'q_form':q_form,
})
def archive(request,archive_year='',archive_month='',archive_day=''):
@ -129,31 +134,28 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
run_time = RunTime.objects.all()[0]
### Determine if the request includes any query or not. ###
try:
does_getPage_exists = request.GET['page']
except:
does_getPage_exists = None
### Determine if the request object includes any querying input or not. ###
if ( (request.GET) and ( not( does_getPage_exists) )):
if ( (request.GET) and ('q_author_name' in request.GET or 'q_author_surname' in request.GET or 'q_text' in request.GET ) ):
# Switch to 'return the result of query' mode.
info_area = 'query'
#Querying
#TODO: We should improve the querying method here.
#TODO: We should improve querying method implemented here.
q_author_name,q_author_surname,q_text = '','',''
authors = Authors.objects.all()
if ( ('q_author_name' in request.GET) and (request.GET['q_author_name'] )):
q_author_name = request.GET['q_author_name']
authors = authors.filter(author_name__icontains = q_author_name)
authors = authors.filter(author_name__iexact = q_author_name)
if (('q_author_surname' in request.GET) and (request.GET['q_author_surname'])):
q_author_surname = request.GET['q_author_surname']
authors = authors.filter(author_surname__icontains = q_author_surname)
authors = authors.filter(author_surname__iexact = q_author_surname)
for item in authors:
try:
entries_list |= item.entries_set.all()
except:
@ -161,11 +163,11 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
if( ('q_text' in request.GET)and(request.GET['q_text'])):
q_text = request.GET['q_text']
if (q_author_name or q_author_surname):
try:
entries_list |= Entries.objects.filter(content_text__icontains = request.GET['q_text'])
except:
entries_list = Entries.objects.filter(content_text__icontains = request.GET['q_text'])
entries_list = entries_list.filter(content_text__icontains = q_text)
else:
entries_list = Entries.objects.filter(content_text__icontains = q_text)
@ -174,8 +176,10 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
return HttpResponseRedirect(BASE_URL+"/query")
except:
return HttpResponseRedirect(BASE_URL+ "/query")
#here is gonna be edited [X]
# Pagination
elements_in_a_page = 25 # This determines, how many elements will be displayed in a paginator page.
paginator = Paginator(entries_list,elements_in_a_page)
# Validation for page number if it is not int return first page.
@ -205,7 +209,7 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
### If not ###
else:
#Switch to return the result of arguments provided mode(archive viewing mode).
info_area = 'archive'
info_area = 'archive' # \This variable is used for determining which infoarea text should be used in "contenttop" div in /main/base.html
selected_entries = Entries.objects.select_related()
@ -222,6 +226,7 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
else:
# Fall back to main view.
return HttpResponseRedirect(BASE_URL+"/main")
#pass
# Check if archive_month is not empty and numeric.
if(archive_month != ''and (str(archive_month).isalnum()) and not(str(archive_month).isalpha())):

View File

@ -173,8 +173,21 @@ def main():
#add the current channels to the db
channels = my_planet.channels()
for channel in channels:
author_name = channel.name
### This part seperates surname from name do not activate it if needn't.
words = channel.name.split()
if len(words) == 1:
author_name = words[0]
author_surname == None
else:
author_surname = words[-1]
words.pop()
tmp_first_name = ''
for word in words: tmp_first_name += ' ' + word
author_name = tmp_first_name[1:]
### ###
#print channel.name
#author_name = channel.name
#author_surname = channel.surname
try:
author_face = channel.face
@ -200,7 +213,6 @@ def main():
channel_urlstatus = channel.url_status
except:
channel_urlstatus = None
label = channel.label
label_personal = 0
@ -215,7 +227,6 @@ def main():
label_community = 1
if label == "Eng":
label_eng = 1
id = channel.id
try:
@ -223,6 +234,7 @@ def main():
#update the values with the ones at the config file
author.author_name = author_name
author.author_surname = author_surname
#print author_name
author.author_face = author_face
author.channel_subtitle = channel_subtitle
@ -237,7 +249,7 @@ def main():
except Exception, ex:
#print ex
author = Authors(author_id=id, author_name=author_name, author_face=author_face, channel_subtitle=channel_subtitle, channel_title=channel_title, channel_url=channel_url, channel_link=channel_link, channel_urlstatus=channel_urlstatus, label_personal=label_personal, label_lkd=label_lkd, label_community=label_community, label_eng=label_eng)
author = Authors(author_id=id, author_name=author_name, author_surname=author_surname, author_face=author_face, channel_subtitle=channel_subtitle, channel_title=channel_title, channel_url=channel_url, channel_link=channel_link, channel_urlstatus=channel_urlstatus, label_personal=label_personal, label_lkd=label_lkd, label_community=label_community, label_eng=label_eng)
author.save()

View File

@ -14,10 +14,10 @@
<div class="innercontent">
<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}"><img class="face" src="/djagenmedia/images/heads/{{ entry.entry_id.author_face|default:"nobody.png" }}" title="{{ entry.entry_id.author_name }}" width="80" height="80" /></a>
<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}"><img class="face" src="/djagenmedia/images/heads/{{ entry.entry_id.author_face|default:"nobody.png" }}" title="{{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }}" width="80" height="80" /></a>
<h1 class="title"><a href="{{ entry.link }} ">{{ entry.title }}</a></h1>
<p class="yazaneden">
Yazar:&nbsp;<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}">{{ entry.entry_id.author_name }}</a>
Yazar:&nbsp;<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}">{{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }}</a>
Tarih:&nbsp;<span class="blogdate">{{ entry.date|date:"d F Y H:i" }}</span>
</p>
<div class="blogcontent">
@ -34,12 +34,43 @@
<div class="pagination">
<span class="step-links">
{% if q_author_name or q_author_surname or q_text %}
<span class="current">
Sayfa <b>{{ p_entries_list.number }}</b> / <b>{{ p_entries_list.paginator.num_pages }}</b>
</span>
<div class="pagelist" style="text-align:center">
{% if p_entries_list.has_previous %}
<a href="?page={{ p_entries_list.previous_page_number }}">Geri</a>
<a href="?q_author_name={{ q_author_name }}&q_author_surname={{ q_author_surname }}&q_text={{ q_text }}&page={{ p_entries_list.previous_page_number }}">Geri</a>
{% endif %}
|
{% for pNum in p_entries_list.paginator.page_range %}
{% ifequal pNum p_entries_list.number %}
{{ pNum }}
{% else %}
<a href="?q_author_name={{ q_author_name }}&q_author_surname={{ q_author_surname }}&q_text={{ q_text }}&page={{ pNum }}">{{ pNum }}</a>
{% endifequal %}
{% endfor %}
|
{% if p_entries_list.has_next %}
<a href="?q_author_name={{ q_author_name }}&q_author_surname={{ q_author_surname }}&q_text={{ q_text }}&page={{ p_entries_list.next_page_number }}">İleri</a>
{% endif %}
</div>
</span>
</div>
{% else %}
<span class="current">
Sayfa <b>{{ p_entries_list.number }}</b> / <b>{{ p_entries_list.paginator.num_pages }}</b>
</span>
<div class="pagelist" style="text-align:center">
{% if p_entries_list.has_previous %}
<a href="?q_author_name=?page={{ p_entries_list.previous_page_number }}">Geri</a>
{% endif %}
|
@ -59,7 +90,7 @@
</span>
</div>
</div>
{% endif %}
{% endblock %}

View File

@ -88,8 +88,7 @@
{% if q_text %}
İçinde <b>{{ q_text|truncatewords:8 }}</b> geçen girdiler
{% endif %}
.</p>
{% endif %}.</p>
{% endif %}

View File

@ -14,10 +14,10 @@
<div class="innercontent">
<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}"><img class="face" src="/djagenmedia/images/heads/{{ entry.entry_id.author_face|default:"nobody.png" }}" title="{{ entry.entry_id.author_name }}" width="80" height="80" /></a>
<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}"><img class="face" src="/djagenmedia/images/heads/{{ entry.entry_id.author_face|default:"nobody.png" }}" title="{{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }}" width="80" height="80" /></a>
<h1 class="title"><a href="{{ entry.link }} ">{{ entry.title }}</a></h1>
<p class="yazaneden">
Yazar:&nbsp;<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}">{{ entry.entry_id.author_name }}</a>
Yazar:&nbsp;<a href="{{ entry.entry_id.channel_link }}" title="{{ entry.entry_id.channel_title }}">{{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }}</a>
Tarih:&nbsp;<span class="blogdate">{{ entry.date|date:"d F Y H:i" }}</span>
</p>
<div class="blogcontent">

View File

@ -1,5 +1,6 @@
{% extends "main/base.html" %}
{% block body %}
{% comment %}
<form action='{{ BASE_URL }}/archive ' method='GET'>
<b>Yazar<br> Adı:</b><input type="text" name="q_author_name">
ve/veya
@ -8,4 +9,22 @@
<b>Aradığınız Metin:</b><input type="text" name="q_text">
<input type="submit" value="Listele">
</form>
{% endcomment %}
<form action="{{ BASE_URL }}/archive" method="GET" enctype="multipart/form-data">
{% for field in q_form %}
<div class="fieldWrapper">
{% if field.errors %}
<span class="error">{{ field.errors }}</span>
{% endif %}
{{ field.label_tag }}
{% if field.help_text %}
<span class="small">{{ field.help_text }}</span>
{% endif %}
{{ field }}
</div>
{% endfor %}
<div class="spacer"></div>
<input type="submit" value="Listele" />
</form>
{% endblock %}