Skip to content

Commit

Permalink
Make scheduler more flexible
Browse files Browse the repository at this point in the history
Schedules can now be set for any aribtary group of days of the week.

Sorry about the css; I couldnt work out where the un-minified version
lived.
  • Loading branch information
lparry committed Jun 5, 2012
1 parent b73570f commit 2da3701
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 51 deletions.
18 changes: 8 additions & 10 deletions interfaces/Classic/templates/config_scheduling.tmpl
Expand Up @@ -31,16 +31,14 @@ $T('hour'):<br>
<!--#end for#-->
</select>
<br>$T('sch-frequency'): <br>
<select name="dayofweek">
<option value="*" selected>$T('daily')
<option value="1">$T('monday')
<option value="2">$T('tuesday')
<option value="3">$T('wednesday')
<option value="4">$T('thursday')
<option value="5">$T('friday')
<option value="6">$T('saturday')
<option value="7">$T('sunday')
</select>
<input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
<input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
<input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
<input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
<input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
<input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
<input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>

<br>$T('sch-action'):<br>
<select name="action">
<!--#for $action in $actions#-->
Expand Down
21 changes: 10 additions & 11 deletions interfaces/Config/templates/config_scheduling.tmpl
Expand Up @@ -34,17 +34,16 @@ else:
</select>
</div>
<div class="field-pair">
<label class="config" for="dayofweek">$T('sch-frequency')</label>
<select name="dayofweek" id="dayofweek">
<option value="*" selected="selected">$T('daily')</option>
<option value="1">$T('monday')</option>
<option value="2">$T('tuesday')</option>
<option value="3">$T('wednesday')</option>
<option value="4">$T('thursday')</option>
<option value="5">$T('friday')</option>
<option value="6">$T('saturday')</option>
<option value="7">$T('sunday')</option>
</select>
<label class="config" for="daysofweek">$T('sch-frequency')</label>
<div class="checkbox-days">
<p><input type="checkbox" name="daysofweek" value="1"><label>$T('monday')</label></p>
<p><input type="checkbox" name="daysofweek" value="2"><label>$T('tuesday')</label></p>
<p><input type="checkbox" name="daysofweek" value="3"><label>$T('wednesday')</label></p>
<p><input type="checkbox" name="daysofweek" value="4"><label>$T('thursday')</label></p>
<p><input type="checkbox" name="daysofweek" value="5"><label>$T('friday')</label></p>
<p><input type="checkbox" name="daysofweek" value="6"><label>$T('saturday')</label></p>
<p><input type="checkbox" name="daysofweek" value="7"><label>$T('sunday')</label></p>
</div>
</div>
<div class="field-pair alt">
<label class="config" for="action">$T('sch-action')</label>
Expand Down
6 changes: 5 additions & 1 deletion interfaces/Config/templates/staticcfg/css/style.css

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions interfaces/Plush/templates/config_scheduling.tmpl
Expand Up @@ -36,18 +36,15 @@ else:
</label>
</div>
<div class="field-pair alt">
<label class="nocheck clearfix" for="dayofweek">
<label class="nocheck clearfix" for="daysofweek">
<span class="component-title">$T('sch-frequency')</span>
<select name="dayofweek" id="dayofweek">
<option value="*" selected>$T('daily')</option>
<option value="1">$T('monday')</option>
<option value="2">$T('tuesday')</option>
<option value="3">$T('wednesday')</option>
<option value="4">$T('thursday')</option>
<option value="5">$T('friday')</option>
<option value="6">$T('saturday')</option>
<option value="7">$T('sunday')</option>
</select>
<input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
<input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
<input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
<input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
<input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
<input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
<input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>
</label>
</div>
<div class="field-pair">
Expand Down
19 changes: 8 additions & 11 deletions interfaces/smpl/templates/config_scheduling.tmpl
Expand Up @@ -26,17 +26,14 @@ else:
<!--#end for#-->
</select>
<br class="clear" />
<label class="label">$T('sch-frequency'):</label>
<select name="dayofweek">
<option value="*" selected>$T('daily')
<option value="1">$T('monday')
<option value="2">$T('tuesday')
<option value="3">$T('wednesday')
<option value="4">$T('thursday')
<option value="5">$T('friday')
<option value="6">$T('saturday')
<option value="7">$T('sunday')
</select>
<label class="label" for="daysofweek">$T('sch-frequency'):</label>
<input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
<input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
<input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
<input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
<input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
<input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
<input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>
<br class="clear" />
<label class="label">$T('sch-action'):</label>
<select name="action">
Expand Down
15 changes: 9 additions & 6 deletions sabnzbd/interface.py
Expand Up @@ -1901,15 +1901,15 @@ def get_days():

actions = []
actions.extend(_SCHED_ACTIONS)
days = get_days()
day_names = get_days()
conf['schedlines'] = []
snum = 1
conf['taskinfo'] = []
for ev in scheduler.sort_schedules(forward=True):
line = ev[3]
conf['schedlines'].append(line)
try:
m, h, day, action = line.split(' ', 3)
m, h, day_numbers, action = line.split(' ', 3)
except:
continue
action = action.strip()
Expand All @@ -1929,7 +1929,10 @@ def get_days():
act = ''
if act in ('enable_server', 'disable_server'):
action = Ttemplate("sch-" + act) + ' ' + server
item = (snum, '%02d' % int(h), '%02d' % int(m), days.get(day, '**'), '%s %s' % (action, value))

days_of_week = ", ".join([day_names.get(i, "**") for i in day_numbers])
item = (snum, '%02d' % int(h), '%02d' % int(m), days_of_week, '%s %s' % (action, value))

conf['taskinfo'].append(item)
snum += 1

Expand All @@ -1954,7 +1957,7 @@ def addSchedule(self, **kwargs):

minute = kwargs.get('minute')
hour = kwargs.get('hour')
dayofweek = kwargs.get('dayofweek')
days_of_week = ''.join([str(x) for x in kwargs.get('daysofweek')])
action = kwargs.get('action')
arguments = kwargs.get('arguments')

Expand All @@ -1964,7 +1967,7 @@ def addSchedule(self, **kwargs):
elif arguments in ('off','disable'):
arguments = '0'

if minute and hour and dayofweek and action:
if minute and hour and days_of_week and action:
if action == 'speedlimit':
if not (arguments and arguments.isdigit()):
action = '0'
Expand All @@ -1983,7 +1986,7 @@ def addSchedule(self, **kwargs):
if action:
sched = cfg.schedules()
sched.append('%s %s %s %s %s' %
(minute, hour, dayofweek, action, arguments))
(minute, hour, days_of_week, action, arguments))
cfg.schedules.set(sched)

config.save_config()
Expand Down
2 changes: 1 addition & 1 deletion sabnzbd/scheduler.py
Expand Up @@ -82,7 +82,7 @@ def init():
continue

if d.isdigit():
d = [int(d)]
d = [int(i) for i in d]
else:
d = range(1, 8)

Expand Down

2 comments on commit 2da3701

@thezoggy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just provide me the css and i can runt he build script to make it all nice and pretty

@lparry
Copy link
Owner Author

@lparry lparry commented on 2da3701 Jun 5, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just those 4 lines at the bottom, the extra line shows up in the diff because of the extra newline on the end.

.checkbox-days{float: left}
.checkbox-days p{margin: 0 0 5px 0}
.checkbox-days input {vertical-align:middle; margin-top: -1px;}
.checkbox-days label{padding-left: 20px}

I'm no css wizard so I'm happy to concede there's probably a better way to style this

Please sign in to comment.