Commit ac15cbd2ccb40a7f07e70d74805775a2e337caff
1 parent
7397ed19
Exists in
master
and in
4 other branches
Created import_widgets templatetag
- The template tag inserts the widgtes from an area in the html context Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com>
Showing
7 changed files
with
26 additions
and
11 deletions
Show diff stats
colab/accounts/templates/accounts/user_update_form.html
1 | 1 | {% extends "base.html" %} |
2 | -{% load i18n gravatar plugins %} | |
2 | +{% load i18n gravatar plugins widgets_tag %} | |
3 | + | |
4 | +{% block html %} | |
5 | + {% import_widgets 'profile' %} | |
6 | + {{ block.super }} | |
7 | +{% endblock %} | |
3 | 8 | |
4 | 9 | {% block head_js %} |
5 | 10 | <script> |
... | ... | @@ -105,7 +110,7 @@ $(function() { |
105 | 110 | {% block head %} |
106 | 111 | {{ block.super }} |
107 | 112 | |
108 | - {% for widget in widgets %} | |
113 | + {% for widget in widgets_profile %} | |
109 | 114 | {{ widget.get_header }} |
110 | 115 | {% endfor %} |
111 | 116 | |
... | ... | @@ -129,7 +134,7 @@ $(function() { |
129 | 134 | <!-- Start of navs --> |
130 | 135 | <ul class="nav nav-tabs"> |
131 | 136 | <li class="active"><a data-toggle="pill" href="#profile">Profile</a></li> |
132 | - {% for widget in widgets %} | |
137 | + {% for widget in widgets_profile %} | |
133 | 138 | <li> |
134 | 139 | <a data-toggle="pill" href="#{{ widget.identifier }}">{{ widget.name }}</a> |
135 | 140 | </li> |
... | ... | @@ -229,7 +234,7 @@ $(function() { |
229 | 234 | </div> |
230 | 235 | </form> |
231 | 236 | </div> |
232 | - {% for widget in widgets %} | |
237 | + {% for widget in widgets_profile %} | |
233 | 238 | <div id="{{ widget.identifier }}" class="tab-pane fade"> |
234 | 239 | <h2>{{ widget.name }}</h2> |
235 | 240 | {{ widget.get_body }} | ... | ... |
colab/accounts/views.py
... | ... | @@ -15,7 +15,6 @@ from colab.super_archives.models import (EmailAddress, |
15 | 15 | EmailAddressValidation) |
16 | 16 | from colab.search.utils import get_collaboration_data, get_visible_threads |
17 | 17 | from colab.accounts.models import User |
18 | -from colab.widgets.widget_manager import WidgetManager | |
19 | 18 | |
20 | 19 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm) |
21 | 20 | from .utils import mailman |
... | ... | @@ -43,12 +42,6 @@ class UserProfileUpdateView(UserProfileBaseMixin, UpdateView): |
43 | 42 | |
44 | 43 | return obj |
45 | 44 | |
46 | - def get_context_data(self, **kwargs): | |
47 | - context = {} | |
48 | - context['widgets'] = WidgetManager.get_widgets('profile', self.request) | |
49 | - context.update(kwargs) | |
50 | - return super(UserProfileUpdateView, self).get_context_data(**context) | |
51 | - | |
52 | 45 | |
53 | 46 | class UserProfileDetailView(UserProfileBaseMixin, DetailView): |
54 | 47 | template_name = 'accounts/user_detail.html' | ... | ... |
colab/settings.py
colab/templates/base.html
... | ... | @@ -0,0 +1,14 @@ |
1 | +from django import template | |
2 | +from colab.widgets.widget_manager import WidgetManager | |
3 | + | |
4 | + | |
5 | +register = template.Library() | |
6 | + | |
7 | + | |
8 | +@register.simple_tag(takes_context=True) | |
9 | +def import_widgets(context, area_id, widget_var=None): | |
10 | + if not widget_var: | |
11 | + widget_var = "widgets_{}".format(area_id) | |
12 | + context[widget_var] = WidgetManager.get_widgets(area_id, | |
13 | + context['request']) | |
14 | + return "" | ... | ... |