Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. @WidgetBase.register
  2. class ActivityDurationWidget(ProgressWidget):
  3.  
  4. current_value_annotation = _('This week')
  5. range_min = 0
  6. range_max = 600 # 10 * 60
  7. range_increment = 15
  8. goal_label = _('Set your daily goal')
  9. recommendation_text = _("We recommended at least **1 hour and 30 minutes** of moderate aerobic activity every week")
  10.  
  11. class Meta:
  12. proxy = True
  13.  
  14. @WidgetBase.register
  15. class ActivityDistanceWidget(ProgressWidget):
  16.  
  17. current_value_annotation = _('This week')
  18. range_min = 0
  19. range_max = 20000
  20. range_increment = 10
  21. goal_label = _('Set your daily goal')
  22. recommendation_text = _("recommendation for distance")
  23.  
  24. class Meta:
  25. proxy = True
  26.  
  27.  
  28.  
  29. label = "How would you like to track progress towards your goal?"
  30. dash_activity_metrics = ["distance" , "duration"]
  31.  
  32. for activity in WIDGET_CATEGORIES['activity']['items']:
  33. activity_identifier = activity['id']
  34. for metric in dash_activity_metrics:
  35. widget_id = "{0}-{1}".format(activity_identifier, metric)
  36. items.append(dict(id=widget_id, type="widget", label=metric, icon_id="<icon_name>"))
  37.  
  38. # dataformat_id = get the dataformat of this acitvity
  39. # icon_id = the icon_id of this widget
  40. current_value_query = mario.parse('{0}/{1}/this-week/sum'.format(activity_identifier, metric))
  41. # create a class object that extends
  42. # ActivityDistanceWidget if the metric is distance
  43. # ActivityDurationWidget if the metric is duration
  44. # with the dataformat_id, current_value_query defined above
  45.  
  46. # the activity category
  47. WIDGET_CATEGORIES[activity['id']] = dict(label=label, items=items)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement