Add config flag for disabling option to "Clear Schedule"

I.e. when editing the schedule
This commit is contained in:
Lance Edgar 2017-02-04 12:38:08 -06:00
parent 273f56ec83
commit af415693b6
2 changed files with 8 additions and 0 deletions

View file

@ -8,6 +8,7 @@
$(function() { $(function() {
% if allow_clear:
$('.clear-schedule').click(function() { $('.clear-schedule').click(function() {
if (confirm("This will remove all shifts from the schedule you're " + if (confirm("This will remove all shifts from the schedule you're " +
"currently viewing.\n\nAre you sure you wish to do this?")) { "currently viewing.\n\nAre you sure you wish to do this?")) {
@ -16,6 +17,7 @@
$('#clear-schedule-form').submit(); $('#clear-schedule-form').submit();
} }
}); });
% endif
$('#copy-week').datepicker({ $('#copy-week').datepicker({
dateFormat: 'mm/dd/yy' dateFormat: 'mm/dd/yy'
@ -88,7 +90,9 @@
<div class="buttons"> <div class="buttons">
<button type="button" class="save-changes" disabled="disabled">Save Changes</button> <button type="button" class="save-changes" disabled="disabled">Save Changes</button>
<button type="button" class="undo-changes" disabled="disabled">Undo Changes</button> <button type="button" class="undo-changes" disabled="disabled">Undo Changes</button>
% if allow_clear:
<button type="button" class="clear-schedule">Clear Schedule</button> <button type="button" class="clear-schedule">Clear Schedule</button>
% endif
<button type="button" class="copy-schedule">Copy Schedule From...</button> <button type="button" class="copy-schedule">Copy Schedule From...</button>
</div> </div>
</%def> </%def>
@ -98,10 +102,12 @@ ${self.timesheet_wrapper(with_edit_form=True)}
${edit_tools()} ${edit_tools()}
% if allow_clear:
${h.form(url('schedule.edit'), id="clear-schedule-form")} ${h.form(url('schedule.edit'), id="clear-schedule-form")}
${h.csrf_token(request)} ${h.csrf_token(request)}
${h.hidden('clear-schedule', value='clear')} ${h.hidden('clear-schedule', value='clear')}
${h.end_form()} ${h.end_form()}
% endif
<div id="day-editor" style="display: none;"> <div id="day-editor" style="display: none;">
<div class="shifts"></div> <div class="shifts"></div>

View file

@ -121,6 +121,8 @@ class ScheduleView(TimeSheetView):
context['form'] = form context['form'] = form
context['page_title'] = "Edit Schedule" context['page_title'] = "Edit Schedule"
context['allow_clear'] = self.rattail_config.getbool('tailbone', 'schedule.allow_clear',
default=True)
return self.render_full(**context) return self.render_full(**context)
def clear_schedule(self): def clear_schedule(self):