Commit cc39a5d3bc818233f24fda541ec5765d4e2c0beb
Committed by
Sergio Oliveira
1 parent
5008375b
Exists in
master
and in
39 other branches
Applying flake8
Signed-off-by: Lucas Moura <lucas.moura128@gmail.com> Signed-off-by: Thiago Ribeiro <thiagitosouza@hotmail.com>
Showing
42 changed files
with
209 additions
and
146 deletions
Show diff stats
colab/badger/admin.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | 2 | ||
3 | from django.contrib import admin | 3 | from django.contrib import admin |
4 | -from django.utils.translation import ugettext_lazy as _ | ||
5 | 4 | ||
6 | from .forms import BadgeForm | 5 | from .forms import BadgeForm |
7 | from .models import Badge, BadgeI18N | 6 | from .models import Badge, BadgeI18N |
colab/badger/forms.py
colab/badger/management/commands/rebuild_badges.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | 2 | ||
3 | -from django.core.management.base import BaseCommand, CommandError | 3 | +from django.core.management.base import BaseCommand |
4 | from haystack.query import SearchQuerySet | 4 | from haystack.query import SearchQuerySet |
5 | 5 | ||
6 | from colab.accounts.models import User | 6 | from colab.accounts.models import User |
@@ -23,7 +23,7 @@ class Command(BaseCommand): | @@ -23,7 +23,7 @@ class Command(BaseCommand): | ||
23 | continue | 23 | continue |
24 | 24 | ||
25 | comparison = u'__{}'.format(badge.comparison) if badge.comparison \ | 25 | comparison = u'__{}'.format(badge.comparison) if badge.comparison \ |
26 | - is not 'equal' else u'' | 26 | + is not 'equal' else u'' |
27 | 27 | ||
28 | key = u'{}{}'.format( | 28 | key = u'{}{}'.format( |
29 | Badge.USER_ATTR_OPTS[badge.user_attr], | 29 | Badge.USER_ATTR_OPTS[badge.user_attr], |
colab/badger/management/commands/update_badges.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | 2 | ||
3 | -from django.core.management.base import BaseCommand, CommandError | 3 | +from django.core.management.base import BaseCommand |
4 | from haystack.query import SearchQuerySet | 4 | from haystack.query import SearchQuerySet |
5 | 5 | ||
6 | from colab.accounts.models import User | 6 | from colab.accounts.models import User |
@@ -8,6 +8,7 @@ from colab.badger.models import Badge | @@ -8,6 +8,7 @@ from colab.badger.models import Badge | ||
8 | 8 | ||
9 | import logging | 9 | import logging |
10 | 10 | ||
11 | + | ||
11 | class Command(BaseCommand): | 12 | class Command(BaseCommand): |
12 | help = "Update the user's badges" | 13 | help = "Update the user's badges" |
13 | 14 | ||
@@ -23,7 +24,7 @@ class Command(BaseCommand): | @@ -23,7 +24,7 @@ class Command(BaseCommand): | ||
23 | continue | 24 | continue |
24 | 25 | ||
25 | comparison = u'__{}'.format(badge.comparison) if badge.comparison \ | 26 | comparison = u'__{}'.format(badge.comparison) if badge.comparison \ |
26 | - is not 'equal' else u'' | 27 | + is not 'equal' else u'' |
27 | 28 | ||
28 | key = u'{}{}'.format( | 29 | key = u'{}{}'.format( |
29 | Badge.USER_ATTR_OPTS[badge.user_attr], | 30 | Badge.USER_ATTR_OPTS[badge.user_attr], |
colab/badger/models.py
@@ -39,7 +39,7 @@ class Badge(models.Model): | @@ -39,7 +39,7 @@ class Badge(models.Model): | ||
39 | image_base64 = models.TextField(_(u'Image')) | 39 | image_base64 = models.TextField(_(u'Image')) |
40 | type = models.CharField(_(u'Type'), max_length=200, choices=TYPE_CHOICES) | 40 | type = models.CharField(_(u'Type'), max_length=200, choices=TYPE_CHOICES) |
41 | user_attr = models.CharField( | 41 | user_attr = models.CharField( |
42 | - _(u'User attribute'),max_length=100, | 42 | + _(u'User attribute'), max_length=100, |
43 | choices=USER_ATTR_CHOICES, | 43 | choices=USER_ATTR_CHOICES, |
44 | blank=True, | 44 | blank=True, |
45 | null=True, | 45 | null=True, |
colab/badger/tests.py
colab/badger/utils.py
@@ -2,27 +2,27 @@ | @@ -2,27 +2,27 @@ | ||
2 | 2 | ||
3 | from django.db.models import Count | 3 | from django.db.models import Count |
4 | 4 | ||
5 | -#from proxy.trac.models import (Revision, Ticket, Wiki, | ||
6 | -# WikiCollabCount, TicketCollabCount) | 5 | +#from proxy.trac.models import (Ticket, Wiki) |
6 | +#from proxy.trac.models import (Revision, WikiCollabCount, TicketCollabCount) | ||
7 | from colab.accounts.models import User | 7 | from colab.accounts.models import User |
8 | 8 | ||
9 | 9 | ||
10 | -def get_wiki_counters(): | ||
11 | - return {author: count for author, count in | ||
12 | - WikiCollabCount.objects.values_list()} | 10 | +#def get_wiki_counters(): |
11 | +# return {author: count for author, count in | ||
12 | +# WikiCollabCount.objects.values_list()} | ||
13 | 13 | ||
14 | 14 | ||
15 | -def get_revision_counters(): | ||
16 | - return { | ||
17 | - author: count for author, count in Revision.objects.values_list( | ||
18 | - 'author' | ||
19 | - ).annotate(count=Count('author')) | ||
20 | - } | 15 | +#def get_revision_counters(): |
16 | +# return { | ||
17 | +# author: count for author, count in Revision.objects.values_list( | ||
18 | +# 'author' | ||
19 | +# ).annotate(count=Count('author')) | ||
20 | +# } | ||
21 | 21 | ||
22 | 22 | ||
23 | -def get_ticket_counters(): | ||
24 | - return {author: count for author, count in | ||
25 | - TicketCollabCount.objects.values_list()} | 23 | +#def get_ticket_counters(): |
24 | +# return {author: count for author, count in | ||
25 | +# TicketCollabCount.objects.values_list()} | ||
26 | 26 | ||
27 | 27 | ||
28 | def get_users_counters(): | 28 | def get_users_counters(): |
colab/badger/views.py
colab/home/admin.py
colab/home/context_processors.py
@@ -26,5 +26,6 @@ def ribbon(request): | @@ -26,5 +26,6 @@ def ribbon(request): | ||
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | + | ||
29 | def browserid_enabled(request): | 30 | def browserid_enabled(request): |
30 | return {'BROWSERID_ENABLED': getattr(settings, 'BROWSERID_ENABLED', False)} | 31 | return {'BROWSERID_ENABLED': getattr(settings, 'BROWSERID_ENABLED', False)} |
colab/home/models.py
colab/home/tests.py
colab/home/views.py
@@ -15,8 +15,6 @@ from colab.super_archives.models import Thread | @@ -15,8 +15,6 @@ from colab.super_archives.models import Thread | ||
15 | 15 | ||
16 | def dashboard(request): | 16 | def dashboard(request): |
17 | """Dashboard page""" | 17 | """Dashboard page""" |
18 | - | ||
19 | - | ||
20 | latest_threads = Thread.objects.all()[:6] | 18 | latest_threads = Thread.objects.all()[:6] |
21 | hottest_threads = Thread.highest_score.from_haystack()[:6] | 19 | hottest_threads = Thread.highest_score.from_haystack()[:6] |
22 | 20 | ||
@@ -40,7 +38,7 @@ def dashboard(request): | @@ -40,7 +38,7 @@ def dashboard(request): | ||
40 | # count_types['wiki'] = sum([ | 38 | # count_types['wiki'] = sum([ |
41 | # wiki.count for wiki in WikiCollabCount.objects.all() | 39 | # wiki.count for wiki in WikiCollabCount.objects.all() |
42 | # ]) | 40 | # ]) |
43 | - | 41 | + |
44 | cache.set('home_chart', count_types) | 42 | cache.set('home_chart', count_types) |
45 | 43 | ||
46 | for key in count_types.keys(): | 44 | for key in count_types.keys(): |
colab/planet/admin.py
colab/planet/management/commands/update_planet.py
colab/planet/models.py
colab/planet/tests.py
colab/planet/views.py
colab/search/admin.py
colab/search/forms.py
@@ -8,8 +8,7 @@ from django.utils.translation import ugettext_lazy as _ | @@ -8,8 +8,7 @@ from django.utils.translation import ugettext_lazy as _ | ||
8 | from haystack.forms import SearchForm | 8 | from haystack.forms import SearchForm |
9 | from haystack.inputs import AltParser | 9 | from haystack.inputs import AltParser |
10 | 10 | ||
11 | -from colab.accounts.models import User | ||
12 | -from colab.super_archives.models import Message, MailingList | 11 | +from colab.super_archives.models import MailingList |
13 | 12 | ||
14 | 13 | ||
15 | class ColabSearchForm(SearchForm): | 14 | class ColabSearchForm(SearchForm): |
@@ -90,8 +89,8 @@ class ColabSearchForm(SearchForm): | @@ -90,8 +89,8 @@ class ColabSearchForm(SearchForm): | ||
90 | sqs = sqs.filter_or(**filter_sizes_exp) | 89 | sqs = sqs.filter_or(**filter_sizes_exp) |
91 | 90 | ||
92 | if self.cleaned_data['used_by']: | 91 | if self.cleaned_data['used_by']: |
93 | - sqs = sqs.filter_or(used_by__in=self.cleaned_data['used_by'].split()) | ||
94 | - | 92 | + sqs = sqs.filter_or(used_by__in=self.cleaned_data['used_by'] |
93 | + .split()) | ||
95 | 94 | ||
96 | if self.cleaned_data['q']: | 95 | if self.cleaned_data['q']: |
97 | q = unicodedata.normalize( | 96 | q = unicodedata.normalize( |
@@ -103,7 +102,8 @@ class ColabSearchForm(SearchForm): | @@ -103,7 +102,8 @@ class ColabSearchForm(SearchForm): | ||
103 | 'pf': 'title^2.1 author^1.9 description^1.7', | 102 | 'pf': 'title^2.1 author^1.9 description^1.7', |
104 | 'mm': '2<70%', | 103 | 'mm': '2<70%', |
105 | 104 | ||
106 | - # Date boosting: http://wiki.apache.org/solr/FunctionQuery#Date_Boosting | 105 | + # Date boosting: |
106 | + # http://wiki.apache.org/solr/FunctionQuery#Date_Boosting | ||
107 | 'bf': 'recip(ms(NOW/HOUR,modified),3.16e-11,1,1)^10', | 107 | 'bf': 'recip(ms(NOW/HOUR,modified),3.16e-11,1,1)^10', |
108 | } | 108 | } |
109 | 109 | ||
@@ -124,8 +124,9 @@ class ColabSearchForm(SearchForm): | @@ -124,8 +124,9 @@ class ColabSearchForm(SearchForm): | ||
124 | ) | 124 | ) |
125 | 125 | ||
126 | if self.cleaned_data['modified_by']: | 126 | if self.cleaned_data['modified_by']: |
127 | + modified_by_data = self.cleaned_date['modified_by'] | ||
127 | sqs = sqs.filter( | 128 | sqs = sqs.filter( |
128 | - fullname_and_username__contains=self.cleaned_data['modified_by'] | 129 | + fullname_and_username__contains=modified_by_data |
129 | ) | 130 | ) |
130 | 131 | ||
131 | if self.cleaned_data['milestone']: | 132 | if self.cleaned_data['milestone']: |
colab/search/models.py
colab/search/tests.py
colab/search/views.py
@@ -145,17 +145,19 @@ class ColabSearchView(SearchView): | @@ -145,17 +145,19 @@ class ColabSearchView(SearchView): | ||
145 | size_choices = () | 145 | size_choices = () |
146 | used_by_choices = () | 146 | used_by_choices = () |
147 | 147 | ||
148 | - if type_chosen == 'attachment': | ||
149 | - mimetype_choices = [(type_, display) for type_, display, mimelist_ in settings.FILE_TYPE_GROUPINGS] | ||
150 | - size_choices = [ | ||
151 | - ('<500KB', u'< 500 KB'), | ||
152 | - ('500KB__10MB', u'>= 500 KB <= 10 MB'), | ||
153 | - ('>10MB', u'> 10 MB'), | ||
154 | - ] | ||
155 | - used_by_choices = set([ | ||
156 | - (v, v) for v in Attachment.objects.values_list( | ||
157 | - 'used_by', flat=True) | ||
158 | - ]) | 148 | + #if type_chosen == 'attachment': |
149 | + # mimetype_choices = [ | ||
150 | + # (type_, display) | ||
151 | + # for type_, display, mimelist_ in settings.FILE_TYPE_GROUPINGS] | ||
152 | + # size_choices = [ | ||
153 | + # ('<500KB', u'< 500 KB'), | ||
154 | + # ('500KB__10MB', u'>= 500 KB <= 10 MB'), | ||
155 | + # ('>10MB', u'> 10 MB'), | ||
156 | + # ] | ||
157 | + # used_by_choices = set([ | ||
158 | + # (v, v) for v in Attachment.objects.values_list('used_by', | ||
159 | + # flat=True) | ||
160 | + # ]) | ||
159 | 161 | ||
160 | mimetype_chosen = self.request.GET.get('mimetype') | 162 | mimetype_chosen = self.request.GET.get('mimetype') |
161 | size_chosen = self.request.GET.get('size') | 163 | size_chosen = self.request.GET.get('size') |
colab/settings.py
@@ -90,7 +90,8 @@ MEDIA_ROOT = '/usr/share/nginx/colab/media/' | @@ -90,7 +90,8 @@ MEDIA_ROOT = '/usr/share/nginx/colab/media/' | ||
90 | STATIC_URL = '/static/' | 90 | STATIC_URL = '/static/' |
91 | MEDIA_URL = '/media/' | 91 | MEDIA_URL = '/media/' |
92 | 92 | ||
93 | -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' | 93 | +STATICFILES_STORAGE = \ |
94 | + 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' | ||
94 | 95 | ||
95 | 96 | ||
96 | # Normally you should not import ANYTHING from Django directly | 97 | # Normally you should not import ANYTHING from Django directly |
colab/super_archives/admin.py
@@ -11,13 +11,14 @@ class EmailAddressAdmin(admin.ModelAdmin): | @@ -11,13 +11,14 @@ class EmailAddressAdmin(admin.ModelAdmin): | ||
11 | 'user__last_name', | 11 | 'user__last_name', |
12 | ) | 12 | ) |
13 | 13 | ||
14 | + | ||
14 | class MessageAdmin(admin.ModelAdmin): | 15 | class MessageAdmin(admin.ModelAdmin): |
15 | list_filter = ('spam', 'thread__mailinglist', 'received_time', ) | 16 | list_filter = ('spam', 'thread__mailinglist', 'received_time', ) |
16 | search_fields = ( | 17 | search_fields = ( |
17 | 'id', | 18 | 'id', |
18 | 'subject', | 19 | 'subject', |
19 | 'subject_clean', | 20 | 'subject_clean', |
20 | - 'body', | 21 | + 'body', |
21 | 'from_address__real_name', | 22 | 'from_address__real_name', |
22 | 'from_address__address', | 23 | 'from_address__address', |
23 | 'from_address__user__first_name', | 24 | 'from_address__user__first_name', |
@@ -40,14 +41,14 @@ class ThreadAdmin(admin.ModelAdmin): | @@ -40,14 +41,14 @@ class ThreadAdmin(admin.ModelAdmin): | ||
40 | 'message__from_address__user__last_name', | 41 | 'message__from_address__user__last_name', |
41 | 'message__from_address__user__username', | 42 | 'message__from_address__user__username', |
42 | ) | 43 | ) |
43 | - | 44 | + |
44 | readonly_fields = ( | 45 | readonly_fields = ( |
45 | 'mailinglist', | 46 | 'mailinglist', |
46 | 'subject_token', | 47 | 'subject_token', |
47 | 'latest_message', | 48 | 'latest_message', |
48 | 'score', | 49 | 'score', |
49 | ) | 50 | ) |
50 | - | 51 | + |
51 | fields = ( | 52 | fields = ( |
52 | 'mailinglist', | 53 | 'mailinglist', |
53 | 'subject_token', | 54 | 'subject_token', |
@@ -55,10 +56,9 @@ class ThreadAdmin(admin.ModelAdmin): | @@ -55,10 +56,9 @@ class ThreadAdmin(admin.ModelAdmin): | ||
55 | 'score', | 56 | 'score', |
56 | 'spam', | 57 | 'spam', |
57 | ) | 58 | ) |
58 | - | 59 | + |
59 | 60 | ||
60 | admin.site.register(MailingList) | 61 | admin.site.register(MailingList) |
61 | admin.site.register(Thread, ThreadAdmin) | 62 | admin.site.register(Thread, ThreadAdmin) |
62 | admin.site.register(Message, MessageAdmin) | 63 | admin.site.register(Message, MessageAdmin) |
63 | admin.site.register(EmailAddress, EmailAddressAdmin) | 64 | admin.site.register(EmailAddress, EmailAddressAdmin) |
64 | - |
colab/super_archives/apps.py
colab/super_archives/context_processors.py
1 | 1 | ||
2 | from .models import Message | 2 | from .models import Message |
3 | 3 | ||
4 | + | ||
4 | def mailarchive(request): | 5 | def mailarchive(request): |
5 | context = {} | 6 | context = {} |
6 | 7 | ||
7 | try: | 8 | try: |
8 | - context['last_imported_message'] = Message.objects.latest('received_time') | 9 | + context['last_imported_message'] = \ |
10 | + Message.objects.latest('received_time') | ||
9 | except Message.DoesNotExist: | 11 | except Message.DoesNotExist: |
10 | pass | 12 | pass |
11 | 13 |
colab/super_archives/management/commands/message.py
@@ -71,15 +71,15 @@ class Message(mailbox.mboxMessage): | @@ -71,15 +71,15 @@ class Message(mailbox.mboxMessage): | ||
71 | 71 | ||
72 | return u"\n".join(body).strip() | 72 | return u"\n".join(body).strip() |
73 | 73 | ||
74 | - else: # if it is not multipart, the payload will be a string | ||
75 | - # representing the message body | 74 | + else: # if it is not multipart, the payload will be a string |
75 | + # representing the message body | ||
76 | body = unicode(self.get_payload(decode=True), | 76 | body = unicode(self.get_payload(decode=True), |
77 | get_charset(self), | 77 | get_charset(self), |
78 | "replace") | 78 | "replace") |
79 | return body.strip() | 79 | return body.strip() |
80 | 80 | ||
81 | def get_received_datetime(self): | 81 | def get_received_datetime(self): |
82 | - if not self.has_key('Received'): | 82 | + if not self in ('Received'): |
83 | return None | 83 | return None |
84 | # The time received should always be the last element | 84 | # The time received should always be the last element |
85 | # in the `Received` attribute from the message headers | 85 | # in the `Received` attribute from the message headers |
colab/super_archives/management/commands/update_keywords.py
colab/super_archives/managers.py
colab/super_archives/migrations/0001_initial.py
@@ -20,11 +20,15 @@ class Migration(migrations.Migration): | @@ -20,11 +20,15 @@ class Migration(migrations.Migration): | ||
20 | migrations.CreateModel( | 20 | migrations.CreateModel( |
21 | name='EmailAddress', | 21 | name='EmailAddress', |
22 | fields=[ | 22 | fields=[ |
23 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 23 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
24 | + auto_created=True, primary_key=True)), | ||
24 | ('address', models.EmailField(unique=True, max_length=75)), | 25 | ('address', models.EmailField(unique=True, max_length=75)), |
25 | - ('real_name', models.CharField(db_index=True, max_length=64, blank=True)), | 26 | + ('real_name', models.CharField(db_index=True, max_length=64, |
27 | + blank=True)), | ||
26 | ('md5', models.CharField(max_length=32, null=True)), | 28 | ('md5', models.CharField(max_length=32, null=True)), |
27 | - ('user', models.ForeignKey(related_name=b'emails', on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True)), | 29 | + ('user', models.ForeignKey(related_name=b'emails', |
30 | + on_delete=django.db.models.deletion.SET_NULL, | ||
31 | + to=settings.AUTH_USER_MODEL, null=True)), | ||
28 | ], | 32 | ], |
29 | options={ | 33 | options={ |
30 | 'ordering': ('id',), | 34 | 'ordering': ('id',), |
@@ -34,11 +38,17 @@ class Migration(migrations.Migration): | @@ -34,11 +38,17 @@ class Migration(migrations.Migration): | ||
34 | migrations.CreateModel( | 38 | migrations.CreateModel( |
35 | name='EmailAddressValidation', | 39 | name='EmailAddressValidation', |
36 | fields=[ | 40 | fields=[ |
37 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 41 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
42 | + auto_created=True, primary_key=True)), | ||
38 | ('address', models.EmailField(unique=True, max_length=75)), | 43 | ('address', models.EmailField(unique=True, max_length=75)), |
39 | - ('validation_key', models.CharField(default=colab.super_archives.models.get_validation_key, max_length=32, null=True)), | 44 | + ('validation_key', |
45 | + models.CharField( | ||
46 | + default=colab.super_archives.models.get_validation_key, | ||
47 | + max_length=32, null=True)), | ||
40 | ('created', models.DateTimeField(auto_now_add=True)), | 48 | ('created', models.DateTimeField(auto_now_add=True)), |
41 | - ('user', models.ForeignKey(related_name=b'emails_not_validated', to=settings.AUTH_USER_MODEL, null=True)), | 49 | + ('user', |
50 | + models.ForeignKey(related_name=b'emails_not_validated', | ||
51 | + to=settings.AUTH_USER_MODEL, null=True)), | ||
42 | ], | 52 | ], |
43 | options={ | 53 | options={ |
44 | }, | 54 | }, |
@@ -47,7 +57,8 @@ class Migration(migrations.Migration): | @@ -47,7 +57,8 @@ class Migration(migrations.Migration): | ||
47 | migrations.CreateModel( | 57 | migrations.CreateModel( |
48 | name='Keyword', | 58 | name='Keyword', |
49 | fields=[ | 59 | fields=[ |
50 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 60 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
61 | + auto_created=True, primary_key=True)), | ||
51 | ('keyword', models.CharField(max_length=b'128')), | 62 | ('keyword', models.CharField(max_length=b'128')), |
52 | ('weight', models.IntegerField(default=0)), | 63 | ('weight', models.IntegerField(default=0)), |
53 | ], | 64 | ], |
@@ -59,7 +70,8 @@ class Migration(migrations.Migration): | @@ -59,7 +70,8 @@ class Migration(migrations.Migration): | ||
59 | migrations.CreateModel( | 70 | migrations.CreateModel( |
60 | name='MailingList', | 71 | name='MailingList', |
61 | fields=[ | 72 | fields=[ |
62 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 73 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
74 | + auto_created=True, primary_key=True)), | ||
63 | ('name', models.CharField(max_length=80)), | 75 | ('name', models.CharField(max_length=80)), |
64 | ('email', models.EmailField(max_length=75)), | 76 | ('email', models.EmailField(max_length=75)), |
65 | ('description', models.TextField()), | 77 | ('description', models.TextField()), |
@@ -73,8 +85,10 @@ class Migration(migrations.Migration): | @@ -73,8 +85,10 @@ class Migration(migrations.Migration): | ||
73 | migrations.CreateModel( | 85 | migrations.CreateModel( |
74 | name='MailingListMembership', | 86 | name='MailingListMembership', |
75 | fields=[ | 87 | fields=[ |
76 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
77 | - ('mailinglist', models.ForeignKey(to='super_archives.MailingList')), | 88 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
89 | + auto_created=True, primary_key=True)), | ||
90 | + ('mailinglist', | ||
91 | + models.ForeignKey(to='super_archives.MailingList')), | ||
78 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), | 92 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), |
79 | ], | 93 | ], |
80 | options={ | 94 | options={ |
@@ -84,14 +98,23 @@ class Migration(migrations.Migration): | @@ -84,14 +98,23 @@ class Migration(migrations.Migration): | ||
84 | migrations.CreateModel( | 98 | migrations.CreateModel( |
85 | name='Message', | 99 | name='Message', |
86 | fields=[ | 100 | fields=[ |
87 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
88 | - ('subject', models.CharField(help_text='Please enter a message subject', max_length=512, verbose_name='Subject', db_index=True)), | ||
89 | - ('subject_clean', models.CharField(max_length=512, db_index=True)), | ||
90 | - ('body', models.TextField(default=b'', help_text='Please enter a message body', verbose_name='Message body')), | 101 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
102 | + auto_created=True, primary_key=True)), | ||
103 | + ('subject', | ||
104 | + models.CharField(help_text='Please enter a message subject', | ||
105 | + max_length=512, verbose_name='Subject', | ||
106 | + db_index=True)), | ||
107 | + ('subject_clean', models.CharField(max_length=512, | ||
108 | + db_index=True)), | ||
109 | + ('body', | ||
110 | + models.TextField(default=b'', | ||
111 | + help_text='Please enter a message body', | ||
112 | + verbose_name='Message body')), | ||
91 | ('received_time', models.DateTimeField(db_index=True)), | 113 | ('received_time', models.DateTimeField(db_index=True)), |
92 | ('message_id', models.CharField(max_length=512)), | 114 | ('message_id', models.CharField(max_length=512)), |
93 | ('spam', models.BooleanField(default=False)), | 115 | ('spam', models.BooleanField(default=False)), |
94 | - ('from_address', models.ForeignKey(to='super_archives.EmailAddress')), | 116 | + ('from_address', |
117 | + models.ForeignKey(to='super_archives.EmailAddress')), | ||
95 | ], | 118 | ], |
96 | options={ | 119 | options={ |
97 | 'ordering': ('received_time',), | 120 | 'ordering': ('received_time',), |
@@ -103,11 +126,13 @@ class Migration(migrations.Migration): | @@ -103,11 +126,13 @@ class Migration(migrations.Migration): | ||
103 | migrations.CreateModel( | 126 | migrations.CreateModel( |
104 | name='MessageBlock', | 127 | name='MessageBlock', |
105 | fields=[ | 128 | fields=[ |
106 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 129 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
130 | + auto_created=True, primary_key=True)), | ||
107 | ('text', models.TextField()), | 131 | ('text', models.TextField()), |
108 | ('is_reply', models.BooleanField(default=False)), | 132 | ('is_reply', models.BooleanField(default=False)), |
109 | ('order', models.IntegerField()), | 133 | ('order', models.IntegerField()), |
110 | - ('message', models.ForeignKey(related_name=b'blocks', to='super_archives.Message')), | 134 | + ('message', models.ForeignKey(related_name=b'blocks', |
135 | + to='super_archives.Message')), | ||
111 | ], | 136 | ], |
112 | options={ | 137 | options={ |
113 | 'ordering': ('order',), | 138 | 'ordering': ('order',), |
@@ -117,7 +142,8 @@ class Migration(migrations.Migration): | @@ -117,7 +142,8 @@ class Migration(migrations.Migration): | ||
117 | migrations.CreateModel( | 142 | migrations.CreateModel( |
118 | name='MessageMetadata', | 143 | name='MessageMetadata', |
119 | fields=[ | 144 | fields=[ |
120 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 145 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
146 | + auto_created=True, primary_key=True)), | ||
121 | ('name', models.CharField(max_length=512)), | 147 | ('name', models.CharField(max_length=512)), |
122 | ('value', models.TextField()), | 148 | ('value', models.TextField()), |
123 | ('Message', models.ForeignKey(to='super_archives.Message')), | 149 | ('Message', models.ForeignKey(to='super_archives.Message')), |
@@ -129,13 +155,29 @@ class Migration(migrations.Migration): | @@ -129,13 +155,29 @@ class Migration(migrations.Migration): | ||
129 | migrations.CreateModel( | 155 | migrations.CreateModel( |
130 | name='Thread', | 156 | name='Thread', |
131 | fields=[ | 157 | fields=[ |
132 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 158 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
159 | + auto_created=True, primary_key=True)), | ||
133 | ('subject_token', models.CharField(max_length=512)), | 160 | ('subject_token', models.CharField(max_length=512)), |
134 | - ('score', models.IntegerField(default=0, help_text='Thread score', verbose_name='Score')), | 161 | + ('score', models.IntegerField(default=0, |
162 | + help_text='Thread score', | ||
163 | + verbose_name='Score')), | ||
135 | ('spam', models.BooleanField(default=False)), | 164 | ('spam', models.BooleanField(default=False)), |
136 | - ('latest_message', models.OneToOneField(related_name=b'+', null=True, to='super_archives.Message', help_text='Latest message posted', verbose_name='Latest message')), | ||
137 | - ('mailinglist', models.ForeignKey(verbose_name='Mailing List', to='super_archives.MailingList', help_text='The Mailing List where is the thread')), | ||
138 | - ('tags', taggit.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', verbose_name='Tags')), | 165 | + ('latest_message', |
166 | + models.OneToOneField(related_name=b'+', | ||
167 | + null=True, to='super_archives.Message', | ||
168 | + help_text='Latest message posted', | ||
169 | + verbose_name='Latest message')), | ||
170 | + ('mailinglist', | ||
171 | + models.ForeignKey( | ||
172 | + verbose_name='Mailing List', | ||
173 | + to='super_archives.MailingList', | ||
174 | + help_text='The Mailing List where is the thread')), | ||
175 | + ('tags', | ||
176 | + taggit.managers.TaggableManager( | ||
177 | + to='taggit.Tag', | ||
178 | + through='taggit.TaggedItem', | ||
179 | + help_text='A comma-separated list of tags.', | ||
180 | + verbose_name='Tags')), | ||
139 | ], | 181 | ], |
140 | options={ | 182 | options={ |
141 | 'ordering': ('-latest_message__received_time',), | 183 | 'ordering': ('-latest_message__received_time',), |
@@ -147,7 +189,8 @@ class Migration(migrations.Migration): | @@ -147,7 +189,8 @@ class Migration(migrations.Migration): | ||
147 | migrations.CreateModel( | 189 | migrations.CreateModel( |
148 | name='Vote', | 190 | name='Vote', |
149 | fields=[ | 191 | fields=[ |
150 | - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 192 | + ('id', models.AutoField(verbose_name='ID', serialize=False, |
193 | + auto_created=True, primary_key=True)), | ||
151 | ('created', models.DateTimeField(auto_now_add=True)), | 194 | ('created', models.DateTimeField(auto_now_add=True)), |
152 | ('message', models.ForeignKey(to='super_archives.Message')), | 195 | ('message', models.ForeignKey(to='super_archives.Message')), |
153 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), | 196 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), |
colab/super_archives/models.py
@@ -38,12 +38,14 @@ class EmailAddressValidation(models.Model): | @@ -38,12 +38,14 @@ class EmailAddressValidation(models.Model): | ||
38 | 38 | ||
39 | @classmethod | 39 | @classmethod |
40 | def create(cls, address, user): | 40 | def create(cls, address, user): |
41 | - email_address_validation = cls.objects.create(address=address, user=user) | ||
42 | - email.send_verification_email(email_address_validation.address, | ||
43 | - email_address_validation.user, | ||
44 | - email_address_validation.validation_key) | 41 | + email_address_validation = cls.objects.create(address=address, |
42 | + user=user) | ||
43 | + email.send_verification_email(email_address_validation.address, | ||
44 | + email_address_validation.user, | ||
45 | + email_address_validation.validation_key) | ||
45 | return email_address_validation | 46 | return email_address_validation |
46 | 47 | ||
48 | + | ||
47 | class EmailAddress(models.Model): | 49 | class EmailAddress(models.Model): |
48 | user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, | 50 | user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, |
49 | related_name='emails', on_delete=models.SET_NULL) | 51 | related_name='emails', on_delete=models.SET_NULL) |
@@ -114,14 +116,17 @@ class Keyword(models.Model): | @@ -114,14 +116,17 @@ class Keyword(models.Model): | ||
114 | class Thread(models.Model, HitCounterModelMixin): | 116 | class Thread(models.Model, HitCounterModelMixin): |
115 | 117 | ||
116 | subject_token = models.CharField(max_length=512) | 118 | subject_token = models.CharField(max_length=512) |
117 | - mailinglist = models.ForeignKey(MailingList, | ||
118 | - verbose_name=_(u"Mailing List"), | ||
119 | - help_text=_(u"The Mailing List where is the thread")) | ||
120 | - latest_message = models.OneToOneField('Message', null=True, | ||
121 | - related_name='+', | ||
122 | - verbose_name=_(u"Latest message"), | ||
123 | - help_text=_(u"Latest message posted")) | ||
124 | - score = models.IntegerField(default=0, verbose_name=_(u"Score"), help_text=_(u"Thread score")) | 119 | + mailinglist = \ |
120 | + models.ForeignKey( | ||
121 | + MailingList, | ||
122 | + verbose_name=_(u"Mailing List"), | ||
123 | + help_text=_(u"The Mailing List where is the thread")) | ||
124 | + latest_message = \ | ||
125 | + models.OneToOneField('Message', null=True, related_name='+', | ||
126 | + verbose_name=_(u"Latest message"), | ||
127 | + help_text=_(u"Latest message posted")) | ||
128 | + score = models.IntegerField(default=0, verbose_name=_(u"Score"), | ||
129 | + help_text=_(u"Thread score")) | ||
125 | spam = models.BooleanField(default=False) | 130 | spam = models.BooleanField(default=False) |
126 | 131 | ||
127 | highest_score = HighestScore() | 132 | highest_score = HighestScore() |
@@ -204,8 +209,8 @@ class Thread(models.Model, HitCounterModelMixin): | @@ -204,8 +209,8 @@ class Thread(models.Model, HitCounterModelMixin): | ||
204 | # function N times in the loops below | 209 | # function N times in the loops below |
205 | now = timezone.now() | 210 | now = timezone.now() |
206 | days_ago = lambda date: (now - date).days | 211 | days_ago = lambda date: (now - date).days |
207 | - get_score = lambda weight, created: \ | ||
208 | - max(weight - (days_ago(created) // 3), 5) | 212 | + get_score = lambda weight, created: max(weight - (days_ago(created) |
213 | + // 3), 5) | ||
209 | 214 | ||
210 | vote_score = 0 | 215 | vote_score = 0 |
211 | replies_score = 0 | 216 | replies_score = 0 |
@@ -384,7 +389,6 @@ class MessageBlock(models.Model): | @@ -384,7 +389,6 @@ class MessageBlock(models.Model): | ||
384 | return obj | 389 | return obj |
385 | 390 | ||
386 | 391 | ||
387 | - | ||
388 | class MessageMetadata(models.Model): | 392 | class MessageMetadata(models.Model): |
389 | Message = models.ForeignKey(Message) | 393 | Message = models.ForeignKey(Message) |
390 | # Same problem here than on subjects. Read comment above | 394 | # Same problem here than on subjects. Read comment above |
colab/super_archives/search_indexes.py
@@ -36,8 +36,8 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | @@ -36,8 +36,8 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | ||
36 | def get_updated_field(self): | 36 | def get_updated_field(self): |
37 | return 'latest_message__received_time' | 37 | return 'latest_message__received_time' |
38 | 38 | ||
39 | - def prepare_fullname(self, obj): | ||
40 | - return obj.message_set.first().from_address.get_full_name() | 39 | + #def prepare_fullname(self, obj): |
40 | + # return obj.message_set.first().from_address.get_full_name() | ||
41 | 41 | ||
42 | def prepare_fullname_and_username(self, obj): | 42 | def prepare_fullname_and_username(self, obj): |
43 | from_address = obj.message_set.first().from_address | 43 | from_address = obj.message_set.first().from_address |
colab/super_archives/signals.py
@@ -13,7 +13,7 @@ def create_email_address(sender, instance, created, **kwargs): | @@ -13,7 +13,7 @@ def create_email_address(sender, instance, created, **kwargs): | ||
13 | 13 | ||
14 | email, email_created = EmailAddress.objects.get_or_create( | 14 | email, email_created = EmailAddress.objects.get_or_create( |
15 | address=instance.email, | 15 | address=instance.email, |
16 | - defaults= { | 16 | + defaults={ |
17 | 'real_name': instance.get_full_name(), | 17 | 'real_name': instance.get_full_name(), |
18 | 'user': instance, | 18 | 'user': instance, |
19 | } | 19 | } |
colab/super_archives/templatetags/superarchives.py
1 | 1 | ||
2 | from django import template | 2 | from django import template |
3 | -from django.conf import settings | ||
4 | - | ||
5 | from colab.super_archives.utils import url | 3 | from colab.super_archives.utils import url |
6 | 4 | ||
7 | 5 | ||
@@ -14,7 +12,7 @@ def display_message(email): | @@ -14,7 +12,7 @@ def display_message(email): | ||
14 | if not email.blocks.count(): | 12 | if not email.blocks.count(): |
15 | email.update_blocks() | 13 | email.update_blocks() |
16 | 14 | ||
17 | - return { 'blocks': email.blocks.all } | 15 | + return {'blocks': email.blocks.all} |
18 | 16 | ||
19 | 17 | ||
20 | @register.simple_tag(takes_context=True) | 18 | @register.simple_tag(takes_context=True) |
colab/super_archives/urls.py
1 | -from django.conf.urls import patterns, include, url | 1 | +from django.conf.urls import patterns, url |
2 | 2 | ||
3 | -from .views import EmailView, EmailValidationView, ThreadView, \ | ||
4 | - ThreadDashboardView | 3 | +from .views import EmailView, EmailValidationView, ThreadView |
4 | +from .views import ThreadDashboardView | ||
5 | 5 | ||
6 | 6 | ||
7 | -urlpatterns = patterns('super_archives.views', | 7 | +urlpatterns = patterns( |
8 | + 'super_archives.views', | ||
8 | url(r'thread/(?P<mailinglist>[-\w]+)/(?P<thread_token>[-\w]+)$', | 9 | url(r'thread/(?P<mailinglist>[-\w]+)/(?P<thread_token>[-\w]+)$', |
9 | ThreadView.as_view(), name="thread_view"), | 10 | ThreadView.as_view(), name="thread_view"), |
10 | url(r'thread/$', ThreadDashboardView.as_view(), name='thread_list'), | 11 | url(r'thread/$', ThreadDashboardView.as_view(), name='thread_list'), |
11 | url(r'manage/email/validate/?$', EmailValidationView.as_view(), | 12 | url(r'manage/email/validate/?$', EmailValidationView.as_view(), |
12 | - name="archive_email_validation_view"), | 13 | + name="archive_email_validation_view"), |
13 | url(r'manage/email/(?P<key>[0-9a-z]{32})?', EmailView.as_view(), | 14 | url(r'manage/email/(?P<key>[0-9a-z]{32})?', EmailView.as_view(), |
14 | - name="archive_email_view"), | 15 | + name="archive_email_view"), |
15 | ) | 16 | ) |
colab/super_archives/utils/blocks.py
@@ -8,7 +8,7 @@ from html2text import html2text | @@ -8,7 +8,7 @@ from html2text import html2text | ||
8 | 8 | ||
9 | EXTENDED_PUNCTUATION = '!"#$%&\'()*+,-./:;=?@[\\]^_`{|}~ \t\n\r\x0b\x0c' | 9 | EXTENDED_PUNCTUATION = '!"#$%&\'()*+,-./:;=?@[\\]^_`{|}~ \t\n\r\x0b\x0c' |
10 | RE_WRAPPED_BY_HTML = re.compile(r'^<[a-z]+[^>]*>.*</[a-z]+[^>]*>$', | 10 | RE_WRAPPED_BY_HTML = re.compile(r'^<[a-z]+[^>]*>.*</[a-z]+[^>]*>$', |
11 | - re.MULTILINE|re.IGNORECASE|re.DOTALL) | 11 | + re.MULTILINE | re.IGNORECASE | re.DOTALL) |
12 | RE_LINKS = re.compile(r'(?P<link>https?://[^ \t\r\n\<]+)') | 12 | RE_LINKS = re.compile(r'(?P<link>https?://[^ \t\r\n\<]+)') |
13 | LINK_MARKUP = u'<a target="_blank" href="\g<link>">\g<link></a>' | 13 | LINK_MARKUP = u'<a target="_blank" href="\g<link>">\g<link></a>' |
14 | 14 | ||
@@ -26,8 +26,8 @@ class EmailBlock(list): | @@ -26,8 +26,8 @@ class EmailBlock(list): | ||
26 | def _html2text(self, text): | 26 | def _html2text(self, text): |
27 | if RE_WRAPPED_BY_HTML.match(text.strip()): | 27 | if RE_WRAPPED_BY_HTML.match(text.strip()): |
28 | return html2text(text) | 28 | return html2text(text) |
29 | - | ||
30 | - text, n = RE_BR_TO_LINEBREAK.subn('\n', text) | 29 | + |
30 | + text, n = RE_BR_TO_LINEBREAK.subn('\n', text) | ||
31 | text = strip_tags(text) | 31 | text = strip_tags(text) |
32 | return text | 32 | return text |
33 | 33 | ||
@@ -90,10 +90,11 @@ class EmailBlockParser(list): | @@ -90,10 +90,11 @@ class EmailBlockParser(list): | ||
90 | return True | 90 | return True |
91 | 91 | ||
92 | clean_line = RE_REPLY_LINE.subn('', stripped_line)[0] | 92 | clean_line = RE_REPLY_LINE.subn('', stripped_line)[0] |
93 | - queryset = self.thread_emails.filter( | ||
94 | - received_time__lt=self.email.received_time, | ||
95 | - body__contains=clean_line).order_by('-received_time') | ||
96 | - | 93 | + queryset = \ |
94 | + self.thread_emails.filter( | ||
95 | + received_time__lt=self.email.received_time, | ||
96 | + body__contains=clean_line).order_by('-received_time') | ||
97 | + | ||
97 | if queryset[:1]: | 98 | if queryset[:1]: |
98 | return True | 99 | return True |
99 | 100 |
colab/super_archives/utils/email.py
@@ -12,7 +12,8 @@ def colab_send_email(subject, message, to): | @@ -12,7 +12,8 @@ def colab_send_email(subject, message, to): | ||
12 | 12 | ||
13 | def send_verification_email(to, user, validation_key): | 13 | def send_verification_email(to, user, validation_key): |
14 | subject = _('Please verify your email ') + u'{}'.format(to) | 14 | subject = _('Please verify your email ') + u'{}'.format(to) |
15 | - msg_tmpl = loader.get_template('superarchives/emails/email_verification.txt') | 15 | + msg_tmpl = \ |
16 | + loader.get_template('superarchives/emails/email_verification.txt') | ||
16 | message = msg_tmpl.render(Context({'to': to, 'user': user, | 17 | message = msg_tmpl.render(Context({'to': to, 'user': user, |
17 | 'key': validation_key, | 18 | 'key': validation_key, |
18 | 'SITE_URL': settings.SITE_URL})) | 19 | 'SITE_URL': settings.SITE_URL})) |
colab/super_archives/utils/url.py
@@ -14,7 +14,7 @@ def append_to_get(path, query=None, **kwargs): | @@ -14,7 +14,7 @@ def append_to_get(path, query=None, **kwargs): | ||
14 | def pop_from_get(path, query=None, **kwargs): | 14 | def pop_from_get(path, query=None, **kwargs): |
15 | query_dict = dict(urlparse.parse_qsl(query)) | 15 | query_dict = dict(urlparse.parse_qsl(query)) |
16 | for key, value in kwargs.items(): | 16 | for key, value in kwargs.items(): |
17 | - if not query_dict.has_key(key): | 17 | + if not query_dict in (key): |
18 | continue | 18 | continue |
19 | if query_dict[key] == value: | 19 | if query_dict[key] == value: |
20 | del query_dict[key] | 20 | del query_dict[key] |
colab/super_archives/views.py
@@ -11,7 +11,6 @@ from django.conf import settings | @@ -11,7 +11,6 @@ from django.conf import settings | ||
11 | from django.contrib import messages | 11 | from django.contrib import messages |
12 | from django.db import IntegrityError | 12 | from django.db import IntegrityError |
13 | from django.views.generic import View | 13 | from django.views.generic import View |
14 | -from django.core.paginator import Paginator, EmptyPage | ||
15 | from django.utils.translation import ugettext as _ | 14 | from django.utils.translation import ugettext as _ |
16 | from django.core.exceptions import ObjectDoesNotExist | 15 | from django.core.exceptions import ObjectDoesNotExist |
17 | from django.utils.decorators import method_decorator | 16 | from django.utils.decorators import method_decorator |
@@ -23,8 +22,8 @@ from haystack.query import SearchQuerySet | @@ -23,8 +22,8 @@ from haystack.query import SearchQuerySet | ||
23 | from colab.accounts.utils import mailman | 22 | from colab.accounts.utils import mailman |
24 | from colab.accounts.models import User | 23 | from colab.accounts.models import User |
25 | from .utils.email import send_verification_email | 24 | from .utils.email import send_verification_email |
26 | -from .models import MailingList, Thread, EmailAddress, \ | ||
27 | - EmailAddressValidation, Message | 25 | +from .models import MailingList, Thread, EmailAddress |
26 | +from .models import EmailAddressValidation, Message | ||
28 | 27 | ||
29 | 28 | ||
30 | class ThreadView(View): | 29 | class ThreadView(View): |
@@ -83,7 +82,8 @@ class ThreadView(View): | @@ -83,7 +82,8 @@ class ThreadView(View): | ||
83 | 'body': request.POST.get('emailbody', '').strip(), | 82 | 'body': request.POST.get('emailbody', '').strip(), |
84 | } | 83 | } |
85 | 84 | ||
86 | - url = urlparse.urljoin(settings.MAILMAN_API_URL, mailinglist + '/sendmail') | 85 | + url = urlparse.urljoin(settings.MAILMAN_API_URL, |
86 | + mailinglist + '/sendmail') | ||
87 | 87 | ||
88 | error_msg = None | 88 | error_msg = None |
89 | try: | 89 | try: |
@@ -110,7 +110,8 @@ class ThreadView(View): | @@ -110,7 +110,8 @@ class ThreadView(View): | ||
110 | elif resp.status_code == 404: | 110 | elif resp.status_code == 404: |
111 | error_msg = _('Mailing list does not exist') | 111 | error_msg = _('Mailing list does not exist') |
112 | else: | 112 | else: |
113 | - error_msg = _('Unknown error trying to connect to Mailman API') | 113 | + error_msg = _('Unknown error\ |
114 | + trying to connect to Mailman API') | ||
114 | messages.error(request, error_msg) | 115 | messages.error(request, error_msg) |
115 | 116 | ||
116 | return self.get(request, mailinglist, thread_token) | 117 | return self.get(request, mailinglist, thread_token) |
@@ -125,7 +126,7 @@ class ThreadDashboardView(View): | @@ -125,7 +126,7 @@ class ThreadDashboardView(View): | ||
125 | all_lists = mailman.all_lists(description=True) | 126 | all_lists = mailman.all_lists(description=True) |
126 | 127 | ||
127 | context['lists'] = [] | 128 | context['lists'] = [] |
128 | - lists = MailingList.objects.filter() | 129 | + #lists = MailingList.objects.filter() |
129 | for list_ in MailingList.objects.order_by('name'): | 130 | for list_ in MailingList.objects.order_by('name'): |
130 | context['lists'].append(( | 131 | context['lists'].append(( |
131 | list_.name, | 132 | list_.name, |
@@ -134,7 +135,7 @@ class ThreadDashboardView(View): | @@ -134,7 +135,7 @@ class ThreadDashboardView(View): | ||
134 | '-latest_message__received_time' | 135 | '-latest_message__received_time' |
135 | )[:MAX], | 136 | )[:MAX], |
136 | SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], | 137 | SearchQuerySet().filter(type='thread', tag=list_.name)[:MAX], |
137 | - len(mailman.list_users(list_.name)), | 138 | + len(mailman.list_users(list_.name)), |
138 | )) | 139 | )) |
139 | 140 | ||
140 | return render(request, 'superarchives/thread-dashboard.html', context) | 141 | return render(request, 'superarchives/thread-dashboard.html', context) |
@@ -151,7 +152,7 @@ class EmailView(View): | @@ -151,7 +152,7 @@ class EmailView(View): | ||
151 | email_val = EmailAddressValidation.objects.get(validation_key=key) | 152 | email_val = EmailAddressValidation.objects.get(validation_key=key) |
152 | except EmailAddressValidation.DoesNotExist: | 153 | except EmailAddressValidation.DoesNotExist: |
153 | messages.error(request, _('The email address you are trying to ' | 154 | messages.error(request, _('The email address you are trying to ' |
154 | - 'verify either has already been verified ' | 155 | + 'verify either has already been verified' |
155 | 'or does not exist.')) | 156 | 'or does not exist.')) |
156 | return redirect('/') | 157 | return redirect('/') |
157 | 158 | ||
@@ -170,7 +171,6 @@ class EmailView(View): | @@ -170,7 +171,6 @@ class EmailView(View): | ||
170 | email.user = email_val.user | 171 | email.user = email_val.user |
171 | email.save() | 172 | email.save() |
172 | email_val.delete() | 173 | email_val.delete() |
173 | - | ||
174 | user = User.objects.get(username=email.user.username) | 174 | user = User.objects.get(username=email.user.username) |
175 | user.is_active = True | 175 | user.is_active = True |
176 | user.save() | 176 | user.save() |
@@ -178,7 +178,6 @@ class EmailView(View): | @@ -178,7 +178,6 @@ class EmailView(View): | ||
178 | messages.success(request, _('Email address verified!')) | 178 | messages.success(request, _('Email address verified!')) |
179 | return redirect('user_profile', username=email_val.user.username) | 179 | return redirect('user_profile', username=email_val.user.username) |
180 | 180 | ||
181 | - | ||
182 | @method_decorator(login_required) | 181 | @method_decorator(login_required) |
183 | def post(self, request, key): | 182 | def post(self, request, key): |
184 | """Create new email address that will wait for validation""" | 183 | """Create new email address that will wait for validation""" |
colab/urls.py
@@ -4,14 +4,11 @@ from django.views.generic import TemplateView | @@ -4,14 +4,11 @@ from django.views.generic import TemplateView | ||
4 | from django.contrib import admin | 4 | from django.contrib import admin |
5 | from django.views.generic import RedirectView | 5 | from django.views.generic import RedirectView |
6 | 6 | ||
7 | -from colab.accounts.models import User | ||
8 | -from .search.forms import ColabSearchForm | ||
9 | -from .super_archives.models import Message | ||
10 | - | ||
11 | 7 | ||
12 | admin.autodiscover() | 8 | admin.autodiscover() |
13 | 9 | ||
14 | -urlpatterns = patterns('', | 10 | +urlpatterns = patterns( |
11 | + '', | ||
15 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), | 12 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), |
16 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), | 13 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), |
17 | url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), | 14 | url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), |
@@ -24,8 +21,12 @@ urlpatterns = patterns('', | @@ -24,8 +21,12 @@ urlpatterns = patterns('', | ||
24 | url(r'^api/', include('colab.api.urls')), | 21 | url(r'^api/', include('colab.api.urls')), |
25 | url(r'^rss/', include('colab.rss.urls')), | 22 | url(r'^rss/', include('colab.rss.urls')), |
26 | 23 | ||
27 | - url(r'^user/', include('colab.accounts.urls')), # Kept for backwards compatibility | ||
28 | - url(r'^signup/', include('colab.accounts.urls')), # (same here) TODO: move to nginx | 24 | + # Kept for backwards compatibility |
25 | + url(r'^user/', include('colab.accounts.urls')), | ||
26 | + # Kept for backwards compatibility | ||
27 | + url(r'^user/', include('colab.accounts.urls')), | ||
28 | + # (same here) TODO: move to nginx | ||
29 | + url(r'^signup/', include('colab.accounts.urls')), | ||
29 | url(r'^account/', include('colab.accounts.urls')), | 30 | url(r'^account/', include('colab.accounts.urls')), |
30 | 31 | ||
31 | url(r'', include('django_browserid.urls')), | 32 | url(r'', include('django_browserid.urls')), |