diff --git a/colab/accounts/views.py b/colab/accounts/views.py index 81b0ab4..282ab74 100644 --- a/colab/accounts/views.py +++ b/colab/accounts/views.py @@ -20,7 +20,7 @@ from conversejs.models import XMPPAccount from colab.super_archives.models import (EmailAddress, Message, EmailAddressValidation) -from colab.search.utils import trans, getCollaborationData +from colab.search.utils import trans, get_collaboration_data from .forms import (UserCreationForm, UserForm, ListsForm, UserUpdateForm, ChangeXMPPPasswordForm) @@ -72,11 +72,10 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): messages = Message.objects.filter(from_address__user__pk=user.pk) count_types[trans('thread')] = messages.count() - collaborations, count_types_extras = getCollaborationData(user) + collaborations, count_types_extras = get_collaboration_data(user) collaborations.extend(messages) - collaborations = sorted(collaborations, - key=lambda elem: elem.modified, reverse=True) + collaborations.sort(key=lambda elem: elem.modified, reverse=True) count_types.update(count_types_extras) diff --git a/colab/home/views.py b/colab/home/views.py index 2799230..fdf59b4 100644 --- a/colab/home/views.py +++ b/colab/home/views.py @@ -2,29 +2,26 @@ from django.conf import settings from django.shortcuts import render from django.http import HttpResponse, Http404 -from colab.search.utils import trans, getCollaborationData +from colab.search.utils import trans, get_collaboration_data from colab.super_archives.models import Thread def dashboard(request): """Dashboard page""" - latest_threads = Thread.objects.all()[:6] - highest_score_threads = Thread.highest_score.all()[:6] + latest_threads = Thread.objects.all() + highest_score_threads = Thread.highest_score.all() hottest_threads = [] for thread in highest_score_threads: hottest_threads.append(thread.latest_message) - latest_results, count_types = getCollaborationData() + latest_results, count_types = get_collaboration_data() threads = Thread.objects.all() - messages = [] - for t in threads: - messages.append(t.latest_message) + messages = [t.latest_message for t in threads] latest_results.extend(messages) - latest_results = sorted(latest_results, - key=lambda elem: elem.modified, reverse=True) + latest_results.sort(key=lambda elem: elem.modified, reverse=True) for key in count_types.keys(): count_types[trans(key)] = count_types.pop(key) diff --git a/colab/proxy/gitlab/data_api.py b/colab/proxy/gitlab/data_api.py index da9f749..bfc2a1d 100644 --- a/colab/proxy/gitlab/data_api.py +++ b/colab/proxy/gitlab/data_api.py @@ -57,7 +57,7 @@ class GitlabDataAPI(ProxyDataAPI): return projects - def fetchData(self): + def fetch_data(self): data = self.fetchProjects() for datum in data: diff --git a/colab/proxy/gitlab/models.py b/colab/proxy/gitlab/models.py index 3335a3f..c0bd5e6 100644 --- a/colab/proxy/gitlab/models.py +++ b/colab/proxy/gitlab/models.py @@ -1,6 +1,4 @@ from django.db import models -from django.conf import settings -from colab.accounts.models import User class GitlabProject(models.Model): diff --git a/colab/proxy/jenkins/data_api.py b/colab/proxy/jenkins/data_api.py index a4b0ee6..0ed6b40 100644 --- a/colab/proxy/jenkins/data_api.py +++ b/colab/proxy/jenkins/data_api.py @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI class JenkinsDataAPI(ProxyDataAPI): - def fetchData(self): + def fetch_data(self): pass diff --git a/colab/proxy/management/commands/import_proxy_data.py b/colab/proxy/management/commands/import_proxy_data.py index e59d160..960d9dd 100644 --- a/colab/proxy/management/commands/import_proxy_data.py +++ b/colab/proxy/management/commands/import_proxy_data.py @@ -1,11 +1,12 @@ #!/usr/bin/env python import importlib +import inspect from django.core.management.base import BaseCommand from django.conf import settings -from colab.proxy.proxybase.proxy_data_api import ProxyDataAPI +from colab.proxy.utils.proxy_data_api import ProxyDataAPI class Command(BaseCommand): @@ -20,7 +21,10 @@ class Command(BaseCommand): for module_item_name in dir(module): module_item = getattr(module, module_item_name) + if not inspect.isclass(module_item): + continue if issubclass(module_item, ProxyDataAPI): if module_item != ProxyDataAPI: api = module_item() - api.fetchData() + api.fetch_data() + break diff --git a/colab/proxy/noosfero/data_api.py b/colab/proxy/noosfero/data_api.py index 85f71a6..7ece44e 100644 --- a/colab/proxy/noosfero/data_api.py +++ b/colab/proxy/noosfero/data_api.py @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI class NoosferoDataAPI(ProxyDataAPI): - def fetchData(self): + def fetch_data(self): pass diff --git a/colab/proxy/proxybase/__init__.py b/colab/proxy/proxybase/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/colab/proxy/proxybase/__init__.py +++ /dev/null diff --git a/colab/proxy/proxybase/management/commands/__init__.py b/colab/proxy/proxybase/management/commands/__init__.py deleted file mode 100644 index 93f5256..0000000 --- a/colab/proxy/proxybase/management/commands/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__init__.py \ No newline at end of file diff --git a/colab/proxy/proxybase/management/commands/import_proxy_data.py b/colab/proxy/proxybase/management/commands/import_proxy_data.py deleted file mode 100644 index e59d160..0000000 --- a/colab/proxy/proxybase/management/commands/import_proxy_data.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -import importlib - -from django.core.management.base import BaseCommand -from django.conf import settings - -from colab.proxy.proxybase.proxy_data_api import ProxyDataAPI - - -class Command(BaseCommand): - help = "Import proxy data into colab database" - - def handle(self, *args, **kwargs): - print "Executing extraction command..." - - for module_name in settings.PROXIED_APPS.keys(): - module_path = 'colab.proxy.{}.data_api'.format(module_name) - module = importlib.import_module(module_path) - - for module_item_name in dir(module): - module_item = getattr(module, module_item_name) - if issubclass(module_item, ProxyDataAPI): - if module_item != ProxyDataAPI: - api = module_item() - api.fetchData() diff --git a/colab/proxy/proxybase/proxy_data_api.py b/colab/proxy/proxybase/proxy_data_api.py deleted file mode 100644 index b4fa475..0000000 --- a/colab/proxy/proxybase/proxy_data_api.py +++ /dev/null @@ -1,6 +0,0 @@ - -class ProxyDataAPI(): - - - def fetchData(self): - raise NotImplementedError('fetchData not yet implemented') \ No newline at end of file diff --git a/colab/proxy/redmine/data_api.py b/colab/proxy/redmine/data_api.py index f4e6b54..132d060 100644 --- a/colab/proxy/redmine/data_api.py +++ b/colab/proxy/redmine/data_api.py @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI class RedmineDataAPI(ProxyDataAPI): - def fetchData(self): + def fetch_data(self): pass diff --git a/colab/proxy/trac/data_api.py b/colab/proxy/trac/data_api.py index 6abd9f0..b7e18a9 100644 --- a/colab/proxy/trac/data_api.py +++ b/colab/proxy/trac/data_api.py @@ -3,5 +3,5 @@ from colab.proxy.utils.proxy_data_api import ProxyDataAPI class TracDataAPI(ProxyDataAPI): - def fetchData(self): + def fetch_data(self): pass diff --git a/colab/proxy/trac/models.py b/colab/proxy/trac/models.py index 1343c87..f1725a6 100644 --- a/colab/proxy/trac/models.py +++ b/colab/proxy/trac/models.py @@ -131,21 +131,3 @@ class Wiki(models.Model, HitCounterModelMixin): return User.objects.get(username=self.modified_by) except User.DoesNotExist: return None - - -class WikiCollabCount(models.Model): - author = models.TextField(primary_key=True) - count = models.IntegerField() - - class Meta: - managed = False - db_table = 'wiki_collab_count_view' - - -class TicketCollabCount(models.Model): - author = models.TextField(primary_key=True) - count = models.IntegerField() - - class Meta: - managed = False - db_table = 'ticket_collab_count_view' diff --git a/colab/proxy/utils/proxy_data_api.py b/colab/proxy/utils/proxy_data_api.py index fd1a122..2fabf46 100644 --- a/colab/proxy/utils/proxy_data_api.py +++ b/colab/proxy/utils/proxy_data_api.py @@ -2,5 +2,5 @@ class ProxyDataAPI(object): - def fetchData(self): + def fetch_data(self): raise NotImplementedError('fetchData not yet implemented') diff --git a/colab/search/utils.py b/colab/search/utils.py index ce8f458..ad7e1e2 100644 --- a/colab/search/utils.py +++ b/colab/search/utils.py @@ -33,7 +33,7 @@ def trans(key): return translations.get(key, key) -def getCollaborationData(filter_by_user=None): +def get_collaboration_data(filter_by_user=None): latest_results = [] count_types = cache.get('home_chart') -- libgit2 0.21.2