diff --git a/colab_spb/views.py b/colab_spb/views.py index 881407b..fe4021b 100644 --- a/colab_spb/views.py +++ b/colab_spb/views.py @@ -1,5 +1,41 @@ from django.shortcuts import render -from django.http import HttpResponse +from django.utils.translation import ugettext as _ +from colab.super_archives.models import MailingList, Thread +from colab.accounts.utils import mailman -def get_list(request,path=None,list_name=None): - return HttpResponse('Hello Word') +def get_list(request): + list_name = None + MAX = 0 + if request.GET.get('list_name'): + list_name = request.GET['list_name'] + if request.GET.get('MAX'): + MAX = request.GET['MAX'] + + context = {} + + all_privates = {} + private_mailinglist = MailingList.objects.filter(is_private=True) + for mailinglist in private_mailinglist: + all_privates[mailinglist.name] = True + + context['lists'] = [] + + lists_for_user = [] + if request.user.is_authenticated(): + user = User.objects.get(username=request.user) + lists_for_user = mailman.get_user_mailinglists(user) + + for list_ in MailingList.objects.filter(name=list_name): + if list_.name not in all_privates or list_.name in lists_for_user: + context['lists'].append(( + list_.name, + mailman.get_list_description(list_.name), + list_.thread_set.filter(spam=False).order_by( + '-latest_message__received_time' + )[:MAX], + [t.latest_message for t in Thread.highest_score.filter( + mailinglist__name=list_.name)[:MAX]], + len(mailman.list_users(list_.name)), + )) + + return render(request,"discussion.html",context) diff --git a/templates/discussion.html b/templates/discussion.html new file mode 100644 index 0000000..8fcff41 --- /dev/null +++ b/templates/discussion.html @@ -0,0 +1,49 @@ + + {% load i18n %} +

{% trans 'Groups'|title %}

+
+ + {% for listname, description, latest, most_relevant, number_of_users in lists %} + {% if latest or most_relevant %} +

{{ listname|title|lower }} {% if description %} ({{ description }}){% endif %}

+
+ {% blocktrans %}{{ number_of_users }} members{% endblocktrans %} + {% if proxy.trac %} + Wiki + {% endif %} +
+
+ +
+
+

{% trans 'latest'|title %}

+ + +
+ +
+

{% trans 'most relevant'|title %}

+ + +
+
+ + + {% endif %} + {% endfor %} diff --git a/urls.py b/urls.py index b707998..0e0db96 100644 --- a/urls.py +++ b/urls.py @@ -2,6 +2,6 @@ from django.conf.urls import patterns, url from . import views urlpatterns = patterns('', - url( r'^(?P.*)$', views.get_list, name='get_list'), + url( r'^get_list/$',views.get_list, name='get_list'), ) -- libgit2 0.21.2