From f8889d1f0d3eda475e0764cf3b4e572870f3ed56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ar=C4=B1c=C4=B1?= Date: Mon, 16 Aug 2010 07:40:40 +0000 Subject: [PATCH] Added Label based viewing. --- .../mustafa_branch/djagen/collector/models.py | 5 ++--- .../mustafa_branch/djagen/collector/views.py | 21 ++++++++++++------- DJAGEN/branches/mustafa_branch/djagen/urls.py | 8 +++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/DJAGEN/branches/mustafa_branch/djagen/collector/models.py b/DJAGEN/branches/mustafa_branch/djagen/collector/models.py index eee5269..332285f 100755 --- a/DJAGEN/branches/mustafa_branch/djagen/collector/models.py +++ b/DJAGEN/branches/mustafa_branch/djagen/collector/models.py @@ -32,7 +32,7 @@ class Authors (models.Model): current_status = models.SmallIntegerField(default=2, choices=ACTION_CHOICES, help_text="Current Status of the Author") #whether the application to the planet is approved, the approved ones will be shown at the planet is_approved = models.BooleanField(default=1, help_text="Approve Status of the Author") - + #planets that the channel belongs to #at the config.ini the entries should be obe of the belows: #label = Personal @@ -84,8 +84,7 @@ class Entries (models.Model): class Meta: ordering = ['-date'] - - + def sanitize(self, data): p = re.compile(r'<[^<]*?/?>') return p.sub('', data) diff --git a/DJAGEN/branches/mustafa_branch/djagen/collector/views.py b/DJAGEN/branches/mustafa_branch/djagen/collector/views.py index a9fbb30..32082d7 100755 --- a/DJAGEN/branches/mustafa_branch/djagen/collector/views.py +++ b/DJAGEN/branches/mustafa_branch/djagen/collector/views.py @@ -160,7 +160,7 @@ def query(request): return render_to_response('main/query.html', {'q_form': form, 'BASE_URL': BASE_URL,'info_area':info_area}) -def archive(request,archive_year=None,archive_month=None,archive_day=None): +def archive(request,archive_year=None,archive_month=None,archive_day=None,label=None): info_area = 'archive' # This setting gets the content truncated which contains more than words. truncate_words = 250 @@ -183,19 +183,23 @@ def archive(request,archive_year=None,archive_month=None,archive_day=None): q_text = request.GET['q_text'] else: q_text = "" - if ('q_label_personal' in request.GET and request.GET['q_label_personal'] == '1'): #If that exists and not empty - q_label_personal = request.GET['q_label_personal'] + if ((label == "personal") or 'q_label_personal' in request.GET and request.GET['q_label_personal'] == '1'): #If that exists and not empty + q_label_personal = 1 else: q_label_personal = "" - if ('q_label_community' in request.GET and request.GET['q_label_community'] == '1'): - q_label_community = request.GET['q_label_community'] + if ((label == "community") or 'q_label_community' in request.GET and request.GET['q_label_community'] == '1'): + q_label_community = 1 else: q_label_community = "" - if ('q_label_lkd' in request.GET and request.GET['q_label_lkd']=='1'): - q_label_lkd = request.GET['q_label_lkd'] + if ((label == "lkd") or 'q_label_lkd' in request.GET and request.GET['q_label_lkd']=='1'): + q_label_lkd = 1 else: q_label_lkd = "" + if ((label == "eng") or 'q_label_eng' in request.GET and request.GET['q_label_eng']=='1'): + q_label_eng = 1 + else: + q_label_eng = "" #-- #-- @@ -217,6 +221,9 @@ def archive(request,archive_year=None,archive_month=None,archive_day=None): entries_list = entries_list.filter(entry_id__label_community = 1) if(q_label_lkd): entries_list = entries_list.filter(entry_id__label_lkd = 1) + if(q_label_eng): + entries_list = entries_list.filter(entry_id__label_eng = 1) + # Text search. diff --git a/DJAGEN/branches/mustafa_branch/djagen/urls.py b/DJAGEN/branches/mustafa_branch/djagen/urls.py index f8a66d8..dd9ddca 100755 --- a/DJAGEN/branches/mustafa_branch/djagen/urls.py +++ b/DJAGEN/branches/mustafa_branch/djagen/urls.py @@ -16,14 +16,18 @@ urlpatterns = patterns('', # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), #(r'^archive/$',archive), - (r'^main/', 'djagen.collector.views.main'), + (r'^main/$', 'djagen.collector.views.main'), + (r'^$', 'djagen.collector.views.main'), + (r'^kisisel/$', archive, {"label":"personal"}), + (r'^topluluk/$', archive, {"label":"community"}), + (r'^lkd/$', archive, {"label":"lkd"}), + (r'^english/$', archive, {"label":"eng"}), (r'^subscribe/', 'djagen.collector.views.member_subscribe'), (r'^members/', 'djagen.collector.views.list_members'), (r'^archive/$',archive), (r'^archive/(?P\d{4})/$', archive), (r'^archive/(?P\d{4})/(?P\d{1,2})/$', archive), (r'^archive/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', archive), - (r'^djagen/$',main), (r'^query/$',query), ) urlpatterns += patterns('',