From 1fe12d46fcf4165032160f49c8662747769ee8b4 Mon Sep 17 00:00:00 2001 From: Justin Huang Date: Mon, 16 May 2016 10:58:33 -0700 Subject: [PATCH] Extend to month. --- hc/front/forms.py | 4 ++-- hc/front/templatetags/hc_extras.py | 6 +++++- static/js/checks.js | 22 +++++++++++++--------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/hc/front/forms.py b/hc/front/forms.py index 439215d7..c7bf28a3 100644 --- a/hc/front/forms.py +++ b/hc/front/forms.py @@ -18,8 +18,8 @@ class NameTagsForm(forms.Form): class TimeoutForm(forms.Form): - timeout = forms.IntegerField(min_value=60, max_value=604800) - grace = forms.IntegerField(min_value=60, max_value=604800) + timeout = forms.IntegerField(min_value=60, max_value=2592000) + grace = forms.IntegerField(min_value=60, max_value=2592000) class AddChannelForm(forms.ModelForm): diff --git a/hc/front/templatetags/hc_extras.py b/hc/front/templatetags/hc_extras.py index ee7fc13f..bdc304d2 100644 --- a/hc/front/templatetags/hc_extras.py +++ b/hc/front/templatetags/hc_extras.py @@ -8,9 +8,13 @@ def hc_duration(td): total = int(td.total_seconds() / 60) total, m = divmod(total, 60) total, h = divmod(total, 24) - w, d = divmod(total, 7) + o, rem = divmod(total, 30) + w, d = divmod(rem, 7) result = "" + if o: + result += "1 month " if w == 0 else "%d months " % w + if w: result += "1 week " if w == 1 else "%d weeks " % w diff --git a/static/js/checks.js b/static/js/checks.js index 47657bd9..8f19d25d 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -4,10 +4,12 @@ $(function () { total = Math.floor(total / 60); var m = total % 60; total = Math.floor(total / 60); var h = total % 24; total = Math.floor(total / 24); - var d = total % 7; total = Math.floor(total / 7); - var w = total; + var d = total % 30 % 7; + var o = Math.floor(total / 30); + var w = Math.floor(total % 30 / 7); var result = ""; + if (o) result += o + (o === 1 ? " month " : " months "); if (w) result += w + (w === 1 ? " week " : " weeks "); if (d) result += d + (d === 1 ? " day " : " days "); if (h) result += h + (h === 1 ? " hour " : " hours "); @@ -23,12 +25,13 @@ $(function () { range: { 'min': [60, 60], '30%': [3600, 3600], - '82.80%': [86400, 86400], - 'max': 604800 + '50%': [86400, 86400], + '80%': [604800, 604800], + 'max': 2592000, }, pips: { mode: 'values', - values: [60, 1800, 3600, 43200, 86400, 604800], + values: [60, 1800, 3600, 43200, 86400, 604800, 2592000], density: 5, format: { to: secsToText, @@ -51,12 +54,13 @@ $(function () { range: { 'min': [60, 60], '30%': [3600, 3600], - '82.80%': [86400, 86400], - 'max': 604800 + '50%': [86400, 86400], + '80%': [604800, 604800], + 'max': 2592000, }, pips: { mode: 'values', - values: [60, 1800, 3600, 43200, 86400, 604800], + values: [60, 1800, 3600, 43200, 86400, 604800, 2592000], density: 5, format: { to: secsToText, @@ -165,4 +169,4 @@ $(function () { }); -}); \ No newline at end of file +});