From 409aa3cccfc4cb6f6597b20f1eee8743c6fb823e Mon Sep 17 00:00:00 2001 From: Macartur Sousa Date: Sat, 29 Aug 2015 21:37:38 +0000 Subject: [PATCH] Added CommunityAssociation in Noosfero --- colab/plugins/noosfero/static/noosfero/js/colab_integration.js | 6 +++--- colab/plugins/noosfero/views.py | 34 +++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/colab/plugins/noosfero/static/noosfero/js/colab_integration.js b/colab/plugins/noosfero/static/noosfero/js/colab_integration.js index be910dd..b72e571 100644 --- a/colab/plugins/noosfero/static/noosfero/js/colab_integration.js +++ b/colab/plugins/noosfero/static/noosfero/js/colab_integration.js @@ -20,7 +20,7 @@ function transform_tags() function feed_gitlab_tag() { - var $tag = $('.software-community-feed_repository'); + var $tag = $('#activity-tab'); $tag.text("Esta comunidade não está associada a"+ " nenhum repositório no momento, para mais"+ " detalhes contacte o administrador"); @@ -31,9 +31,9 @@ function feed_gitlab_tag() function discussion_tag() { - var $tag = $('.software-community-discussion'); + var $tag = $('#discussions-tab'); var request_path = '/spb/get_list/'+ '?list_name='+mailman_list+ '&MAX='+list_limit; $tag.load(request_path); -} \ No newline at end of file +} diff --git a/colab/plugins/noosfero/views.py b/colab/plugins/noosfero/views.py index e534a47..6e68840 100644 --- a/colab/plugins/noosfero/views.py +++ b/colab/plugins/noosfero/views.py @@ -2,7 +2,7 @@ from django.conf import settings from colab.plugins.views import ColabProxyView - +from colab_spb.models import CommunityAssociations class NoosferoProxyView(ColabProxyView): app_label = 'noosfero' @@ -11,16 +11,24 @@ class NoosferoProxyView(ColabProxyView): ('^/social/account/login(.*)$', r'{}\1'.format(settings.LOGIN_URL)), ) - def get_context_data(self, **kwargs): - context = super(NoosferoProxyView, self).get_context_data(**kwargs) - context['community_association'] = { - 'community':'e-sic-livre', - 'repository':'/gitlab/software-publico', - 'mailman_list':'lista', - 'list_limit':7, - 'activities_limit':7, - } - return context - def dispatch(self, request, *args, **kwargs): - return super(NoosferoProxyView, self).dispatch(request, *args, **kwargs) + return super(NoosferoProxyView, self).dispatch(request, + *args, **kwargs) + + def set_current_community_association(self, context): + community = self.request.path.split('/')[2] + + if not community: + return + + associations = CommunityAssociations.objects.all() + + for community_association in associations: + if community_association.community.name in community: + context['community_association'] = { + 'community': community_association.community.name, + 'repository': community_association.group.url, + 'mailman_list': community_association.mail_list.name, + 'list_limit': 7, + 'activities_limit': 7, + } -- libgit2 0.21.2