diff --git a/DJAGEN/trunk/djagen/collector/admin.py b/DJAGEN/trunk/djagen/collector/admin.py index 142be79..d2125b6 100755 --- a/DJAGEN/trunk/djagen/collector/admin.py +++ b/DJAGEN/trunk/djagen/collector/admin.py @@ -20,7 +20,7 @@ class AuthorsAdmin (admin.ModelAdmin): search_fields = ['author_name', 'author_surname', 'author_email'] def save_model(self, request, obj, form, change): - + #get the values for saving author_name = obj.author_name author_surname = obj.author_surname diff --git a/DJAGEN/trunk/djagen/collector/forms.py b/DJAGEN/trunk/djagen/collector/forms.py index e15bf4e..c33ce8d 100755 --- a/DJAGEN/trunk/djagen/collector/forms.py +++ b/DJAGEN/trunk/djagen/collector/forms.py @@ -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() ) diff --git a/DJAGEN/trunk/djagen/collector/views.py b/DJAGEN/trunk/djagen/collector/views.py index 016fb16..91f0972 100755 --- a/DJAGEN/trunk/djagen/collector/views.py +++ b/DJAGEN/trunk/djagen/collector/views.py @@ -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) 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.save() #save the history with explanation author.history_set.create(action_type=5, action_date=datetime.datetime.now(), action_explanation=request.POST['message']) - + #send mail part #fill it here 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): - 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())): @@ -236,7 +241,7 @@ def archive(request,archive_year='',archive_month='',archive_day=''): # 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. try: page = int(request.GET.get('page', '1')) diff --git a/DJAGEN/trunk/djagen/gezegen/planet.py b/DJAGEN/trunk/djagen/gezegen/planet.py index a245a76..74776ad 100755 --- a/DJAGEN/trunk/djagen/gezegen/planet.py +++ b/DJAGEN/trunk/djagen/gezegen/planet.py @@ -166,16 +166,29 @@ def main(): # run the planet my_planet = planet.Planet(config) my_planet.run(planet_name, planet_link, template_files, offline) - - - + + + ## This is where archiving is done! ## #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 except: @@ -184,7 +197,7 @@ def main(): channel_subtitle = channel.subtitle except: channel_subtitle = None - try: + try: channel_title = channel.title except: channel_title = None @@ -200,9 +213,8 @@ def main(): channel_urlstatus = channel.url_status except: channel_urlstatus = None - label = channel.label - + label_personal = 0 label_lkd = 0 label_community = 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,8 +249,8 @@ 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() @@ -264,7 +276,7 @@ def main(): 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.content_text = entry.sanitize(content_html) - + entry.save() #datetime issue diff --git a/DJAGEN/trunk/djagen/templates/main/archive.html b/DJAGEN/trunk/djagen/templates/main/archive.html index dc961eb..2951f40 100755 --- a/DJAGEN/trunk/djagen/templates/main/archive.html +++ b/DJAGEN/trunk/djagen/templates/main/archive.html @@ -7,17 +7,17 @@ {% autoescape off %} {% ifequal entry.entry_id.is_approved 1 %} - + {% ifchanged entry.date.day entry.date.month entry.date.year %}
{% endifchanged %} {% ifchanged %}

{{ entry.date|date:"d F Y" }}

{% endifchanged %}
- +

{{ entry.title }}

- Yazar: {{ entry.entry_id.author_name }} + Yazar: {{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }} Tarih: {{ entry.date|date:"d F Y H:i" }}

@@ -27,39 +27,70 @@ {% endautoescape %}
- + {% endfor %} - + + +{% else %} Sayfa {{ p_entries_list.number }} / {{ p_entries_list.paginator.num_pages }} -
- {% if p_entries_list.has_previous %} - Geri - {% endif %} - | - - {% for pNum in p_entries_list.paginator.page_range %} - {% ifequal pNum p_entries_list.number %} - {{ pNum }} - {% else %} - {{ pNum }} - {% endifequal %} - {% endfor %} - - | - {% if p_entries_list.has_next %} - İleri - {% endif %} -
- - - -
+
+ {% if p_entries_list.has_previous %} + Geri + {% endif %} + | + + {% for pNum in p_entries_list.paginator.page_range %} + {% ifequal pNum p_entries_list.number %} + {{ pNum }} + {% else %} + {{ pNum }} + {% endifequal %} + {% endfor %} + + | + {% if p_entries_list.has_next %} + İleri + {% endif %} +
+ + + + +{% endif %} {% endblock %} diff --git a/DJAGEN/trunk/djagen/templates/main/base.html b/DJAGEN/trunk/djagen/templates/main/base.html index a8b4059..cd4dd6a 100755 --- a/DJAGEN/trunk/djagen/templates/main/base.html +++ b/DJAGEN/trunk/djagen/templates/main/base.html @@ -88,8 +88,7 @@ {% if q_text %} İçinde {{ q_text|truncatewords:8 }} geçen girdiler - {% endif %} - .

+ {% endif %}.

{% endif %} diff --git a/DJAGEN/trunk/djagen/templates/main/main.html b/DJAGEN/trunk/djagen/templates/main/main.html index 6c178fa..3dc3f8f 100755 --- a/DJAGEN/trunk/djagen/templates/main/main.html +++ b/DJAGEN/trunk/djagen/templates/main/main.html @@ -7,17 +7,17 @@ {% autoescape off %} {% ifequal entry.entry_id.is_approved 1 %} - + {% ifchanged entry.date.day entry.date.month entry.date.year %}
{% endifchanged %} {% ifchanged %}

{{ entry.date|date:"d F Y" }}

{% endifchanged %}
- +

{{ entry.title }}

- Yazar: {{ entry.entry_id.author_name }} + Yazar: {{ entry.entry_id.author_name }} {{ entry.entry_id.author_surname }} Tarih: {{ entry.date|date:"d F Y H:i" }}

@@ -27,7 +27,7 @@ {% endautoescape %}
- + {% endfor %} diff --git a/DJAGEN/trunk/djagen/templates/main/query.html b/DJAGEN/trunk/djagen/templates/main/query.html index c3a3f25..327eccf 100755 --- a/DJAGEN/trunk/djagen/templates/main/query.html +++ b/DJAGEN/trunk/djagen/templates/main/query.html @@ -1,11 +1,30 @@ {% extends "main/base.html" %} {% block body %} -
- Yazar
Adı:
+{% comment %} + + Yazar
Adı:
ve/veya Soyadı:
veya
- Aradığınız Metin: - -
+ 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 }} +
+ {% endfor %} +
+ +
{% endblock %}