Commit d28b5b08b1376da87d718efc48ee1f99d722e89e

Authored by Gust
1 parent ef76e090

Fix suggestions and warnings

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
colab/accounts/views.py
... ... @@ -20,7 +20,7 @@ from conversejs.models import XMPPAccount
20 20  
21 21 from colab.super_archives.models import (EmailAddress, Message,
22 22 EmailAddressValidation)
23   -from colab.search.utils import trans, getCollaborationData
  23 +from colab.search.utils import trans, get_collaboration_data
24 24  
25 25 from .forms import (UserCreationForm, UserForm, ListsForm,
26 26 UserUpdateForm, ChangeXMPPPasswordForm)
... ... @@ -72,11 +72,10 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView):
72 72 messages = Message.objects.filter(from_address__user__pk=user.pk)
73 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 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 80 count_types.update(count_types_extras)
82 81  
... ...
colab/home/views.py
... ... @@ -2,29 +2,26 @@ from django.conf import settings
2 2 from django.shortcuts import render
3 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 6 from colab.super_archives.models import Thread
7 7  
8 8  
9 9 def dashboard(request):
10 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 15 hottest_threads = []
16 16 for thread in highest_score_threads:
17 17 hottest_threads.append(thread.latest_message)
18 18  
19   - latest_results, count_types = getCollaborationData()
  19 + latest_results, count_types = get_collaboration_data()
20 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 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 26 for key in count_types.keys():
30 27 count_types[trans(key)] = count_types.pop(key)
... ...
colab/proxy/gitlab/data_api.py
... ... @@ -57,7 +57,7 @@ class GitlabDataAPI(ProxyDataAPI):
57 57  
58 58 return projects
59 59  
60   - def fetchData(self):
  60 + def fetch_data(self):
61 61 data = self.fetchProjects()
62 62  
63 63 for datum in data:
... ...
colab/proxy/gitlab/models.py
1 1 from django.db import models
2   -from django.conf import settings
3   -from colab.accounts.models import User
4 2  
5 3  
6 4 class GitlabProject(models.Model):
... ...
colab/proxy/jenkins/data_api.py
... ... @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI
3 3  
4 4 class JenkinsDataAPI(ProxyDataAPI):
5 5  
6   - def fetchData(self):
  6 + def fetch_data(self):
7 7 pass
... ...
colab/proxy/management/commands/import_proxy_data.py
1 1 #!/usr/bin/env python
2 2  
3 3 import importlib
  4 +import inspect
4 5  
5 6 from django.core.management.base import BaseCommand
6 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 12 class Command(BaseCommand):
... ... @@ -20,7 +21,10 @@ class Command(BaseCommand):
20 21  
21 22 for module_item_name in dir(module):
22 23 module_item = getattr(module, module_item_name)
  24 + if not inspect.isclass(module_item):
  25 + continue
23 26 if issubclass(module_item, ProxyDataAPI):
24 27 if module_item != ProxyDataAPI:
25 28 api = module_item()
26   - api.fetchData()
  29 + api.fetch_data()
  30 + break
... ...
colab/proxy/noosfero/data_api.py
... ... @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI
3 3  
4 4 class NoosferoDataAPI(ProxyDataAPI):
5 5  
6   - def fetchData(self):
  6 + def fetch_data(self):
7 7 pass
... ...
colab/proxy/proxybase/__init__.py
colab/proxy/proxybase/management/commands/__init__.py
... ... @@ -1 +0,0 @@
1   -__init__.py
2 0 \ No newline at end of file
colab/proxy/proxybase/management/commands/import_proxy_data.py
... ... @@ -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
... ... @@ -1,6 +0,0 @@
1   -
2   -class ProxyDataAPI():
3   -
4   -
5   - def fetchData(self):
6   - raise NotImplementedError('fetchData not yet implemented')
7 0 \ No newline at end of file
colab/proxy/redmine/data_api.py
... ... @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI
3 3  
4 4 class RedmineDataAPI(ProxyDataAPI):
5 5  
6   - def fetchData(self):
  6 + def fetch_data(self):
7 7 pass
... ...
colab/proxy/trac/data_api.py
... ... @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI
3 3  
4 4 class TracDataAPI(ProxyDataAPI):
5 5  
6   - def fetchData(self):
  6 + def fetch_data(self):
7 7 pass
... ...
colab/proxy/trac/models.py
... ... @@ -131,21 +131,3 @@ class Wiki(models.Model, HitCounterModelMixin):
131 131 return User.objects.get(username=self.modified_by)
132 132 except User.DoesNotExist:
133 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
... ... @@ -2,5 +2,5 @@
2 2  
3 3 class ProxyDataAPI(object):
4 4  
5   - def fetchData(self):
  5 + def fetch_data(self):
6 6 raise NotImplementedError('fetchData not yet implemented')
... ...
colab/search/utils.py
... ... @@ -33,7 +33,7 @@ def trans(key):
33 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 38 latest_results = []
39 39 count_types = cache.get('home_chart')
... ...