Commit 0a74c01869af2b03ecfbe8b6dd1754790e292a50
1 parent
35e2bdfb
Exists in
master
and in
39 other branches
Remove haystack from super_archives dashboard
-Apply flake8 to super_archives view -Refactor verbose name Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Siqueira Melo <rodrigosiqueiramelo@gmail.com>
Showing
5 changed files
with
29 additions
and
17 deletions
Show diff stats
colab/home/views.py
... | ... | @@ -9,23 +9,22 @@ from colab.super_archives.models import Thread |
9 | 9 | def dashboard(request): |
10 | 10 | """Dashboard page""" |
11 | 11 | |
12 | - latest_threads = Thread.objects.all() | |
13 | - highest_score_threads = Thread.highest_score.all() | |
12 | + highest_score_threads = Thread.highest_score.all()[:6] | |
14 | 13 | |
15 | - hottest_threads = [] | |
16 | - for thread in highest_score_threads: | |
17 | - hottest_threads.append(thread.latest_message) | |
14 | + hottest_threads = [t.latest_message for t in highest_score_threads] | |
18 | 15 | |
16 | + latest_threads = Thread.objects.all()[:6] | |
19 | 17 | latest_results, count_types = get_collaboration_data() |
20 | - threads = Thread.objects.all() | |
21 | - messages = [t.latest_message for t in threads] | |
22 | 18 | |
19 | + # NOTE: This code will cease to exist when super_archives | |
20 | + # become a plugin | |
21 | + messages = [t.latest_message for t in latest_threads] | |
23 | 22 | latest_results.extend(messages) |
24 | 23 | latest_results.sort(key=lambda elem: elem.modified, reverse=True) |
25 | 24 | |
26 | 25 | context = { |
27 | 26 | 'hottest_threads': hottest_threads[:6], |
28 | - 'latest_threads': latest_threads[:6], | |
27 | + 'latest_threads': latest_threads, | |
29 | 28 | 'type_count': count_types, |
30 | 29 | 'latest_results': latest_results[:6], |
31 | 30 | } | ... | ... |
colab/proxy/gitlab/models.py
1 | 1 | from django.db import models |
2 | +from django.utils.translation import ugettext_lazy as _ | |
2 | 3 | |
3 | 4 | |
4 | 5 | class GitlabProject(models.Model): |
... | ... | @@ -10,3 +11,7 @@ class GitlabProject(models.Model): |
10 | 11 | name_with_namespace = models.TextField() |
11 | 12 | created_at = models.DateTimeField(blank=True) |
12 | 13 | last_activity_at = models.DateTimeField(blank=True) |
14 | + | |
15 | + class Meta: | |
16 | + verbose_name = _('Gitlab Project') | |
17 | + verbose_name_plural = _('Gitlab Projects') | ... | ... |
colab/search/utils.py
... | ... | @@ -45,9 +45,15 @@ def get_collaboration_data(filter_by_user=None): |
45 | 45 | elements = elements.all() |
46 | 46 | |
47 | 47 | latest_results.extend(elements) |
48 | + elements_count = elements.count() | |
49 | + | |
50 | + if elements_count > 1: | |
51 | + verbose_name = module_item._meta.verbose_name_plural.title() | |
52 | + else: | |
53 | + verbose_name = module_item._meta.verbose_name_plural.title() | |
48 | 54 | |
49 | 55 | if populate_count_types: |
50 | - count_types[module_item().verbose_name] = elements.count() | |
56 | + count_types[verbose_name] = elements_count | |
51 | 57 | |
52 | 58 | if populate_count_types: |
53 | 59 | cache.set('home_chart', count_types, 30) | ... | ... |
colab/super_archives/views.py
... | ... | @@ -17,13 +17,11 @@ from django.utils.decorators import method_decorator |
17 | 17 | from django.contrib.auth.decorators import login_required |
18 | 18 | from django.shortcuts import render, redirect, get_object_or_404 |
19 | 19 | |
20 | -from haystack.query import SearchQuerySet | |
21 | - | |
22 | 20 | from colab.accounts.utils import mailman |
23 | 21 | from colab.accounts.models import User |
24 | 22 | from .utils.email import send_verification_email |
25 | -from .models import MailingList, Thread, EmailAddress | |
26 | -from .models import EmailAddressValidation, Message | |
23 | +from .models import (MailingList, Thread, EmailAddress, | |
24 | + EmailAddressValidation, Message) | |
27 | 25 | |
28 | 26 | |
29 | 27 | class ThreadView(View): |
... | ... | @@ -110,8 +108,9 @@ class ThreadView(View): |
110 | 108 | elif resp.status_code == 404: |
111 | 109 | error_msg = _('Mailing list does not exist') |
112 | 110 | else: |
113 | - error_msg = _('Unknown error\ | |
114 | - trying to connect to Mailman API') | |
111 | + error_msg = \ | |
112 | + _('Unknown error trying to connect to Mailman API') | |
113 | + | |
115 | 114 | messages.error(request, error_msg) |
116 | 115 | |
117 | 116 | return self.get(request, mailinglist, thread_token) |
... | ... | @@ -126,7 +125,7 @@ class ThreadDashboardView(View): |
126 | 125 | all_lists = mailman.all_lists(description=True) |
127 | 126 | |
128 | 127 | context['lists'] = [] |
129 | - # lists = MailingList.objects.filter() | |
128 | + | |
130 | 129 | for list_ in MailingList.objects.order_by('name'): |
131 | 130 | context['lists'].append(( |
132 | 131 | list_.name, |
... | ... | @@ -134,7 +133,8 @@ class ThreadDashboardView(View): |
134 | 133 | list_.thread_set.filter(spam=False).order_by( |
135 | 134 | '-latest_message__received_time' |
136 | 135 | )[:MAX], |
137 | - SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], | |
136 | + [t.latest_message for t in Thread.highest_score.filter( | |
137 | + mailinglist__name=list_.name)[:MAX]], | |
138 | 138 | len(mailman.list_users(list_.name)), |
139 | 139 | )) |
140 | 140 | |
... | ... | @@ -171,6 +171,7 @@ class EmailView(View): |
171 | 171 | email.user = email_val.user |
172 | 172 | email.save() |
173 | 173 | email_val.delete() |
174 | + | |
174 | 175 | user = User.objects.get(username=email.user.username) |
175 | 176 | user.is_active = True |
176 | 177 | user.save() | ... | ... |
vagrant/provision.sh