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

@ -20,7 +20,7 @@ class AuthorsAdmin (admin.ModelAdmin):
search_fields = ['author_name', 'author_surname', 'author_email'] search_fields = ['author_name', 'author_surname', 'author_email']
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):
#get the values for saving #get the values for saving
author_name = obj.author_name author_name = obj.author_name
author_surname = obj.author_surname author_surname = obj.author_surname

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!'}) 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): class QueryForm(forms.Form):
name = forms.CharField(max_length=25, required = False, label = 'Adı') q_author_name = forms.CharField(max_length=25, required = False, label = 'Adı')
surname = forms.CharField(max_length=25, required = False, label = 'Soyadı') q_author_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_text = forms.CharField(required = False, label = 'Aradığınız metin', widget = forms.widgets.Textarea() )

View File

@ -72,12 +72,12 @@ def member_subscribe(request):
author = Authors(author_name=request.POST['name'], author_surname=request.POST['surname'], author_email=request.POST['email'], channel_url=request.POST['feed'], author_face=f.name, is_approved=0, current_status=5) author = Authors(author_name=request.POST['name'], author_surname=request.POST['surname'], author_email=request.POST['email'], channel_url=request.POST['feed'], author_face=f.name, is_approved=0, current_status=5)
else: else:
author = Authors(author_name=request.POST['name'], author_surname=request.POST['surname'], author_email=request.POST['email'], channel_url=request.POST['feed'], is_approved=0, current_status=5) author = Authors(author_name=request.POST['name'], author_surname=request.POST['surname'], author_email=request.POST['email'], channel_url=request.POST['feed'], is_approved=0, current_status=5)
author.save() author.save()
#save the history with explanation #save the history with explanation
author.history_set.create(action_type=5, action_date=datetime.datetime.now(), action_explanation=request.POST['message']) author.history_set.create(action_type=5, action_date=datetime.datetime.now(), action_explanation=request.POST['message'])
#send mail part #send mail part
#fill it here #fill it here
return render_response(request, 'main/subscribe.html/',{'submit': 'done', 'BASE_URL': BASE_URL,'info_area':info_area}) return render_response(request, 'main/subscribe.html/',{'submit': 'done', 'BASE_URL': BASE_URL,'info_area':info_area})
@ -117,7 +117,12 @@ def list_members(request):
def query(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=''): 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] run_time = RunTime.objects.all()[0]
### Determine if the request includes any query or not. ### ### Determine if the request object includes any querying input or not. ###
try:
does_getPage_exists = request.GET['page']
except:
does_getPage_exists = None
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. # Switch to 'return the result of query' mode.
info_area = 'query' info_area = 'query'
#Querying #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 = '','','' q_author_name,q_author_surname,q_text = '','',''
authors = Authors.objects.all() authors = Authors.objects.all()
if ( ('q_author_name' in request.GET) and (request.GET['q_author_name'] )): if ( ('q_author_name' in request.GET) and (request.GET['q_author_name'] )):
q_author_name = 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'])): if (('q_author_surname' in request.GET) and (request.GET['q_author_surname'])):
q_author_surname = 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: for item in authors:
try: try:
entries_list |= item.entries_set.all() entries_list |= item.entries_set.all()
except: 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'])): if( ('q_text' in request.GET)and(request.GET['q_text'])):
q_text = request.GET['q_text'] q_text = request.GET['q_text']
if (q_author_name or q_author_surname):
try: entries_list = entries_list.filter(content_text__icontains = q_text)
entries_list |= Entries.objects.filter(content_text__icontains = request.GET['q_text']) else:
except: entries_list = Entries.objects.filter(content_text__icontains = q_text)
entries_list = Entries.objects.filter(content_text__icontains = request.GET['q_text'])
@ -174,8 +176,10 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
return HttpResponseRedirect(BASE_URL+"/query") return HttpResponseRedirect(BASE_URL+"/query")
except: except:
return HttpResponseRedirect(BASE_URL+ "/query") return HttpResponseRedirect(BASE_URL+ "/query")
#here is gonna be edited [X] #here is gonna be edited [X]
# Pagination # Pagination
elements_in_a_page = 25 # This determines, how many elements will be displayed in a paginator page. 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) paginator = Paginator(entries_list,elements_in_a_page)
# Validation for page number if it is not int return first 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 ### ### If not ###
else: else:
#Switch to return the result of arguments provided mode(archive viewing mode). #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() selected_entries = Entries.objects.select_related()
@ -222,6 +226,7 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
else: else:
# Fall back to main view. # Fall back to main view.
return HttpResponseRedirect(BASE_URL+"/main") return HttpResponseRedirect(BASE_URL+"/main")
#pass
# Check if archive_month is not empty and numeric. # Check if archive_month is not empty and numeric.
if(archive_month != ''and (str(archive_month).isalnum()) and not(str(archive_month).isalpha())): if(archive_month != ''and (str(archive_month).isalnum()) and not(str(archive_month).isalpha())):
@ -236,7 +241,7 @@ def archive(request,archive_year='',archive_month='',archive_day=''):
# Pagination # Pagination
elements_in_a_page = 25 # This determines, how many elements will be displayed in a paginator page. 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) paginator = Paginator(entries_list,elements_in_a_page)
# Validation for page number if it is not int return first page. # Validation for page number if it is not int return first page.
try: try:
page = int(request.GET.get('page', '1')) page = int(request.GET.get('page', '1'))

View File

@ -166,16 +166,29 @@ def main():
# run the planet # run the planet
my_planet = planet.Planet(config) my_planet = planet.Planet(config)
my_planet.run(planet_name, planet_link, template_files, offline) my_planet.run(planet_name, planet_link, template_files, offline)
## This is where archiving is done! ## ## This is where archiving is done! ##
#add the current channels to the db #add the current channels to the db
channels = my_planet.channels() channels = my_planet.channels()
for channel in channels: for channel in channels:
### This part seperates surname from name do not activate it if needn't.
author_name = channel.name 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: try:
author_face = channel.face author_face = channel.face
except: except:
@ -184,7 +197,7 @@ def main():
channel_subtitle = channel.subtitle channel_subtitle = channel.subtitle
except: except:
channel_subtitle = None channel_subtitle = None
try: try:
channel_title = channel.title channel_title = channel.title
except: except:
channel_title = None channel_title = None
@ -200,9 +213,8 @@ def main():
channel_urlstatus = channel.url_status channel_urlstatus = channel.url_status
except: except:
channel_urlstatus = None channel_urlstatus = None
label = channel.label label = channel.label
label_personal = 0 label_personal = 0
label_lkd = 0 label_lkd = 0
label_community = 0 label_community = 0
@ -215,7 +227,6 @@ def main():
label_community = 1 label_community = 1
if label == "Eng": if label == "Eng":
label_eng = 1 label_eng = 1
id = channel.id id = channel.id
try: try:
@ -223,6 +234,7 @@ def main():
#update the values with the ones at the config file #update the values with the ones at the config file
author.author_name = author_name author.author_name = author_name
author.author_surname = author_surname
#print author_name #print author_name
author.author_face = author_face author.author_face = author_face
author.channel_subtitle = channel_subtitle author.channel_subtitle = channel_subtitle
@ -237,8 +249,8 @@ def main():
except Exception, ex: except Exception, ex:
#print 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() author.save()
@ -264,7 +276,7 @@ def main():
else: summary = item.summary else: summary = item.summary
entry = author.entries_set.create(id_hash=id_hash, title=item.title, content_html=item.content, summary=summary, link=item.link, date=datetime.datetime(d[0], d[1], d[2], d[3], d[4], d[5])) entry = author.entries_set.create(id_hash=id_hash, title=item.title, content_html=item.content, summary=summary, link=item.link, date=datetime.datetime(d[0], d[1], d[2], d[3], d[4], d[5]))
entry.content_text = entry.sanitize(content_html) entry.content_text = entry.sanitize(content_html)
entry.save() entry.save()
#datetime issue #datetime issue

View File

@ -7,17 +7,17 @@
{% autoescape off %} {% autoescape off %}
{% ifequal entry.entry_id.is_approved 1 %} {% ifequal entry.entry_id.is_approved 1 %}
{% ifchanged entry.date.day entry.date.month entry.date.year %}<div class="separator"></div>{% endifchanged %} {% ifchanged entry.date.day entry.date.month entry.date.year %}<div class="separator"></div>{% endifchanged %}
{% ifchanged %}<h2 class="date">{{ entry.date|date:"d F Y" }}</h2>{% endifchanged %} {% ifchanged %}<h2 class="date">{{ entry.date|date:"d F Y" }}</h2>{% endifchanged %}
<div class="innercontent"> <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> <h1 class="title"><a href="{{ entry.link }} ">{{ entry.title }}</a></h1>
<p class="yazaneden"> <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> Tarih:&nbsp;<span class="blogdate">{{ entry.date|date:"d F Y H:i" }}</span>
</p> </p>
<div class="blogcontent"> <div class="blogcontent">
@ -27,39 +27,70 @@
{% endautoescape %} {% endautoescape %}
</div> </div>
{% endfor %} {% endfor %}
<div class="pagination"> <div class="pagination">
<span class="step-links"> <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="?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"> <span class="current">
Sayfa <b>{{ p_entries_list.number }}</b> / <b>{{ p_entries_list.paginator.num_pages }}</b> Sayfa <b>{{ p_entries_list.number }}</b> / <b>{{ p_entries_list.paginator.num_pages }}</b>
</span> </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>
{% endif %}
|
{% for pNum in p_entries_list.paginator.page_range %}
{% ifequal pNum p_entries_list.number %}
{{ pNum }}
{% else %}
<a href="?page={{ pNum }}">{{ pNum }}</a>
{% endifequal %}
{% endfor %}
|
{% if p_entries_list.has_next %}
<a href="?page={{ p_entries_list.next_page_number }}">İleri</a>
{% endif %}
</div>
</span>
</div>
<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 %}
|
{% for pNum in p_entries_list.paginator.page_range %}
{% ifequal pNum p_entries_list.number %}
{{ pNum }}
{% else %}
<a href="?page={{ pNum }}">{{ pNum }}</a>
{% endifequal %}
{% endfor %}
|
{% if p_entries_list.has_next %}
<a href="?page={{ p_entries_list.next_page_number }}">İleri</a>
{% endif %}
</div>
</span>
</div>
{% endif %}
{% endblock %} {% endblock %}

View File

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

View File

@ -7,17 +7,17 @@
{% autoescape off %} {% autoescape off %}
{% ifequal entry.entry_id.is_approved 1 %} {% ifequal entry.entry_id.is_approved 1 %}
{% ifchanged entry.date.day entry.date.month entry.date.year %}<div class="separator"></div>{% endifchanged %} {% ifchanged entry.date.day entry.date.month entry.date.year %}<div class="separator"></div>{% endifchanged %}
{% ifchanged %}<h2 class="date">{{ entry.date|date:"d F Y" }}</h2>{% endifchanged %} {% ifchanged %}<h2 class="date">{{ entry.date|date:"d F Y" }}</h2>{% endifchanged %}
<div class="innercontent"> <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> <h1 class="title"><a href="{{ entry.link }} ">{{ entry.title }}</a></h1>
<p class="yazaneden"> <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> Tarih:&nbsp;<span class="blogdate">{{ entry.date|date:"d F Y H:i" }}</span>
</p> </p>
<div class="blogcontent"> <div class="blogcontent">
@ -27,7 +27,7 @@
{% endautoescape %} {% endautoescape %}
</div> </div>
{% endfor %} {% endfor %}

View File

@ -1,11 +1,30 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% block body %} {% block body %}
<form action='{{ BASE_URL }}/archive ' method='GET'> {% comment %}
<b>Yazar<br> Adı:</b><input type="text" name="q_author_name"> <form action='{{ BASE_URL }}/archive ' method='GET'>
<b>Yazar<br> Adı:</b><input type="text" name="q_author_name">
ve/veya ve/veya
<b>Soyadı:</b><input type="text" name="q_author_surname"><br> <b>Soyadı:</b><input type="text" name="q_author_surname"><br>
veya<br> veya<br>
<b>Aradığınız Metin:</b><input type="text" name="q_text"> <b>Aradığınız Metin:</b><input type="text" name="q_text">
<input type="submit" value="Listele"> <input type="submit" value="Listele">
</form> </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 %} {% endblock %}