From 22fd419aeaae458cf92bd2918265e72574984bea Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Jul 25 2017 14:48:11 +0000 Subject: Tranfer the hub edit mode to the widgets Some widgets display no chrome when there is no data. However, in edit mode, the chrome should be displayed anyway or the widget can't be configured, removed, or moved on the page. This change allows widgets to be informed of the display mode and display the panel chrome accordingly. --- diff --git a/hubs/templates/hubs.html b/hubs/templates/hubs.html index 63946a3..ff6ed6d 100644 --- a/hubs/templates/hubs.html +++ b/hubs/templates/hubs.html @@ -96,7 +96,7 @@
{% for widget in widgets["left"] %}
{% endfor %}
@@ -120,7 +120,7 @@
{% for widget in widgets["right"] %}
{% endfor %}
diff --git a/hubs/tests/test_widget_view.py b/hubs/tests/test_widget_view.py new file mode 100644 index 0000000..328d207 --- /dev/null +++ b/hubs/tests/test_widget_view.py @@ -0,0 +1,34 @@ +from __future__ import unicode_literals + +import six +from mock import Mock + +from hubs.app import app +from hubs.tests import APPTest +from hubs.widgets.base import Widget +from hubs.widgets.caching import CachedFunction +from hubs.widgets.view import WidgetView, RootWidgetView + + +class TestingWidget(Widget): + name = "testing" + + +class WidgetViewTest(APPTest): + + def test_root_view(self): + testing_widget = TestingWidget() + view = RootWidgetView(testing_widget) + self.assertEqual(view.name, "root") + self.assertEqual(view.url_rules, ["/"]) + self.assertEqual(view.template_name, "root.html") + + def test_root_view_edit_mode(self): + testing_widget = TestingWidget() + view = RootWidgetView(testing_widget) + with app.test_request_context('/'): + context = view.get_extra_context(None) + self.assertFalse(context["edit_mode"]) + with app.test_request_context('/?editmode=1'): + context = view.get_extra_context(None) + self.assertTrue(context["edit_mode"]) diff --git a/hubs/widgets/about/__init__.py b/hubs/widgets/about/__init__.py index 1de5e0c..196ace3 100644 --- a/hubs/widgets/about/__init__.py +++ b/hubs/widgets/about/__init__.py @@ -1,7 +1,8 @@ from __future__ import unicode_literals from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import WidgetView, RootWidgetView class About(Widget): @@ -17,11 +18,7 @@ class About(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "about.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): return dict( diff --git a/hubs/widgets/about/templates/about.html b/hubs/widgets/about/templates/about.html deleted file mode 100644 index eafc55a..0000000 --- a/hubs/widgets/about/templates/about.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -

{{text}}

-{% endblock %} diff --git a/hubs/widgets/about/templates/root.html b/hubs/widgets/about/templates/root.html new file mode 100644 index 0000000..eafc55a --- /dev/null +++ b/hubs/widgets/about/templates/root.html @@ -0,0 +1,5 @@ +{% extends "panel.html" %} + +{% block content %} +

{{text}}

+{% endblock %} diff --git a/hubs/widgets/badges/__init__.py b/hubs/widgets/badges/__init__.py index 00eae24..ee1ff98 100644 --- a/hubs/widgets/badges/__init__.py +++ b/hubs/widgets/badges/__init__.py @@ -4,7 +4,8 @@ import operator import requests from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import WidgetView, RootWidgetView from hubs.widgets.caching import CachedFunction @@ -21,11 +22,7 @@ class Badges(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "badges.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): context = {"title": self.widget.label} diff --git a/hubs/widgets/badges/templates/badges.html b/hubs/widgets/badges/templates/badges.html deleted file mode 100644 index c7201d2..0000000 --- a/hubs/widgets/badges/templates/badges.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
-{% for badge in assertions %} - - - -{% endfor %} -
-{% endblock %} diff --git a/hubs/widgets/badges/templates/root.html b/hubs/widgets/badges/templates/root.html new file mode 100644 index 0000000..c7201d2 --- /dev/null +++ b/hubs/widgets/badges/templates/root.html @@ -0,0 +1,11 @@ +{% extends "panel.html" %} + +{% block content %} +
+{% for badge in assertions %} + + + +{% endfor %} +
+{% endblock %} diff --git a/hubs/widgets/bugzilla/__init__.py b/hubs/widgets/bugzilla/__init__.py index b55f1e8..a57d72b 100644 --- a/hubs/widgets/bugzilla/__init__.py +++ b/hubs/widgets/bugzilla/__init__.py @@ -6,16 +6,14 @@ import pkgwat.api from hubs.utils.pkgdb import get_owned_packages from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import WidgetView, RootWidgetView from hubs.widgets.caching import CachedFunction log = logging.getLogger('hubs.widgets') -PKGDB_URL = "https://admin.fedoraproject.org/pkgdb/api/packager/package" - - class Bugzilla(Widget): name = "bugzilla" @@ -36,11 +34,7 @@ class Bugzilla(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "bugzilla.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): get_issues = GetIssues(instance) diff --git a/hubs/widgets/bugzilla/templates/bugzilla.html b/hubs/widgets/bugzilla/templates/bugzilla.html deleted file mode 100644 index 5fc68b5..0000000 --- a/hubs/widgets/bugzilla/templates/bugzilla.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} - -{% endblock %} diff --git a/hubs/widgets/bugzilla/templates/root.html b/hubs/widgets/bugzilla/templates/root.html new file mode 100644 index 0000000..5fc68b5 --- /dev/null +++ b/hubs/widgets/bugzilla/templates/root.html @@ -0,0 +1,21 @@ +{% extends "panel.html" %} + +{% block content %} + +{% endblock %} diff --git a/hubs/widgets/contact/__init__.py b/hubs/widgets/contact/__init__.py index 59b7a1d..0d6c6b3 100644 --- a/hubs/widgets/contact/__init__.py +++ b/hubs/widgets/contact/__init__.py @@ -5,7 +5,8 @@ import hubs.models import requests import six -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import WidgetView, RootWidgetView from hubs.utils.views import login_required @@ -15,11 +16,7 @@ class Contact(Widget): position = "both" -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "contact.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): ''' Data for Contact widget. Checks if the hub associated diff --git a/hubs/widgets/contact/templates/contact.html b/hubs/widgets/contact/templates/contact.html deleted file mode 100644 index d4844e9..0000000 --- a/hubs/widgets/contact/templates/contact.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
- {% if usergroup %} - - {% else %} - - {% endif %} -
-{% endblock %} diff --git a/hubs/widgets/contact/templates/root.html b/hubs/widgets/contact/templates/root.html new file mode 100644 index 0000000..d4844e9 --- /dev/null +++ b/hubs/widgets/contact/templates/root.html @@ -0,0 +1,74 @@ +{% extends "panel.html" %} + +{% block content %} +
+ {% if usergroup %} + + {% else %} + + {% endif %} +
+{% endblock %} diff --git a/hubs/widgets/dummy/__init__.py b/hubs/widgets/dummy/__init__.py index 463e359..d6733b7 100644 --- a/hubs/widgets/dummy/__init__.py +++ b/hubs/widgets/dummy/__init__.py @@ -1,7 +1,8 @@ from __future__ import unicode_literals from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView class Dummy(Widget): @@ -17,11 +18,7 @@ class Dummy(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "dummy.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): return dict( diff --git a/hubs/widgets/dummy/templates/dummy.html b/hubs/widgets/dummy/templates/dummy.html deleted file mode 100644 index f2b2486..0000000 --- a/hubs/widgets/dummy/templates/dummy.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -{{text}} -{% endblock %} diff --git a/hubs/widgets/dummy/templates/root.html b/hubs/widgets/dummy/templates/root.html new file mode 100644 index 0000000..f2b2486 --- /dev/null +++ b/hubs/widgets/dummy/templates/root.html @@ -0,0 +1,5 @@ +{% extends "panel.html" %} + +{% block content %} +{{text}} +{% endblock %} diff --git a/hubs/widgets/fedmsgstats/__init__.py b/hubs/widgets/fedmsgstats/__init__.py index fe86e40..2cecb75 100644 --- a/hubs/widgets/fedmsgstats/__init__.py +++ b/hubs/widgets/fedmsgstats/__init__.py @@ -8,7 +8,8 @@ import requests from hubs.utils import get_fedmsg_config from hubs.utils.text import commas from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView from hubs.widgets.caching import CachedFunction @@ -29,11 +30,7 @@ class FedmsgStats(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "fedmsgstats.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): username = instance.config["username"] diff --git a/hubs/widgets/fedmsgstats/templates/fedmsgstats.html b/hubs/widgets/fedmsgstats/templates/fedmsgstats.html deleted file mode 100644 index 6c6efe1..0000000 --- a/hubs/widgets/fedmsgstats/templates/fedmsgstats.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
-
- - - -
subscriberssubscribed to
{{subscribers_text}}{{subscribed_text}}
-
-
- {% if session['nickname'] != username %} -
    - {% if session['nickname'] in subscribers %} -
  • - -
  • - {% else %} -
  • - -
  • - {% endif %} -
- {% endif %} -
-
-{% endblock %} diff --git a/hubs/widgets/fedmsgstats/templates/root.html b/hubs/widgets/fedmsgstats/templates/root.html new file mode 100644 index 0000000..6c6efe1 --- /dev/null +++ b/hubs/widgets/fedmsgstats/templates/root.html @@ -0,0 +1,27 @@ +{% extends "panel.html" %} + +{% block content %} +
+
+ + + +
subscriberssubscribed to
{{subscribers_text}}{{subscribed_text}}
+
+
+ {% if session['nickname'] != username %} +
    + {% if session['nickname'] in subscribers %} +
  • + +
  • + {% else %} +
  • + +
  • + {% endif %} +
+ {% endif %} +
+
+{% endblock %} diff --git a/hubs/widgets/feed/__init__.py b/hubs/widgets/feed/__init__.py index 9010ad1..9a58891 100644 --- a/hubs/widgets/feed/__init__.py +++ b/hubs/widgets/feed/__init__.py @@ -4,7 +4,8 @@ from __future__ import unicode_literals, absolute_import import logging from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import WidgetView, RootWidgetView from .functions import GetData @@ -28,11 +29,7 @@ class Feed(Widget): cached_functions_module = ".functions" -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "feed.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): return dict( diff --git a/hubs/widgets/feed/templates/feed.html b/hubs/widgets/feed/templates/feed.html deleted file mode 100644 index f687dd4..0000000 --- a/hubs/widgets/feed/templates/feed.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
-
- - - -{% endblock %} diff --git a/hubs/widgets/feed/templates/root.html b/hubs/widgets/feed/templates/root.html new file mode 100644 index 0000000..f687dd4 --- /dev/null +++ b/hubs/widgets/feed/templates/root.html @@ -0,0 +1,18 @@ +{% extends "panel.html" %} + +{% block content %} +
+
+ + + +{% endblock %} diff --git a/hubs/widgets/fhosted/__init__.py b/hubs/widgets/fhosted/__init__.py index 38e69e6..b17eb7a 100644 --- a/hubs/widgets/fhosted/__init__.py +++ b/hubs/widgets/fhosted/__init__.py @@ -3,7 +3,8 @@ from __future__ import unicode_literals from six.moves.xmlrpc_client import ServerProxy from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView from hubs.widgets.caching import CachedFunction @@ -28,11 +29,7 @@ class FedoraHosted(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "fhosted.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): get_tickets = GetTickets(instance) diff --git a/hubs/widgets/fhosted/templates/fhosted.html b/hubs/widgets/fhosted/templates/fhosted.html deleted file mode 100644 index 5dcc574..0000000 --- a/hubs/widgets/fhosted/templates/fhosted.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "templates/panel.html" %} - -{% block content %} -{% if error %} -

{{ error }}

-{% else %} - - All Issues - -
- - -{% endif %} -{% endblock %} diff --git a/hubs/widgets/fhosted/templates/root.html b/hubs/widgets/fhosted/templates/root.html new file mode 100644 index 0000000..5dcc574 --- /dev/null +++ b/hubs/widgets/fhosted/templates/root.html @@ -0,0 +1,48 @@ +{% extends "templates/panel.html" %} + +{% block content %} +{% if error %} +

{{ error }}

+{% else %} + + All Issues + +
+ + +{% endif %} +{% endblock %} diff --git a/hubs/widgets/github_pr/__init__.py b/hubs/widgets/github_pr/__init__.py index 2de11a3..f52c149 100644 --- a/hubs/widgets/github_pr/__init__.py +++ b/hubs/widgets/github_pr/__init__.py @@ -5,7 +5,8 @@ import logging from hubs.utils import get_fedmsg_config from hubs.utils.github import github_repos, github_pulls from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView from hubs.widgets.caching import CachedFunction @@ -34,11 +35,7 @@ class GitHubPRs(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "github_pr.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): get_prs = GetPRs(instance) diff --git a/hubs/widgets/github_pr/templates/github_pr.html b/hubs/widgets/github_pr/templates/github_pr.html deleted file mode 100644 index 379771a..0000000 --- a/hubs/widgets/github_pr/templates/github_pr.html +++ /dev/null @@ -1,50 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} - - Organization Github Page - -
- -{% endblock %} diff --git a/hubs/widgets/github_pr/templates/root.html b/hubs/widgets/github_pr/templates/root.html new file mode 100644 index 0000000..379771a --- /dev/null +++ b/hubs/widgets/github_pr/templates/root.html @@ -0,0 +1,50 @@ +{% extends "panel.html" %} + +{% block content %} + + Organization Github Page + +
+ +{% endblock %} diff --git a/hubs/widgets/githubissues/__init__.py b/hubs/widgets/githubissues/__init__.py index 4da6f9f..e2a25e2 100644 --- a/hubs/widgets/githubissues/__init__.py +++ b/hubs/widgets/githubissues/__init__.py @@ -3,7 +3,8 @@ from __future__ import unicode_literals import requests from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView from hubs.widgets.caching import CachedFunction @@ -34,11 +35,7 @@ class GitHubIssues(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "githubissues.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): get_issues = GetIssues(instance) diff --git a/hubs/widgets/githubissues/templates/githubissues.html b/hubs/widgets/githubissues/templates/githubissues.html deleted file mode 100644 index 31943ae..0000000 --- a/hubs/widgets/githubissues/templates/githubissues.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -{% for i in range(display_number) %} -
- - - - - -
- #{{ all_issues[i]['num'] }} - - {{ all_issues[i]['title'] }} -
- - - - - -
- - Opened by {{ all_issues[i]['openedby'] }} - {% if all_issues[i]['assignee']|string() == "None" %} -
Unclaimed - {% else %} -
Assigned by {{ all_issues[i]['assignee'] }} - {% endif %} -
-
- - - -
-
-{% endfor %} -
-
All Issues
-
-{% endblock %} diff --git a/hubs/widgets/githubissues/templates/root.html b/hubs/widgets/githubissues/templates/root.html new file mode 100644 index 0000000..31943ae --- /dev/null +++ b/hubs/widgets/githubissues/templates/root.html @@ -0,0 +1,42 @@ +{% extends "panel.html" %} + +{% block content %} +{% for i in range(display_number) %} +
+ + + + + +
+ #{{ all_issues[i]['num'] }} + + {{ all_issues[i]['title'] }} +
+ + + + + +
+ + Opened by {{ all_issues[i]['openedby'] }} + {% if all_issues[i]['assignee']|string() == "None" %} +
Unclaimed + {% else %} +
Assigned by {{ all_issues[i]['assignee'] }} + {% endif %} +
+
+ + + +
+
+{% endfor %} +
+
All Issues
+
+{% endblock %} diff --git a/hubs/widgets/halp/templates/halp.html b/hubs/widgets/halp/templates/halp.html deleted file mode 100644 index 8709b0e..0000000 --- a/hubs/widgets/halp/templates/halp.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
-
- - -{% endblock %} diff --git a/hubs/widgets/halp/templates/root.html b/hubs/widgets/halp/templates/root.html new file mode 100644 index 0000000..8709b0e --- /dev/null +++ b/hubs/widgets/halp/templates/root.html @@ -0,0 +1,22 @@ +{% extends "panel.html" %} + +{% block content %} +
+
+ + +{% endblock %} diff --git a/hubs/widgets/halp/views.py b/hubs/widgets/halp/views.py index ada528b..584fb53 100644 --- a/hubs/widgets/halp/views.py +++ b/hubs/widgets/halp/views.py @@ -9,7 +9,7 @@ from flask.signals import template_rendered from hubs.models import Hub from hubs.utils.views import get_hub, require_hub_access from hubs.widgets import registry -from hubs.widgets.base import WidgetView +from hubs.widgets.view import WidgetView, RootWidgetView from .functions import GetRequests from .utils import find_hubs_for_msg, paginate @@ -19,13 +19,9 @@ except ImportError: before_render_template = None # Flask < 0.11 -class BaseView(WidgetView): +class BaseView(RootWidgetView): """The base view to instantiate the widget.""" - name = "root" - url_rules = ["/"] - template_name = "halp.html" - def get_context(self, instance, *args, **kwargs): return dict( hubs=instance.config.get("hubs", []), diff --git a/hubs/widgets/library/__init__.py b/hubs/widgets/library/__init__.py index 803b56a..3eddd2d 100644 --- a/hubs/widgets/library/__init__.py +++ b/hubs/widgets/library/__init__.py @@ -1,7 +1,8 @@ from __future__ import unicode_literals from hubs.widgets import clean_input, validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView class Library(Widget): @@ -19,11 +20,7 @@ class Library(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "library.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): urls = [ diff --git a/hubs/widgets/library/templates/library.html b/hubs/widgets/library/templates/library.html deleted file mode 100644 index b32cfcb..0000000 --- a/hubs/widgets/library/templates/library.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
-
-
    - {% for url in urls %} -
  • - {{ url }} -
  • - {% endfor %} -
-
-
-{% endblock %} diff --git a/hubs/widgets/library/templates/root.html b/hubs/widgets/library/templates/root.html new file mode 100644 index 0000000..b32cfcb --- /dev/null +++ b/hubs/widgets/library/templates/root.html @@ -0,0 +1,15 @@ +{% extends "panel.html" %} + +{% block content %} +
+
+
    + {% for url in urls %} +
  • + {{ url }} +
  • + {% endfor %} +
+
+
+{% endblock %} diff --git a/hubs/widgets/linechart/__init__.py b/hubs/widgets/linechart/__init__.py index 49388a2..c1fcf37 100644 --- a/hubs/widgets/linechart/__init__.py +++ b/hubs/widgets/linechart/__init__.py @@ -1,7 +1,8 @@ from __future__ import unicode_literals from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView class Linechart(Widget): @@ -18,11 +19,7 @@ class Linechart(Widget): )] -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "linechart.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): username = instance.config["username"] diff --git a/hubs/widgets/linechart/templates/linechart.html b/hubs/widgets/linechart/templates/linechart.html deleted file mode 100644 index 573d452..0000000 --- a/hubs/widgets/linechart/templates/linechart.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
- -
-{% endblock %} diff --git a/hubs/widgets/linechart/templates/root.html b/hubs/widgets/linechart/templates/root.html new file mode 100644 index 0000000..573d452 --- /dev/null +++ b/hubs/widgets/linechart/templates/root.html @@ -0,0 +1,7 @@ +{% extends "panel.html" %} + +{% block content %} +
+ +
+{% endblock %} diff --git a/hubs/widgets/meetings/__init__.py b/hubs/widgets/meetings/__init__.py index e8eec08..0633d40 100644 --- a/hubs/widgets/meetings/__init__.py +++ b/hubs/widgets/meetings/__init__.py @@ -7,7 +7,8 @@ import requests from hubs.utils.text import markup from hubs.widgets import validators -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView from hubs.widgets.caching import CachedFunction @@ -37,11 +38,7 @@ class Meetings(Widget): return env -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "meetings.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): get_meetings = GetMeetings(instance) diff --git a/hubs/widgets/meetings/templates/meetings.html b/hubs/widgets/meetings/templates/meetings.html deleted file mode 100644 index d2ade22..0000000 --- a/hubs/widgets/meetings/templates/meetings.html +++ /dev/null @@ -1,63 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -{% for title, next in meetings.items() %} -
-
-
  The {{ next.meeting_name }} is {{ next.start_dt | humanize }}
-
-
-
- {% if next.display_duration %} - {{ next.start_date }} - {{ next.stop_date }} - {% else %} - {{next.start_date}} - {% endif %} -
-
- {% if next.display_time %} - @{{ next.start_time }}{% endif %}
- - {{ next.location }} -
- -
- {% if next.get('meeting_information_html') %} -
-
- {{ next.meeting_information_html[:150] }} - {%- if next.meeting_information_html | length > 150 %}... -

- Full description -

- {% endif %} -
-
- {% endif %} -
-{% if meetings | length > 1 %}
{% endif %} -{% else %} -
-
- No coming meetings in {{ calendar }}. -
-
-{% endfor %} -{% endblock %} - - -{% block footer %} - -{% endblock %} diff --git a/hubs/widgets/meetings/templates/root.html b/hubs/widgets/meetings/templates/root.html new file mode 100644 index 0000000..d2ade22 --- /dev/null +++ b/hubs/widgets/meetings/templates/root.html @@ -0,0 +1,63 @@ +{% extends "panel.html" %} + +{% block content %} +{% for title, next in meetings.items() %} +
+
+
  The {{ next.meeting_name }} is {{ next.start_dt | humanize }}
+
+
+
+ {% if next.display_duration %} + {{ next.start_date }} - {{ next.stop_date }} + {% else %} + {{next.start_date}} + {% endif %} +
+
+ {% if next.display_time %} + @{{ next.start_time }}{% endif %}
+ + {{ next.location }} +
+ +
+ {% if next.get('meeting_information_html') %} +
+
+ {{ next.meeting_information_html[:150] }} + {%- if next.meeting_information_html | length > 150 %}... +

+ Full description +

+ {% endif %} +
+
+ {% endif %} +
+{% if meetings | length > 1 %}
{% endif %} +{% else %} +
+
+ No coming meetings in {{ calendar }}. +
+
+{% endfor %} +{% endblock %} + + +{% block footer %} + +{% endblock %} diff --git a/hubs/widgets/memberships/__init__.py b/hubs/widgets/memberships/__init__.py index 20f14c0..ff57c74 100644 --- a/hubs/widgets/memberships/__init__.py +++ b/hubs/widgets/memberships/__init__.py @@ -2,7 +2,8 @@ from __future__ import unicode_literals import hubs.models -from hubs.widgets.base import Widget, WidgetView +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView ELLIPSIS_LIMIT = 3 @@ -15,11 +16,7 @@ class Memberships(Widget): position = "both" -class BaseView(WidgetView): - - name = "root" - url_rules = ["/"] - template_name = "memberships.html" +class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): hub = instance.hub diff --git a/hubs/widgets/memberships/templates/memberships.html b/hubs/widgets/memberships/templates/memberships.html deleted file mode 100644 index 621ea9f..0000000 --- a/hubs/widgets/memberships/templates/memberships.html +++ /dev/null @@ -1,80 +0,0 @@ -{% extends "panel.html" %} - -{% block content %} -
- {% if memberships|length > oldest_members|length %} - {% for member in oldest_members %} -
- Hub avatar for {{ member.name }} - {{ member.name }} - {% if g.auth.username in member.owners %} -

Owner

- {% else %} -

Member

- {% endif %} -
- {% endfor %} - View All - {% else %} - {% for member in memberships %} -
- Hub avatar for {{ member.name }} - {{ member.name }} - {% if g.auth.username in member.owners %} -

Owner

- {% else %} -

Member

- {% endif %} -
- {% endfor %} - {%endif%} -
- - -