Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @WidgetBase.register
- class ActivityDurationWidget(ProgressWidget):
- current_value_annotation = _('This week')
- range_min = 0
- range_max = 600 # 10 * 60
- range_increment = 15
- goal_label = _('Set your daily goal')
- recommendation_text = _("We recommended at least **1 hour and 30 minutes** of moderate aerobic activity every week")
- class Meta:
- proxy = True
- @WidgetBase.register
- class ActivityDistanceWidget(ProgressWidget):
- current_value_annotation = _('This week')
- range_min = 0
- range_max = 20000
- range_increment = 10
- goal_label = _('Set your daily goal')
- recommendation_text = _("recommendation for distance")
- class Meta:
- proxy = True
- label = "How would you like to track progress towards your goal?"
- dash_activity_metrics = ["distance" , "duration"]
- for activity in WIDGET_CATEGORIES['activity']['items']:
- activity_identifier = activity['id']
- for metric in dash_activity_metrics:
- widget_id = "{0}-{1}".format(activity_identifier, metric)
- items.append(dict(id=widget_id, type="widget", label=metric, icon_id="<icon_name>"))
- # dataformat_id = get the dataformat of this acitvity
- # icon_id = the icon_id of this widget
- current_value_query = mario.parse('{0}/{1}/this-week/sum'.format(activity_identifier, metric))
- # create a class object that extends
- # ActivityDistanceWidget if the metric is distance
- # ActivityDurationWidget if the metric is duration
- # with the dataformat_id, current_value_query defined above
- # the activity category
- WIDGET_CATEGORIES[activity['id']] = dict(label=label, items=items)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement