views.py
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from django.conf import settings
from colab.plugins.views import ColabProxyView
from colab_spb.models import CommunityAssociations
class NoosferoProxyView(ColabProxyView):
app_label = 'noosfero'
diazo_theme_template = 'proxy/noosfero.html'
rewrite = (
('^/social/account/login(.*)$', r'{}\1'.format(settings.LOGIN_URL)),
)
def dispatch(self, request, *args, **kwargs):
return super(NoosferoProxyView, self).dispatch(request,
*args, **kwargs)
def get_context_data(self, **kwargs):
context = super(NoosferoProxyView, self).get_context_data(**kwargs)
community = self.get_community_name(self.request.path)
if community is "":
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,
}
return context
return context
def get_community_name(self, path):
community = ""
words = self.request.path.split('/')
for index in range(len(words)):
if 'profile' in words[index]:
community = words[index+1]
break
return community