Commit 4280f70504c7571b77d5fc66f722f4c37a6f2416
Committed by
Sergio Oliveira
1 parent
0e5123ab
Exists in
master
and in
39 other branches
Fix flake8 warnings
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Alexandre Barbosa <alexandreab@live.com>
Showing
5 changed files
with
10 additions
and
11 deletions
Show diff stats
colab/accounts/utils/mailman.py
| @@ -115,4 +115,4 @@ def get_user_mailinglists(user): | @@ -115,4 +115,4 @@ def get_user_mailinglists(user): | ||
| 115 | for email in emails: | 115 | for email in emails: |
| 116 | lists_for_user.extend(address_lists(email)) | 116 | lists_for_user.extend(address_lists(email)) |
| 117 | 117 | ||
| 118 | - return lists_for_user | ||
| 119 | \ No newline at end of file | 118 | \ No newline at end of file |
| 119 | + return lists_for_user |
colab/accounts/views.py
| @@ -15,7 +15,7 @@ from django.views.generic import DetailView, UpdateView, TemplateView | @@ -15,7 +15,7 @@ from django.views.generic import DetailView, UpdateView, TemplateView | ||
| 15 | from conversejs import xmpp | 15 | from conversejs import xmpp |
| 16 | from conversejs.models import XMPPAccount | 16 | from conversejs.models import XMPPAccount |
| 17 | 17 | ||
| 18 | -from colab.super_archives.models import (EmailAddress, Message, | 18 | +from colab.super_archives.models import (EmailAddress, |
| 19 | EmailAddressValidation) | 19 | EmailAddressValidation) |
| 20 | from colab.search.utils import get_collaboration_data, get_visible_threads | 20 | from colab.search.utils import get_collaboration_data, get_visible_threads |
| 21 | from colab.accounts.models import User | 21 | from colab.accounts.models import User |
| @@ -80,7 +80,6 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | @@ -80,7 +80,6 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | ||
| 80 | context['type_count'] = count_types | 80 | context['type_count'] = count_types |
| 81 | context['results'] = collaborations[:10] | 81 | context['results'] = collaborations[:10] |
| 82 | 82 | ||
| 83 | - email_pks = [addr.pk for addr in profile_user.emails.iterator()] | ||
| 84 | query = get_visible_threads(logged_user, profile_user) | 83 | query = get_visible_threads(logged_user, profile_user) |
| 85 | query = query.order_by('-received_time') | 84 | query = query.order_by('-received_time') |
| 86 | context['emails'] = query[:10] | 85 | context['emails'] = query[:10] |
colab/home/views.py
| @@ -7,6 +7,7 @@ from colab.super_archives.models import Thread | @@ -7,6 +7,7 @@ from colab.super_archives.models import Thread | ||
| 7 | from colab.accounts.utils import mailinglist | 7 | from colab.accounts.utils import mailinglist |
| 8 | from colab.accounts.models import User | 8 | from colab.accounts.models import User |
| 9 | 9 | ||
| 10 | + | ||
| 10 | def dashboard(request): | 11 | def dashboard(request): |
| 11 | """Dashboard page""" | 12 | """Dashboard page""" |
| 12 | 13 | ||
| @@ -23,19 +24,18 @@ def dashboard(request): | @@ -23,19 +24,18 @@ def dashboard(request): | ||
| 23 | 24 | ||
| 24 | for t in all_threads: | 25 | for t in all_threads: |
| 25 | if not t.mailinglist.is_private or \ | 26 | if not t.mailinglist.is_private or \ |
| 26 | - t.mailinglist.name in lists_for_user: | ||
| 27 | - latest_threads.append(t) | 27 | + t.mailinglist.name in lists_for_user: |
| 28 | + latest_threads.append(t) | ||
| 28 | 29 | ||
| 29 | hottest_threads = [] | 30 | hottest_threads = [] |
| 30 | for t in highest_score_threads: | 31 | for t in highest_score_threads: |
| 31 | if not t.mailinglist.is_private or \ | 32 | if not t.mailinglist.is_private or \ |
| 32 | - t.mailinglist.name in lists_for_user: | 33 | + t.mailinglist.name in lists_for_user: |
| 33 | hottest_threads.append(t.latest_message) | 34 | hottest_threads.append(t.latest_message) |
| 34 | 35 | ||
| 35 | latest_results, count_types = get_collaboration_data(user) | 36 | latest_results, count_types = get_collaboration_data(user) |
| 36 | latest_results.sort(key=lambda elem: elem.modified, reverse=True) | 37 | latest_results.sort(key=lambda elem: elem.modified, reverse=True) |
| 37 | 38 | ||
| 38 | - | ||
| 39 | context = { | 39 | context = { |
| 40 | 'hottest_threads': hottest_threads[:6], | 40 | 'hottest_threads': hottest_threads[:6], |
| 41 | 'latest_threads': latest_threads[:6], | 41 | 'latest_threads': latest_threads[:6], |
colab/search/utils.py
| @@ -6,7 +6,6 @@ from collections import OrderedDict | @@ -6,7 +6,6 @@ from collections import OrderedDict | ||
| 6 | from django.core.cache import cache | 6 | from django.core.cache import cache |
| 7 | from django.utils.translation import ugettext as _ | 7 | from django.utils.translation import ugettext as _ |
| 8 | from django.conf import settings | 8 | from django.conf import settings |
| 9 | -from django.db.models.query import QuerySet | ||
| 10 | from django.db.models import Q | 9 | from django.db.models import Q |
| 11 | 10 | ||
| 12 | from colab.super_archives.models import Thread, Message | 11 | from colab.super_archives.models import Thread, Message |
| @@ -26,6 +25,7 @@ def get_visible_threads_queryset(logged_user): | @@ -26,6 +25,7 @@ def get_visible_threads_queryset(logged_user): | ||
| 26 | 25 | ||
| 27 | return qs | 26 | return qs |
| 28 | 27 | ||
| 28 | + | ||
| 29 | def get_visible_threads(logged_user, filter_by_user=None): | 29 | def get_visible_threads(logged_user, filter_by_user=None): |
| 30 | thread_qs = get_visible_threads_queryset(logged_user) | 30 | thread_qs = get_visible_threads_queryset(logged_user) |
| 31 | if filter_by_user: | 31 | if filter_by_user: |
| @@ -38,9 +38,10 @@ def get_visible_threads(logged_user, filter_by_user=None): | @@ -38,9 +38,10 @@ def get_visible_threads(logged_user, filter_by_user=None): | ||
| 38 | 38 | ||
| 39 | return messages | 39 | return messages |
| 40 | 40 | ||
| 41 | + | ||
| 41 | def get_collaboration_data(logged_user, filter_by_user=None): | 42 | def get_collaboration_data(logged_user, filter_by_user=None): |
| 42 | latest_results = [] | 43 | latest_results = [] |
| 43 | - count_types = None#cache.get('home_chart') | 44 | + count_types = cache.get('home_chart') |
| 44 | populate_count_types = False | 45 | populate_count_types = False |
| 45 | 46 | ||
| 46 | if count_types is None: | 47 | if count_types is None: |
colab/super_archives/views.py
| @@ -40,7 +40,7 @@ class ThreadView(View): | @@ -40,7 +40,7 @@ class ThreadView(View): | ||
| 40 | user = User.objects.get(username=request.user) | 40 | user = User.objects.get(username=request.user) |
| 41 | emails = user.emails.values_list('address', flat=True) | 41 | emails = user.emails.values_list('address', flat=True) |
| 42 | lists_for_user = mailman.get_user_mailinglists(user) | 42 | lists_for_user = mailman.get_user_mailinglists(user) |
| 43 | - if not thread.mailinglist.name in lists_for_user: | 43 | + if thread.mailinglist.name not in lists_for_user: |
| 44 | raise PermissionDenied | 44 | raise PermissionDenied |
| 45 | 45 | ||
| 46 | thread.hit(request) | 46 | thread.hit(request) |
| @@ -141,7 +141,6 @@ class ThreadDashboardView(View): | @@ -141,7 +141,6 @@ class ThreadDashboardView(View): | ||
| 141 | lists_for_user = [] | 141 | lists_for_user = [] |
| 142 | if request.user.is_authenticated(): | 142 | if request.user.is_authenticated(): |
| 143 | user = User.objects.get(username=request.user) | 143 | user = User.objects.get(username=request.user) |
| 144 | - emails = user.emails.values_list('address', flat=True) | ||
| 145 | lists_for_user = mailman.get_user_mailinglists(user) | 144 | lists_for_user = mailman.get_user_mailinglists(user) |
| 146 | 145 | ||
| 147 | for list_ in MailingList.objects.order_by('name'): | 146 | for list_ in MailingList.objects.order_by('name'): |