From f8f4e1e80f3367b39ff543330ac0598ce1dd1bfc Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Jan 09 2018 11:01:02 +0000 Subject: organize the linechart / weekly activity widget renames the linechart widget in the code to weekly activity also, makes it only show on the user hub, and removes the config to just show the activity for the user that the user hub belongs to. --- diff --git a/hubs/default_config.py b/hubs/default_config.py index cb13489..9541815 100644 --- a/hubs/default_config.py +++ b/hubs/default_config.py @@ -57,7 +57,7 @@ WIDGETS = [ 'hubs.widgets.contact:Contact', 'hubs.widgets.dummy:Dummy', 'hubs.widgets.library:Library', - 'hubs.widgets.linechart:Linechart', + 'hubs.widgets.weeklyactivity:WeeklyActivity', 'hubs.widgets.feed:Feed', 'hubs.widgets.github_pr:GitHubPRs', 'hubs.widgets.githubissues:GitHubIssues', diff --git a/hubs/widgets/linechart/__init__.py b/hubs/widgets/linechart/__init__.py deleted file mode 100644 index 549a0b5..0000000 --- a/hubs/widgets/linechart/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -from __future__ import unicode_literals - -from hubs.utils import validators -from hubs.widgets.base import Widget -from hubs.widgets.view import RootWidgetView - - -class Linechart(Widget): - - name = "linechart" - label = "Weekly Activity" - position = "left" - parameters = [dict( - name="username", - label="Username", - default=None, - validator=validators.Username, - help="A FAS username.", - )] - - -class BaseView(RootWidgetView): - - def get_context(self, instance, *args, **kwargs): - username = instance.config["username"] - categories = [ - 'git', 'Wiki', 'Copr', 'anitya', 'mirrormanager', 'ansible', - 'fedoratagger', 'summershum', 'nuancier', 'Mailman', - 'fedbadges', 'FMN', 'koschei', 'compose', 'fedimg', - 'Jenkins', 'irc', 'FAS', 'buildsys', 'Askbot', 'pagure', - 'Bodhi', 'faf', 'kerneltest', 'github', 'Trac', 'meetbot', - 'planet', 'fedocal', 'hotness', - ] - categories = [c.lower() for c in categories] - categories = "&".join(['category=%s' % c for c in categories]) - url = ("https://apps.fedoraproject.org/datagrepper/charts/stackedline" - "?delta=604800&N=12&style=clean&height=300&fill=true" - "&user={username}&split_on=categories") - url = url + "&" + categories - url = url.format(username=username) - return dict(url=url) diff --git a/hubs/widgets/linechart/templates/root.html b/hubs/widgets/linechart/templates/root.html deleted file mode 100644 index 5b4e756..0000000 --- a/hubs/widgets/linechart/templates/root.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/hubs/widgets/weeklyactivity/__init__.py b/hubs/widgets/weeklyactivity/__init__.py new file mode 100644 index 0000000..662b1f9 --- /dev/null +++ b/hubs/widgets/weeklyactivity/__init__.py @@ -0,0 +1,38 @@ +from __future__ import unicode_literals + +from hubs.utils import validators +from hubs.widgets.base import Widget +from hubs.widgets.view import RootWidgetView + + +class WeeklyActivity(Widget): + + name = "weeklyactivity" + label = "Weekly Activity" + position = "left" + hub_types = ['user'] + + +class BaseView(RootWidgetView): + + def get_context(self, instance, *args, **kwargs): + # since this widget only shows on user hubs, we assume + # hub.name == the username + username = instance.hub.name + + categories = [ + 'git', 'Wiki', 'Copr', 'anitya', 'mirrormanager', 'ansible', + 'fedoratagger', 'summershum', 'nuancier', 'Mailman', + 'fedbadges', 'FMN', 'koschei', 'compose', 'fedimg', + 'Jenkins', 'irc', 'FAS', 'buildsys', 'Askbot', 'pagure', + 'Bodhi', 'faf', 'kerneltest', 'github', 'Trac', 'meetbot', + 'planet', 'fedocal', 'hotness', + ] + categories = [c.lower() for c in categories] + categories = "&".join(['category=%s' % c for c in categories]) + url = ("https://apps.fedoraproject.org/datagrepper/charts/stackedline" + "?delta=604800&N=12&style=clean&height=300&fill=true" + "&user={username}&split_on=categories") + url = url + "&" + categories + url = url.format(username=username) + return dict(url=url) diff --git a/hubs/widgets/weeklyactivity/templates/root.html b/hubs/widgets/weeklyactivity/templates/root.html new file mode 100644 index 0000000..5b4e756 --- /dev/null +++ b/hubs/widgets/weeklyactivity/templates/root.html @@ -0,0 +1,3 @@ +
+ +