From 1ab795172026bc585b890f8e53f56b68f6541fe6 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Mon, 4 Feb 2013 11:55:03 +0100 Subject: Rethink urls to be more hierarchic and less RPC --- hyperkitty/templates/messages/like_form.html | 3 +- hyperkitty/templates/recent_activities.html | 2 +- hyperkitty/urls.py | 78 +++++++++++----------------- hyperkitty/views/list.py | 4 +- hyperkitty/views/message.py | 3 +- 5 files changed, 37 insertions(+), 53 deletions(-) (limited to 'hyperkitty') diff --git a/hyperkitty/templates/messages/like_form.html b/hyperkitty/templates/messages/like_form.html index ba78ede..3b99987 100644 --- a/hyperkitty/templates/messages/like_form.html +++ b/hyperkitty/templates/messages/like_form.html @@ -1,6 +1,5 @@
- + action="{% url message_vote mlist_fqdn=list_address, hashid=hashid %}"> {% csrf_token %}
  • +{{ object.likes }}/-{{ object.dislikes }} diff --git a/hyperkitty/templates/recent_activities.html b/hyperkitty/templates/recent_activities.html index 70d944a..37b0693 100644 --- a/hyperkitty/templates/recent_activities.html +++ b/hyperkitty/templates/recent_activities.html @@ -24,7 +24,7 @@ activity_graph( ["{{dates_string|join:'","'}}"], {{evolution}}, - "{% url archives mlist_fqdn=list_address %}" + "{% url archives_latest mlist_fqdn=list_address %}" ); diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py index 10b52ba..ae38fe7 100644 --- a/hyperkitty/urls.py +++ b/hyperkitty/urls.py @@ -44,71 +44,55 @@ urlpatterns = patterns('hyperkitty.views', url(r'^/$', 'pages.index', name='index'), url(r'^$', 'pages.index', name='root'), - # Archives - url(r'^archives/(?P.*@.*)/(?P\d{4})/(?P\d\d?)/(?P\d\d?)/$', + # List archives and overview + url(r'^list/(?P[^/@]+@[^/@]+)/(?P\d{4})/(?P\d\d?)/(?P\d\d?)/$', 'list.archives', name='archives_with_day'), - url(r'^archives/(?P.*@.*)/(?P\d{4})/(?P\d\d?)/$', + url(r'^list/(?P[^/@]+@[^/@]+)/(?P\d{4})/(?P\d\d?)/$', 'list.archives', name='archives_with_month'), - url(r'^archives/(?P.*@.*)/$', - 'list.archives', name='archives'), + url(r'^list/(?P[^/@]+@[^/@]+)/latest$', + 'list.archives', name='archives_latest'), + url(r'^list/(?P[^/@]+@[^/@]+)/$', + 'list.overview', name='list_overview'), - # Lists - url(r'^list/$', 'pages.index'), # Can I remove this URL? - url(r'^list/(?P.*@.*)/$', - 'list.list', name='list_overview'), - - # Search Tag - url(r'^tag/(?P.*@.*)\/(?P.*)\/(?P\d+)/$', - 'list.search_tag'), - url(r'^tag/(?P.*@.*)\/(?P.*)/$', - 'list.search_tag', name='search_tag'), - - # Search - # If page number is present in URL - url(r'^search/(?P.*@.*)\/(?P.*)\/(?P.*)\/(?P\d+)/$', - 'list.search_keyword'), - # Show the first page as default when no page number is present in URL - url(r'^search/(?P.*@.*)\/(?P.*)\/(?P.*)/$', - 'list.search_keyword', name="search_keyword"), - url(r'^search/(?P.*@.*)/$', - 'list.search', name="search_list"), - - - ### MESSAGE LEVEL VIEWS ### - url(r'^message/(?P.*@.*)/(?P\w+)/$', + # Message + url(r'^list/(?P[^/@]+@[^/@]+)/message/(?P\w+)/$', 'message.index', name='message_index'), - - url(r'^message/(?P.*@.*)/(?P\w+)/attachment/(?P\d+)/(?P.+)$', + url(r'^list/(?P[^/@]+@[^/@]+)/message/(?P\w+)/attachment/(?P\d+)/(?P.+)$', 'message.attachment', name='message_attachment'), - - url(r'^vote/(?P.*@.*)/$', + url(r'^list/(?P[^/@]+@[^/@]+)/message/(?P\w+)/vote$', 'message.vote', name='message_vote'), - ### MESSAGE LEVEL VIEW ENDS ### - - - ### THREAD LEVEL VIEWS ### - # Thread view page - url(r'^thread/(?P.*@.*)/(?P.+)/$', + # Thread + url(r'^list/(?P[^/@]+@[^/@]+)/thread/(?P\w+)/$', 'thread.thread_index', name='thread'), - # Add Tag to a thread - url(r'^thread/(?P.*@.*)\/(?P.*)/addtag$', + url(r'^list/(?P[^/@]+@[^/@]+)/thread/(?P\w+)/addtag$', 'thread.add_tag', name='add_tag'), - # Thread favorites - url(r'^thread/(?P.*@.*)\/(?P.*)/favorite$', + url(r'^list/(?P[^/@]+@[^/@]+)/thread/(?P\w+)/favorite$', 'thread.favorite', name='favorite'), - ### THREAD LEVEL VIEW ENDS ### + # Search Tag + url(r'^list/(?P[^/@]+@[^/@]+)/tag/(?P.*)/(?P\d+)/$', + 'list.search_tag'), + url(r'^list/(?P[^/@]+@[^/@]+)/tag/(?P.*)/$', + 'list.search_tag', name='search_tag'), + + # Search + url(r'^list/(?P[^/@]+@[^/@]+)/search/(?P.*)/(?P.*)/(?P\d+)/$', + 'list.search_keyword'), + url(r'^list/(?P[^/@]+@[^/@]+)/search/(?P.*)/(?P.*)/$', + 'list.search_keyword', name="search_keyword"), + url(r'^list/(?P[^/@]+@[^/@]+)/search/$', + 'list.search', name="search_list"), # REST API url(r'^api/$', 'api.api'), - url(r'^api/email\/(?P.*@.*)\/(?P.*)/', + url(r'^api/email\/(?P[^/@]+@[^/@]+)\/(?P.*)/', EmailResource.as_view(), name="api_email"), - url(r'^api/thread\/(?P.*@.*)\/(?P.*)/', + url(r'^api/thread\/(?P[^/@]+@[^/@]+)\/(?P.*)/', ThreadResource.as_view(), name="api_thread"), - url(r'^api/search\/(?P.*@.*)\/(?P.*)\/(?P.*)/', + url(r'^api/search\/(?P[^/@]+@[^/@]+)\/(?P.*)\/(?P.*)/', SearchResource.as_view(), name="api_search"), # Uncomment the admin/doc line below to enable admin documentation: diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index dc846cc..9e7a90a 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -177,7 +177,9 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): }) return HttpResponse(t.render(c)) -def list(request, mlist_fqdn=None): + + +def overview(request, mlist_fqdn=None): if not mlist_fqdn: return HttpResponseRedirect('/') t = loader.get_template('recent_activities.html') diff --git a/hyperkitty/views/message.py b/hyperkitty/views/message.py index b78d091..15aee66 100644 --- a/hyperkitty/views/message.py +++ b/hyperkitty/views/message.py @@ -121,14 +121,13 @@ def attachment(request, mlist_fqdn, hashid, counter, filename): return response -def vote(request, mlist_fqdn): +def vote(request, mlist_fqdn, hashid): """ Add a rating to a given message identified by messageid. """ if not request.user.is_authenticated(): return HttpResponse('You must be logged in to vote', content_type="text/plain", status=403) value = int(request.POST['vote']) - hashid = request.POST['hashid'] # Checks if the user has already voted for a this message. try: -- cgit