diff --git a/colab/home/views.py b/colab/home/views.py index 9661748..6fe0ade 100644 --- a/colab/home/views.py +++ b/colab/home/views.py @@ -9,23 +9,22 @@ from colab.super_archives.models import Thread def dashboard(request): """Dashboard page""" - latest_threads = Thread.objects.all() - highest_score_threads = Thread.highest_score.all() + highest_score_threads = Thread.highest_score.all()[:6] - hottest_threads = [] - for thread in highest_score_threads: - hottest_threads.append(thread.latest_message) + hottest_threads = [t.latest_message for t in highest_score_threads] + latest_threads = Thread.objects.all()[:6] latest_results, count_types = get_collaboration_data() - threads = Thread.objects.all() - messages = [t.latest_message for t in threads] + # NOTE: This code will cease to exist when super_archives + # become a plugin + messages = [t.latest_message for t in latest_threads] latest_results.extend(messages) latest_results.sort(key=lambda elem: elem.modified, reverse=True) context = { 'hottest_threads': hottest_threads[:6], - 'latest_threads': latest_threads[:6], + 'latest_threads': latest_threads, 'type_count': count_types, 'latest_results': latest_results[:6], } diff --git a/colab/proxy/gitlab/models.py b/colab/proxy/gitlab/models.py index c0bd5e6..4daa563 100644 --- a/colab/proxy/gitlab/models.py +++ b/colab/proxy/gitlab/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.utils.translation import ugettext_lazy as _ class GitlabProject(models.Model): @@ -10,3 +11,7 @@ class GitlabProject(models.Model): name_with_namespace = models.TextField() created_at = models.DateTimeField(blank=True) last_activity_at = models.DateTimeField(blank=True) + + class Meta: + verbose_name = _('Gitlab Project') + verbose_name_plural = _('Gitlab Projects') diff --git a/colab/search/utils.py b/colab/search/utils.py index a0e6d93..2f7df8b 100644 --- a/colab/search/utils.py +++ b/colab/search/utils.py @@ -45,9 +45,15 @@ def get_collaboration_data(filter_by_user=None): elements = elements.all() latest_results.extend(elements) + elements_count = elements.count() + + if elements_count > 1: + verbose_name = module_item._meta.verbose_name_plural.title() + else: + verbose_name = module_item._meta.verbose_name_plural.title() if populate_count_types: - count_types[module_item().verbose_name] = elements.count() + count_types[verbose_name] = elements_count if populate_count_types: cache.set('home_chart', count_types, 30) diff --git a/colab/super_archives/views.py b/colab/super_archives/views.py index 3e67428..2659f39 100644 --- a/colab/super_archives/views.py +++ b/colab/super_archives/views.py @@ -17,13 +17,11 @@ from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect, get_object_or_404 -from haystack.query import SearchQuerySet - from colab.accounts.utils import mailman from colab.accounts.models import User from .utils.email import send_verification_email -from .models import MailingList, Thread, EmailAddress -from .models import EmailAddressValidation, Message +from .models import (MailingList, Thread, EmailAddress, + EmailAddressValidation, Message) class ThreadView(View): @@ -110,8 +108,9 @@ class ThreadView(View): elif resp.status_code == 404: error_msg = _('Mailing list does not exist') else: - error_msg = _('Unknown error\ - trying to connect to Mailman API') + error_msg = \ + _('Unknown error trying to connect to Mailman API') + messages.error(request, error_msg) return self.get(request, mailinglist, thread_token) @@ -126,7 +125,7 @@ class ThreadDashboardView(View): all_lists = mailman.all_lists(description=True) context['lists'] = [] - # lists = MailingList.objects.filter() + for list_ in MailingList.objects.order_by('name'): context['lists'].append(( list_.name, @@ -134,7 +133,8 @@ class ThreadDashboardView(View): list_.thread_set.filter(spam=False).order_by( '-latest_message__received_time' )[:MAX], - SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], + [t.latest_message for t in Thread.highest_score.filter( + mailinglist__name=list_.name)[:MAX]], len(mailman.list_users(list_.name)), )) @@ -171,6 +171,7 @@ class EmailView(View): email.user = email_val.user email.save() email_val.delete() + user = User.objects.get(username=email.user.username) user.is_active = True user.save() diff --git a/vagrant/provision.sh b/vagrant/provision.sh index 240a8c0..0b55f9b 100755 --- a/vagrant/provision.sh +++ b/vagrant/provision.sh @@ -31,3 +31,4 @@ if [ ! -s /etc/colab/settings.yaml ]; then fi colab-admin migrate +colab-admin loaddata /vagrant/tests/test_data.json -- libgit2 0.21.2