From 8bfbb2bdf8a41620c58c8d9dd1874b98412eda3e Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 27 May 2020 13:16:51 +0200 Subject: [PATCH] better names for categories --- rowers/models.py | 21 +++++------------ rowers/mytypes.py | 12 +++++++++- rowers/scoring.py | 5 +++-- rowers/templates/standard_view.html | 6 ++--- rowers/templatetags/rowerfilters.py | 35 ++++++++++++++++++++++++++++- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index 53db424f..2eca5a37 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -243,15 +243,9 @@ def update_records(url=c2url,verbose=True): class CalcAgePerformance(models.Model): - weightcategories = ( - ('hwt','heavy-weight'), - ('lwt','light-weight'), - ) + weightcategories = mytypes.weightcategories - sexcategories = ( - ('male','male'), - ('female','female'), - ) + sexcategories = mytypes.sexcategories weightcategory = models.CharField(default="hwt", max_length=30, @@ -288,10 +282,7 @@ class PowerTimeFitnessMetric(models.Model): @python_2_unicode_compatible class C2WorldClassAgePerformance(models.Model): - weightcategories = ( - ('hwt','heavy-weight'), - ('lwt','light-weight'), - ) + weightcategories = mytypes.weightcategories sexcategories = ( ('male','male'), @@ -593,10 +584,8 @@ sexcategories = ( ('female','female'), ('not specified','not specified'), ) -weightcategories = ( - ('hwt','heavy-weight'), - ('lwt','light-weight'), -) + +weightcategories = mytypes.weightcategories # Plan diff --git a/rowers/mytypes.py b/rowers/mytypes.py index c70ffbcc..294cb8bb 100644 --- a/rowers/mytypes.py +++ b/rowers/mytypes.py @@ -316,13 +316,23 @@ boattypes = ( ) adaptivetypes = ( - ('None','None'), + ('None','Open'), ('PR1', 'PR1 (Arms and Shoulders)'), ('PR2', 'PR2 (Trunk and Arms)'), ('PR3', 'PR3 (Leg Trunk and Arms)'), ('FES', 'FES (Functional Electrical Stimulation)'), ) +weightcategories = ( + ('hwt','open-weight'), + ('lwt','light-weight'), + ) + +sexcategories = ( + ('male','Open'), + ('female','Female'), + ) + waterboattype = [i[0] for i in boattypes] privacychoices = ( diff --git a/rowers/scoring.py b/rowers/scoring.py index b196b8f5..915a799b 100644 --- a/rowers/scoring.py +++ b/rowers/scoring.py @@ -84,12 +84,13 @@ def save_scoring(name,user,filename,id=0,notes=""): except KeyError: weightclass = 'hwt' + adaptiveclass = 'None' try: adaptiveclass = row['AdaptiveClass'] if adaptiveclass.lower() in ['o','open','none','no']: - adaptiveclass = None + adaptiveclass = 'None' except KeyError: - adaptiveclass = None + adaptiveclass = 'None' try: skillclass = row['SkillClass'] diff --git a/rowers/templates/standard_view.html b/rowers/templates/standard_view.html index e42b4aad..c76f0f49 100644 --- a/rowers/templates/standard_view.html +++ b/rowers/templates/standard_view.html @@ -57,9 +57,9 @@ {{ standard.coursetime }} {{ standard.boatclass }} {{ standard.boattype }} - {{ standard.sex }} - {{ standard.weightclass }} - {{ standard.adaptiveclass }} + {{ standard.sex|sex }} + {{ standard.weightclass|weight }} + {{ standard.adaptiveclass|adaptive }} {{ standard.skillclass }} {{ standard.agemin }}/{{ standard.agemax }} diff --git a/rowers/templatetags/rowerfilters.py b/rowers/templatetags/rowerfilters.py index 4974bce7..9a2aab71 100644 --- a/rowers/templatetags/rowerfilters.py +++ b/rowers/templatetags/rowerfilters.py @@ -22,7 +22,7 @@ from rowers import c2stuff, runkeeperstuff from rowers.c2stuff import c2_open from rowers.runkeeperstuff import runkeeper_open from rowers.rower_rules import is_coach_user, is_workout_user, isplanmember,ispromember -from rowers.mytypes import otwtypes +from rowers.mytypes import otwtypes,adaptivetypes,sexcategories,weightcategories from rowers.utils import NoTokenError import rowers.payments as payments @@ -38,6 +38,39 @@ from django.template.defaultfilters import stringfilter from six import string_types +@register.filter +def adaptive(s): + u = s + + for e,v in adaptivetypes: + if e.lower() == u.lower(): + u = v + continue + + return u + +@register.filter +def sex(s): + u = s + + for e,v in sexcategories: + if e.lower() == u.lower(): + u = v + continue + + return u + +@register.filter +def weight(s): + u = s + + for e,v in weightcategories: + if e.lower() == u.lower(): + u = v + continue + + return u + @register.filter def sigdig(value, digits = 3): try: