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 | 9 | def import_widgets(context, area_id, widget_var=None): |
| 10 | 10 | if not widget_var: |
| 11 | 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 | 13 | return "" | ... | ... |
colab/widgets/widget_manager.py
| ... | ... | @@ -28,7 +28,7 @@ class Widget(object): |
| 28 | 28 | head = self.content[start + len('<head>'):end] |
| 29 | 29 | return mark_safe(head) |
| 30 | 30 | |
| 31 | - def generate_content(self, request=None): | |
| 31 | + def generate_content(self, **kwarg): | |
| 32 | 32 | self.content = '' |
| 33 | 33 | |
| 34 | 34 | |
| ... | ... | @@ -50,11 +50,11 @@ class WidgetManager(object): |
| 50 | 50 | WidgetManager.widget_categories[category].remove(widget) |
| 51 | 51 | |
| 52 | 52 | @staticmethod |
| 53 | - def get_widgets(category, request=None): | |
| 53 | + def get_widgets(category, **kargs): | |
| 54 | 54 | if category not in WidgetManager.widget_categories: |
| 55 | 55 | return [] |
| 56 | 56 | |
| 57 | 57 | widgets = WidgetManager.widget_categories[category][:] |
| 58 | 58 | for widget in widgets: |
| 59 | - widget.generate_content(request) | |
| 59 | + widget.generate_content(**kargs) | |
| 60 | 60 | return widgets | ... | ... |