Commit d28b5b08b1376da87d718efc48ee1f99d722e89e
1 parent
ef76e090
Exists in
master
and in
39 other branches
Fix suggestions and warnings
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Showing
16 changed files
with
22 additions
and
75 deletions
Show diff stats
colab/accounts/views.py
@@ -20,7 +20,7 @@ from conversejs.models import XMPPAccount | @@ -20,7 +20,7 @@ from conversejs.models import XMPPAccount | ||
20 | 20 | ||
21 | from colab.super_archives.models import (EmailAddress, Message, | 21 | from colab.super_archives.models import (EmailAddress, Message, |
22 | EmailAddressValidation) | 22 | EmailAddressValidation) |
23 | -from colab.search.utils import trans, getCollaborationData | 23 | +from colab.search.utils import trans, get_collaboration_data |
24 | 24 | ||
25 | from .forms import (UserCreationForm, UserForm, ListsForm, | 25 | from .forms import (UserCreationForm, UserForm, ListsForm, |
26 | UserUpdateForm, ChangeXMPPPasswordForm) | 26 | UserUpdateForm, ChangeXMPPPasswordForm) |
@@ -72,11 +72,10 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | @@ -72,11 +72,10 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | ||
72 | messages = Message.objects.filter(from_address__user__pk=user.pk) | 72 | messages = Message.objects.filter(from_address__user__pk=user.pk) |
73 | count_types[trans('thread')] = messages.count() | 73 | count_types[trans('thread')] = messages.count() |
74 | 74 | ||
75 | - collaborations, count_types_extras = getCollaborationData(user) | 75 | + collaborations, count_types_extras = get_collaboration_data(user) |
76 | collaborations.extend(messages) | 76 | collaborations.extend(messages) |
77 | 77 | ||
78 | - collaborations = sorted(collaborations, | ||
79 | - key=lambda elem: elem.modified, reverse=True) | 78 | + collaborations.sort(key=lambda elem: elem.modified, reverse=True) |
80 | 79 | ||
81 | count_types.update(count_types_extras) | 80 | count_types.update(count_types_extras) |
82 | 81 |
colab/home/views.py
@@ -2,29 +2,26 @@ from django.conf import settings | @@ -2,29 +2,26 @@ from django.conf import settings | ||
2 | from django.shortcuts import render | 2 | from django.shortcuts import render |
3 | from django.http import HttpResponse, Http404 | 3 | from django.http import HttpResponse, Http404 |
4 | 4 | ||
5 | -from colab.search.utils import trans, getCollaborationData | 5 | +from colab.search.utils import trans, get_collaboration_data |
6 | from colab.super_archives.models import Thread | 6 | from colab.super_archives.models import Thread |
7 | 7 | ||
8 | 8 | ||
9 | def dashboard(request): | 9 | def dashboard(request): |
10 | """Dashboard page""" | 10 | """Dashboard page""" |
11 | 11 | ||
12 | - latest_threads = Thread.objects.all()[:6] | ||
13 | - highest_score_threads = Thread.highest_score.all()[:6] | 12 | + latest_threads = Thread.objects.all() |
13 | + highest_score_threads = Thread.highest_score.all() | ||
14 | 14 | ||
15 | hottest_threads = [] | 15 | hottest_threads = [] |
16 | for thread in highest_score_threads: | 16 | for thread in highest_score_threads: |
17 | hottest_threads.append(thread.latest_message) | 17 | hottest_threads.append(thread.latest_message) |
18 | 18 | ||
19 | - latest_results, count_types = getCollaborationData() | 19 | + latest_results, count_types = get_collaboration_data() |
20 | threads = Thread.objects.all() | 20 | threads = Thread.objects.all() |
21 | - messages = [] | ||
22 | - for t in threads: | ||
23 | - messages.append(t.latest_message) | 21 | + messages = [t.latest_message for t in threads] |
24 | 22 | ||
25 | latest_results.extend(messages) | 23 | latest_results.extend(messages) |
26 | - latest_results = sorted(latest_results, | ||
27 | - key=lambda elem: elem.modified, reverse=True) | 24 | + latest_results.sort(key=lambda elem: elem.modified, reverse=True) |
28 | 25 | ||
29 | for key in count_types.keys(): | 26 | for key in count_types.keys(): |
30 | count_types[trans(key)] = count_types.pop(key) | 27 | count_types[trans(key)] = count_types.pop(key) |
colab/proxy/gitlab/data_api.py
@@ -57,7 +57,7 @@ class GitlabDataAPI(ProxyDataAPI): | @@ -57,7 +57,7 @@ class GitlabDataAPI(ProxyDataAPI): | ||
57 | 57 | ||
58 | return projects | 58 | return projects |
59 | 59 | ||
60 | - def fetchData(self): | 60 | + def fetch_data(self): |
61 | data = self.fetchProjects() | 61 | data = self.fetchProjects() |
62 | 62 | ||
63 | for datum in data: | 63 | for datum in data: |
colab/proxy/gitlab/models.py
colab/proxy/jenkins/data_api.py
colab/proxy/management/commands/import_proxy_data.py
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | 2 | ||
3 | import importlib | 3 | import importlib |
4 | +import inspect | ||
4 | 5 | ||
5 | from django.core.management.base import BaseCommand | 6 | from django.core.management.base import BaseCommand |
6 | from django.conf import settings | 7 | from django.conf import settings |
7 | 8 | ||
8 | -from colab.proxy.proxybase.proxy_data_api import ProxyDataAPI | 9 | +from colab.proxy.utils.proxy_data_api import ProxyDataAPI |
9 | 10 | ||
10 | 11 | ||
11 | class Command(BaseCommand): | 12 | class Command(BaseCommand): |
@@ -20,7 +21,10 @@ class Command(BaseCommand): | @@ -20,7 +21,10 @@ class Command(BaseCommand): | ||
20 | 21 | ||
21 | for module_item_name in dir(module): | 22 | for module_item_name in dir(module): |
22 | module_item = getattr(module, module_item_name) | 23 | module_item = getattr(module, module_item_name) |
24 | + if not inspect.isclass(module_item): | ||
25 | + continue | ||
23 | if issubclass(module_item, ProxyDataAPI): | 26 | if issubclass(module_item, ProxyDataAPI): |
24 | if module_item != ProxyDataAPI: | 27 | if module_item != ProxyDataAPI: |
25 | api = module_item() | 28 | api = module_item() |
26 | - api.fetchData() | 29 | + api.fetch_data() |
30 | + break |
colab/proxy/noosfero/data_api.py
colab/proxy/proxybase/__init__.py
colab/proxy/proxybase/management/commands/__init__.py
colab/proxy/proxybase/management/commands/import_proxy_data.py
@@ -1,26 +0,0 @@ | @@ -1,26 +0,0 @@ | ||
1 | -#!/usr/bin/env python | ||
2 | - | ||
3 | -import importlib | ||
4 | - | ||
5 | -from django.core.management.base import BaseCommand | ||
6 | -from django.conf import settings | ||
7 | - | ||
8 | -from colab.proxy.proxybase.proxy_data_api import ProxyDataAPI | ||
9 | - | ||
10 | - | ||
11 | -class Command(BaseCommand): | ||
12 | - help = "Import proxy data into colab database" | ||
13 | - | ||
14 | - def handle(self, *args, **kwargs): | ||
15 | - print "Executing extraction command..." | ||
16 | - | ||
17 | - for module_name in settings.PROXIED_APPS.keys(): | ||
18 | - module_path = 'colab.proxy.{}.data_api'.format(module_name) | ||
19 | - module = importlib.import_module(module_path) | ||
20 | - | ||
21 | - for module_item_name in dir(module): | ||
22 | - module_item = getattr(module, module_item_name) | ||
23 | - if issubclass(module_item, ProxyDataAPI): | ||
24 | - if module_item != ProxyDataAPI: | ||
25 | - api = module_item() | ||
26 | - api.fetchData() |
colab/proxy/proxybase/proxy_data_api.py
colab/proxy/redmine/data_api.py
colab/proxy/trac/data_api.py
colab/proxy/trac/models.py
@@ -131,21 +131,3 @@ class Wiki(models.Model, HitCounterModelMixin): | @@ -131,21 +131,3 @@ class Wiki(models.Model, HitCounterModelMixin): | ||
131 | return User.objects.get(username=self.modified_by) | 131 | return User.objects.get(username=self.modified_by) |
132 | except User.DoesNotExist: | 132 | except User.DoesNotExist: |
133 | return None | 133 | return None |
134 | - | ||
135 | - | ||
136 | -class WikiCollabCount(models.Model): | ||
137 | - author = models.TextField(primary_key=True) | ||
138 | - count = models.IntegerField() | ||
139 | - | ||
140 | - class Meta: | ||
141 | - managed = False | ||
142 | - db_table = 'wiki_collab_count_view' | ||
143 | - | ||
144 | - | ||
145 | -class TicketCollabCount(models.Model): | ||
146 | - author = models.TextField(primary_key=True) | ||
147 | - count = models.IntegerField() | ||
148 | - | ||
149 | - class Meta: | ||
150 | - managed = False | ||
151 | - db_table = 'ticket_collab_count_view' |
colab/proxy/utils/proxy_data_api.py
colab/search/utils.py
@@ -33,7 +33,7 @@ def trans(key): | @@ -33,7 +33,7 @@ def trans(key): | ||
33 | return translations.get(key, key) | 33 | return translations.get(key, key) |
34 | 34 | ||
35 | 35 | ||
36 | -def getCollaborationData(filter_by_user=None): | 36 | +def get_collaboration_data(filter_by_user=None): |
37 | 37 | ||
38 | latest_results = [] | 38 | latest_results = [] |
39 | count_types = cache.get('home_chart') | 39 | count_types = cache.get('home_chart') |