mirror of https://github.com/snachodog/mybuddy.git
Add timer delete functionality and move template back in to core.
This commit is contained in:
parent
8cb2c171f2
commit
a51d9e4c83
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends 'babyblotter/page.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
{% block title %}Delete {{ object }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<form role="form" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>
|
||||||
|
<input type="submit" value="Delete" class="btn btn-danger" />
|
||||||
|
<a href="/" class="btn btn-default">Cancel</a>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
|
@ -16,7 +16,7 @@
|
||||||
href="{% url 'tummytime-add' %}?timer={{ timer.id }}"
|
href="{% url 'tummytime-add' %}?timer={{ timer.id }}"
|
||||||
role="button"><i class="fa fa-smile-o" aria-hidden="true"></i> Tummy Time</a>
|
role="button"><i class="fa fa-smile-o" aria-hidden="true"></i> Tummy Time</a>
|
||||||
<a class="btn btn-danger btn-lg btn-block p-3 mb-3"
|
<a class="btn btn-danger btn-lg btn-block p-3 mb-3"
|
||||||
href="#"
|
href="{% url 'timer-delete' timer.id %}"
|
||||||
role="button"><i class="fa fa-times-circle" aria-hidden="true"></i> Delete Timer</a>
|
role="button"><i class="fa fa-times-circle" aria-hidden="true"></i> Delete Timer</a>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -9,14 +9,14 @@ from core.models import Timer
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('timer_list.html', takes_context=True)
|
@register.inclusion_tag('core/timer_list.html', takes_context=True)
|
||||||
def list_timers(context, active=True):
|
def list_timers(context, active=True):
|
||||||
request = context['request'] or None
|
request = context['request'] or None
|
||||||
timers = Timer.objects.filter(user=request.user, active=active)
|
timers = Timer.objects.filter(user=request.user, active=active)
|
||||||
return {'timers': timers}
|
return {'timers': timers}
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('timer_nav.html', takes_context=True)
|
@register.inclusion_tag('core/timer_nav.html', takes_context=True)
|
||||||
def timer_nav(context, active=True):
|
def timer_nav(context, active=True):
|
||||||
request = context['request'] or None
|
request = context['request'] or None
|
||||||
timers = Timer.objects.filter(user=request.user, active=active)
|
timers = Timer.objects.filter(user=request.user, active=active)
|
||||||
|
@ -25,7 +25,7 @@ def timer_nav(context, active=True):
|
||||||
return {'timers': timers, 'perms': perms, 'next': request.path}
|
return {'timers': timers, 'perms': perms, 'next': request.path}
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('timer_add.html')
|
@register.inclusion_tag('core/timer_add.html')
|
||||||
def add_timer(success_url):
|
def add_timer(success_url):
|
||||||
return {'success_url': success_url}
|
return {'success_url': success_url}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ urlpatterns = [
|
||||||
name='timer-add-quick'),
|
name='timer-add-quick'),
|
||||||
url(r'timer/(?P<pk>[0-9]+)/$', views.TimerDetail.as_view(),
|
url(r'timer/(?P<pk>[0-9]+)/$', views.TimerDetail.as_view(),
|
||||||
name='timer-detail'),
|
name='timer-detail'),
|
||||||
|
url(r'timer/(?P<pk>[0-9]+)/delete/$', views.TimerDelete.as_view(),
|
||||||
|
name='timer-delete'),
|
||||||
|
|
||||||
url(r'tummy-time/$', views.TummyTimeList.as_view(), name='tummytime-list'),
|
url(r'tummy-time/$', views.TummyTimeList.as_view(), name='tummytime-list'),
|
||||||
url(r'tummy-time/add/$', views.TummyTimeAdd.as_view(),
|
url(r'tummy-time/add/$', views.TummyTimeAdd.as_view(),
|
||||||
|
|
|
@ -158,7 +158,6 @@ class SleepDelete(PermissionRequiredMixin, DeleteView):
|
||||||
|
|
||||||
class TimerDetail(PermissionRequiredMixin, DetailView):
|
class TimerDetail(PermissionRequiredMixin, DetailView):
|
||||||
model = Timer
|
model = Timer
|
||||||
template_name = 'timer_detail.html' # To be consistent w/Timer templates.
|
|
||||||
permission_required = ('core.view_timer',)
|
permission_required = ('core.view_timer',)
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,6 +190,12 @@ class TimerAddQuick(PermissionRequiredMixin, RedirectView):
|
||||||
return super(TimerAddQuick, self).get(request, *args, **kwargs)
|
return super(TimerAddQuick, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class TimerDelete(PermissionRequiredMixin, DeleteView):
|
||||||
|
model = Timer
|
||||||
|
permission_required = ('core.delete_timer',)
|
||||||
|
success_url = '/'
|
||||||
|
|
||||||
|
|
||||||
class TummyTimeList(PermissionRequiredMixin, ListView):
|
class TummyTimeList(PermissionRequiredMixin, ListView):
|
||||||
model = TummyTime
|
model = TummyTime
|
||||||
permission_required = ('core.view_tummytime',)
|
permission_required = ('core.view_tummytime',)
|
||||||
|
@ -211,10 +216,12 @@ class TummyTimeAdd(PermissionRequiredMixin, CreateView):
|
||||||
|
|
||||||
class TummyTimeUpdate(PermissionRequiredMixin, UpdateView):
|
class TummyTimeUpdate(PermissionRequiredMixin, UpdateView):
|
||||||
model = TummyTime
|
model = TummyTime
|
||||||
|
permission_required = ('core.change_tummytime',)
|
||||||
form_class = TummyTimeForm
|
form_class = TummyTimeForm
|
||||||
success_url = '/tummy-time'
|
success_url = '/tummy-time'
|
||||||
|
|
||||||
|
|
||||||
class TummyTimeDelete(PermissionRequiredMixin, DeleteView):
|
class TummyTimeDelete(PermissionRequiredMixin, DeleteView):
|
||||||
model = TummyTime
|
model = TummyTime
|
||||||
|
permission_required = ('core.delete_tummytime',)
|
||||||
success_url = '/tummy-time'
|
success_url = '/tummy-time'
|
||||||
|
|
Loading…
Reference in New Issue