Commit e211e9c7bdfba5671d98425f9d7789e903060ca4

Authored by Charles Oliveira
Committed by Gust
1 parent c20987eb

Removed some of workarounds

colab/accounts/templates/accounts/user_update_form.html
... ... @@ -121,7 +121,7 @@ $(function() {
121 121 <h3>{% gravatar user_.email 50 %} {{ user_.get_full_name }} ({{ user_.username }})</h3>
122 122 <a href="https://gravatar.com" target="_blank">
123 123 {% trans "Change your avatar at Gravatar.com" %}
124   - </a>{{ lala }}
  124 + </a>
125 125 </div>
126 126 <br>
127 127 <br>
... ... @@ -148,7 +148,7 @@ $(function() {
148 148 }
149 149 </style>
150 150 <div class="tab-content">
151   - <div id="profile" class="tab-pane fade">
  151 + <div id="profile" class="tab-pane fade in active">
152 152 <form method="post">
153 153 {% csrf_token %}
154 154  
... ... @@ -229,15 +229,12 @@ $(function() {
229 229 </div>
230 230 </form>
231 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 238 </div>
239 239  
240   -
241   -
242   -
243 240 {% endblock %}
... ...
colab/accounts/views.py
... ... @@ -46,7 +46,6 @@ class UserProfileUpdateView(UserProfileBaseMixin, UpdateView):
46 46 def get_context_data(self, **kwargs):
47 47 context = {}
48 48 context['widgets'] = WidgetManager.get_widgets('profile', self.request)
49   - context['lala'] = 'lala123'
50 49 context.update(kwargs)
51 50 return super(UserProfileUpdateView, self).get_context_data(**context)
52 51  
... ...
colab/plugins/gitlab/templates/proxy/gitlab_profile.html
... ... @@ -31,8 +31,7 @@
31 31 {% block head_js %}
32 32 <script>jQuery.noConflict();</script>
33 33 {% endblock %}
34   -<body>
35   -</body>
  34 +
36 35 <div id="main-content"></div>
37 36 <script type="text/javascript">
38 37 jQuery(function(){
... ...
colab/plugins/gitlab/urls.py
... ... @@ -4,7 +4,5 @@ from django.conf.urls import patterns, url
4 4 from .views import GitlabProxyView, GitlabProfileProxyView
5 5  
6 6 urlpatterns = patterns('',
7   - # Gitlab URLs
8   - #url(r'(?P<path>profile.*)$', GitlabProfileProxyView.as_view(), name='gitlab'),
9 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 8 name = 'Gitlab Profile'
9 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 24 def generate_content(self, request):
12 25 requested_url = request.GET.get('code', self.default_url)
13 26 g = GitlabProfileProxyView()
14 27 r = g.dispatch(request, requested_url)
  28 +
15 29 if r.status_code == 302:
16 30 location = r.get('Location')
17 31 requested_url = location[location.find('/{}/'.format(self.app_label)):]
18 32 request.method = 'GET'
19 33 r = g.dispatch(request, requested_url)
20 34  
21   - return "<div>" + r.content + "</div>"
22 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 51  
52 52 cache.set(cache_key, menu)
53 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 3 class Widget:
3 4 identifier = None
4 5 name = None
5 6 default_url = None
6   - content = None
  7 + content = ''
7 8  
8 9 def get_body(self):
9 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 20 def get_header(self):
16 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 31 def generate_content(self, request=None):
23 32 self.content = ''
... ...