Commit 8802d4d572173e52ff793ecc46a876770a8ae38f
1 parent
dc49d1d7
Exists in
master
and in
4 other branches
Refactored widgets to receive **kwargs
Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
2 changed files
with
4 additions
and
5 deletions
Show diff stats
colab/widgets/templatetags/widgets_tag.py
@@ -9,6 +9,5 @@ register = template.Library() | @@ -9,6 +9,5 @@ register = template.Library() | ||
9 | def import_widgets(context, area_id, widget_var=None): | 9 | def import_widgets(context, area_id, widget_var=None): |
10 | if not widget_var: | 10 | if not widget_var: |
11 | widget_var = "widgets_{}".format(area_id) | 11 | widget_var = "widgets_{}".format(area_id) |
12 | - context[widget_var] = WidgetManager.get_widgets(area_id, | ||
13 | - context['request']) | 12 | + context[widget_var] = WidgetManager.get_widgets(area_id, context=context) |
14 | return "" | 13 | return "" |
colab/widgets/widget_manager.py
@@ -28,7 +28,7 @@ class Widget(object): | @@ -28,7 +28,7 @@ class Widget(object): | ||
28 | head = self.content[start + len('<head>'):end] | 28 | head = self.content[start + len('<head>'):end] |
29 | return mark_safe(head) | 29 | return mark_safe(head) |
30 | 30 | ||
31 | - def generate_content(self, request=None): | 31 | + def generate_content(self, **kwarg): |
32 | self.content = '' | 32 | self.content = '' |
33 | 33 | ||
34 | 34 | ||
@@ -50,11 +50,11 @@ class WidgetManager(object): | @@ -50,11 +50,11 @@ class WidgetManager(object): | ||
50 | WidgetManager.widget_categories[category].remove(widget) | 50 | WidgetManager.widget_categories[category].remove(widget) |
51 | 51 | ||
52 | @staticmethod | 52 | @staticmethod |
53 | - def get_widgets(category, request=None): | 53 | + def get_widgets(category, **kargs): |
54 | if category not in WidgetManager.widget_categories: | 54 | if category not in WidgetManager.widget_categories: |
55 | return [] | 55 | return [] |
56 | 56 | ||
57 | widgets = WidgetManager.widget_categories[category][:] | 57 | widgets = WidgetManager.widget_categories[category][:] |
58 | for widget in widgets: | 58 | for widget in widgets: |
59 | - widget.generate_content(request) | 59 | + widget.generate_content(**kargs) |
60 | return widgets | 60 | return widgets |