diff --git a/core/forms.py b/core/forms.py index 55774c21..c05dd401 100644 --- a/core/forms.py +++ b/core/forms.py @@ -132,8 +132,6 @@ class SleepForm(forms.ModelForm): class TimerForm(forms.ModelForm): - next = forms.CharField(required=False) - class Meta: model = Timer fields = ['name'] diff --git a/core/templates/core/timer_add.html b/core/templates/core/timer_add.html deleted file mode 100644 index 72276314..00000000 --- a/core/templates/core/timer_add.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
New Timer
-
-
- {% csrf_token %} - -
- - -
-
-
-
\ No newline at end of file diff --git a/core/templates/core/timer_form.html b/core/templates/core/timer_form.html new file mode 100644 index 00000000..10667414 --- /dev/null +++ b/core/templates/core/timer_form.html @@ -0,0 +1,34 @@ +{% extends 'babyblotter/page.html' %} +{% load widget_tweaks %} +{% load duration %} + +{% block title %}Timer{% endblock %} + +{% block content %} + {% if object %} +

Update {{ object }}

+ {% else %} +

Start Timer

+ {% endif %} +
+ {% csrf_token %} + {% for field in form %} +
+ + {% if field.errors %} + {{ field|add_class:"form-control is-invalid" }} + {% else %} + {{ field|add_class:"form-control" }} + {% endif %} + {% if field.help_text %} +

{{ field.help_text }}

+ {% endif %} + {% if field.errors %} +

{% for error in field.errors %}{{ error }}{% endfor %}

+ {% endif %} +
+ {% endfor %} + + Cancel +
+{% endblock %} \ No newline at end of file diff --git a/core/templatetags/timers.py b/core/templatetags/timers.py index 80810a2e..fab6e1f4 100644 --- a/core/templatetags/timers.py +++ b/core/templatetags/timers.py @@ -16,8 +16,3 @@ def timer_nav(context, active=True): perms = context['perms'] or None # The 'next' parameter is currently not used. return {'timers': timers, 'perms': perms, 'next': request.path} - - -@register.inclusion_tag('core/timer_add.html') -def add_timer(success_url): - return {'success_url': success_url} diff --git a/core/views.py b/core/views.py index 9100f122..16065216 100644 --- a/core/views.py +++ b/core/views.py @@ -165,19 +165,13 @@ class TimerAdd(PermissionRequiredMixin, CreateView): model = Timer permission_required = ('core.add_timer',) form_class = TimerForm + success_url = '/timers' def get_form_kwargs(self): kwargs = super(TimerAdd, self).get_form_kwargs() kwargs.update({'user': self.request.user}) return kwargs - def get_success_url(self): - if resolve(self.request.POST['success_url']).url_name: - url = self.request.POST['success_url'] - else: - url = '/' - return url - class TimerAddQuick(PermissionRequiredMixin, RedirectView): permission_required = ('core.add_timer',)