Browse Source

Extend to month.

pull/60/head
Justin Huang 9 years ago
committed by Pēteris Caune
parent
commit
1fe12d46fc
3 changed files with 20 additions and 12 deletions
  1. +2
    -2
      hc/front/forms.py
  2. +5
    -1
      hc/front/templatetags/hc_extras.py
  3. +13
    -9
      static/js/checks.js

+ 2
- 2
hc/front/forms.py View File

@ -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):


+ 5
- 1
hc/front/templatetags/hc_extras.py View File

@ -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


+ 13
- 9
static/js/checks.js View File

@ -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 () {
});
});
});

Loading…
Cancel
Save