Commit e211e9c7bdfba5671d98425f9d7789e903060ca4
Committed by
Gust
1 parent
c20987eb
Exists in
master
and in
4 other branches
Removed some of workarounds
Showing
7 changed files
with
42 additions
and
46 deletions
Show diff stats
colab/accounts/templates/accounts/user_update_form.html
@@ -121,7 +121,7 @@ $(function() { | @@ -121,7 +121,7 @@ $(function() { | ||
121 | <h3>{% gravatar user_.email 50 %} {{ user_.get_full_name }} ({{ user_.username }})</h3> | 121 | <h3>{% gravatar user_.email 50 %} {{ user_.get_full_name }} ({{ user_.username }})</h3> |
122 | <a href="https://gravatar.com" target="_blank"> | 122 | <a href="https://gravatar.com" target="_blank"> |
123 | {% trans "Change your avatar at Gravatar.com" %} | 123 | {% trans "Change your avatar at Gravatar.com" %} |
124 | - </a>{{ lala }} | 124 | + </a> |
125 | </div> | 125 | </div> |
126 | <br> | 126 | <br> |
127 | <br> | 127 | <br> |
@@ -148,7 +148,7 @@ $(function() { | @@ -148,7 +148,7 @@ $(function() { | ||
148 | } | 148 | } |
149 | </style> | 149 | </style> |
150 | <div class="tab-content"> | 150 | <div class="tab-content"> |
151 | - <div id="profile" class="tab-pane fade"> | 151 | + <div id="profile" class="tab-pane fade in active"> |
152 | <form method="post"> | 152 | <form method="post"> |
153 | {% csrf_token %} | 153 | {% csrf_token %} |
154 | 154 | ||
@@ -229,15 +229,12 @@ $(function() { | @@ -229,15 +229,12 @@ $(function() { | ||
229 | </div> | 229 | </div> |
230 | </form> | 230 | </form> |
231 | </div> | 231 | </div> |
232 | - <div id="code" class="tab-pane fade in active"> | ||
233 | - {% content_xpto %} | ||
234 | - </div> | ||
235 | - <div id="social" class="tab-pane fade"> | ||
236 | - <p>Some content in menu 2.</p> | ||
237 | - </div> | 232 | + {% for widget in widgets %} |
233 | + <div id="{{ widget.identifier }}" class="tab-pane fade"> | ||
234 | + <h2>{{ widget.name }}</h2> | ||
235 | + {{ widget.get_body }} | ||
236 | + </div> | ||
237 | + {% endfor %} | ||
238 | </div> | 238 | </div> |
239 | 239 | ||
240 | - | ||
241 | - | ||
242 | - | ||
243 | {% endblock %} | 240 | {% endblock %} |
colab/accounts/views.py
@@ -46,7 +46,6 @@ class UserProfileUpdateView(UserProfileBaseMixin, UpdateView): | @@ -46,7 +46,6 @@ class UserProfileUpdateView(UserProfileBaseMixin, UpdateView): | ||
46 | def get_context_data(self, **kwargs): | 46 | def get_context_data(self, **kwargs): |
47 | context = {} | 47 | context = {} |
48 | context['widgets'] = WidgetManager.get_widgets('profile', self.request) | 48 | context['widgets'] = WidgetManager.get_widgets('profile', self.request) |
49 | - context['lala'] = 'lala123' | ||
50 | context.update(kwargs) | 49 | context.update(kwargs) |
51 | return super(UserProfileUpdateView, self).get_context_data(**context) | 50 | return super(UserProfileUpdateView, self).get_context_data(**context) |
52 | 51 |
colab/plugins/gitlab/templates/proxy/gitlab_profile.html
@@ -31,8 +31,7 @@ | @@ -31,8 +31,7 @@ | ||
31 | {% block head_js %} | 31 | {% block head_js %} |
32 | <script>jQuery.noConflict();</script> | 32 | <script>jQuery.noConflict();</script> |
33 | {% endblock %} | 33 | {% endblock %} |
34 | -<body> | ||
35 | -</body> | 34 | + |
36 | <div id="main-content"></div> | 35 | <div id="main-content"></div> |
37 | <script type="text/javascript"> | 36 | <script type="text/javascript"> |
38 | jQuery(function(){ | 37 | jQuery(function(){ |
colab/plugins/gitlab/urls.py
@@ -4,7 +4,5 @@ from django.conf.urls import patterns, url | @@ -4,7 +4,5 @@ from django.conf.urls import patterns, url | ||
4 | from .views import GitlabProxyView, GitlabProfileProxyView | 4 | from .views import GitlabProxyView, GitlabProfileProxyView |
5 | 5 | ||
6 | urlpatterns = patterns('', | 6 | urlpatterns = patterns('', |
7 | - # Gitlab URLs | ||
8 | - #url(r'(?P<path>profile.*)$', GitlabProfileProxyView.as_view(), name='gitlab'), | ||
9 | url(r'^(?P<path>.*)$', GitlabProxyView.as_view(), name='gitlab'), | 7 | url(r'^(?P<path>.*)$', GitlabProxyView.as_view(), name='gitlab'), |
10 | ) | 8 | ) |
colab/plugins/gitlab/widgets.py
@@ -8,14 +8,28 @@ class GitlabProfileWidget(GitlabProxyView, Widget): | @@ -8,14 +8,28 @@ class GitlabProfileWidget(GitlabProxyView, Widget): | ||
8 | name = 'Gitlab Profile' | 8 | name = 'Gitlab Profile' |
9 | default_url = '/gitlab/profile/account' | 9 | default_url = '/gitlab/profile/account' |
10 | 10 | ||
11 | + def get_body(self): | ||
12 | + start = self.content.find('<body') | ||
13 | + start = self.content.find('>', start) | ||
14 | + end = self.content.find('</body>') | ||
15 | + print "start = " + str(start) + ", end = " + str(end) | ||
16 | + print "content = " + self.content | ||
17 | + | ||
18 | + if -1 in [start, end]: | ||
19 | + return '' | ||
20 | + | ||
21 | + body = self.content[start + len('>'):end] | ||
22 | + return mark_safe(body) | ||
23 | + | ||
11 | def generate_content(self, request): | 24 | def generate_content(self, request): |
12 | requested_url = request.GET.get('code', self.default_url) | 25 | requested_url = request.GET.get('code', self.default_url) |
13 | g = GitlabProfileProxyView() | 26 | g = GitlabProfileProxyView() |
14 | r = g.dispatch(request, requested_url) | 27 | r = g.dispatch(request, requested_url) |
28 | + | ||
15 | if r.status_code == 302: | 29 | if r.status_code == 302: |
16 | location = r.get('Location') | 30 | location = r.get('Location') |
17 | requested_url = location[location.find('/{}/'.format(self.app_label)):] | 31 | requested_url = location[location.find('/{}/'.format(self.app_label)):] |
18 | request.method = 'GET' | 32 | request.method = 'GET' |
19 | r = g.dispatch(request, requested_url) | 33 | r = g.dispatch(request, requested_url) |
20 | 34 | ||
21 | - return "<div>" + r.content + "</div>" | ||
22 | \ No newline at end of file | 35 | \ No newline at end of file |
36 | + self.content = r.content |
colab/plugins/templatetags/plugins.py
@@ -51,23 +51,3 @@ def plugins_menu(context): | @@ -51,23 +51,3 @@ def plugins_menu(context): | ||
51 | 51 | ||
52 | cache.set(cache_key, menu) | 52 | cache.set(cache_key, menu) |
53 | return menu | 53 | return menu |
54 | - | ||
55 | -import requests | ||
56 | -from django.conf import settings | ||
57 | -from colab.plugins.gitlab.views import GitlabProfileProxyView | ||
58 | -@register.simple_tag(takes_context=True) | ||
59 | -def content_xpto(context): | ||
60 | - request = context['request'] | ||
61 | - requested_url = request.GET.get('code', '/gitlab/profile/account') | ||
62 | - print "requested_url1 = " + requested_url | ||
63 | - | ||
64 | - g = GitlabProfileProxyView() | ||
65 | - r = g.dispatch(request, requested_url) | ||
66 | - if r.status_code == 302: | ||
67 | - location = r.get('Location') | ||
68 | - requested_url = location[location.find('/gitlab/'):] | ||
69 | - request.method = 'GET' | ||
70 | - print "requested_url2 = " + requested_url | ||
71 | - r = g.dispatch(request, requested_url) | ||
72 | - | ||
73 | - return "<div>" + r.content + "</div>" |
colab/plugins/utils/widget_manager.py
1 | +from django.utils.safestring import mark_safe | ||
1 | 2 | ||
2 | class Widget: | 3 | class Widget: |
3 | identifier = None | 4 | identifier = None |
4 | name = None | 5 | name = None |
5 | default_url = None | 6 | default_url = None |
6 | - content = None | 7 | + content = '' |
7 | 8 | ||
8 | def get_body(self): | 9 | def get_body(self): |
9 | # avoiding regex in favor of performance | 10 | # avoiding regex in favor of performance |
10 | - start = content.find('<body>') | ||
11 | - end = content.find('</body>') | ||
12 | - head = content[start + len('<body>'):end] | ||
13 | - return head | 11 | + start = self.content.find('<body>') |
12 | + end = self.content.find('</body>') | ||
13 | + | ||
14 | + if -1 in [start, end]: | ||
15 | + return '' | ||
16 | + | ||
17 | + body = self.content[start + len('<body>'):end] | ||
18 | + return mark_safe(body) | ||
14 | 19 | ||
15 | def get_header(self): | 20 | def get_header(self): |
16 | # avoiding regex in favor of performance | 21 | # avoiding regex in favor of performance |
17 | - start = content.find('<head>') | ||
18 | - end = content.find('</head>') | ||
19 | - head = content[start + len('<head>'):end] | ||
20 | - return head | 22 | + start = self.content.find('<head>') |
23 | + end = self.content.find('</head>') | ||
24 | + | ||
25 | + if -1 in [start, end]: | ||
26 | + return '' | ||
27 | + | ||
28 | + head = self.content[start + len('<head>'):end] | ||
29 | + return mark_safe(head) | ||
21 | 30 | ||
22 | def generate_content(self, request=None): | 31 | def generate_content(self, request=None): |
23 | self.content = '' | 32 | self.content = '' |