plannedsession_delete_view line 470
This commit is contained in:
@@ -1,32 +1,25 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "newbase.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
|
|
||||||
{% block title %}Planned Session{% endblock %}
|
{% block title %}Planned Session{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block main %}
|
||||||
<div class="grid_12 alpha">
|
|
||||||
{% include "planningbuttons.html" %}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div id="left" class="grid_6 alpha">
|
|
||||||
<h1>Confirm Delete</h1>
|
<h1>Confirm Delete</h1>
|
||||||
<p>This will permanently delete the planned session</p>
|
<p>This will permanently delete the planned session</p>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
<div class="grid_2 alpha">
|
<li class="grid_2">
|
||||||
<p>
|
<p>
|
||||||
<a class="button green small" href="/rowers/sessions/">Cancel</a>
|
<form action="" method="post">
|
||||||
</div>
|
{% csrf_token %}
|
||||||
|
<p>Are you sure you want to delete <em>{{ object }}</em>?</p>
|
||||||
<div class="grid_2">
|
<input class="button red" type="submit" value="Confirm">
|
||||||
<p>
|
</form>
|
||||||
<a class="button red small" href="/rowers/sessions/{{ ps.id }}/delete">Delete</a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</li>
|
||||||
|
|
||||||
</div>
|
<li class="grid_2">
|
||||||
<div id="right" class="grid_6 omega">
|
<h2>Session {{ psdict.name.1 }}</h2>
|
||||||
<h1>Session {{ psdict.name.1 }}</h1>
|
|
||||||
<table class="listtable shortpadded">
|
<table class="listtable shortpadded">
|
||||||
{% for attr in attrs %}
|
{% for attr in attrs %}
|
||||||
{% for key,value in psdict.items %}
|
{% for key,value in psdict.items %}
|
||||||
@@ -38,8 +31,13 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_plan.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -466,8 +466,9 @@ urlpatterns = [
|
|||||||
name='plannedsession_view'),
|
name='plannedsession_view'),
|
||||||
url(r'^sessions/(?P<id>\d+)/user/(?P<userid>\d+)$',views.plannedsession_view,
|
url(r'^sessions/(?P<id>\d+)/user/(?P<userid>\d+)$',views.plannedsession_view,
|
||||||
name='plannedsession_view'),
|
name='plannedsession_view'),
|
||||||
url(r'^sessions/(?P<id>\d+)/deleteconfirm$',views.plannedsession_deleteconfirm_view),
|
url(r'^sessions/(?P<pk>\d+)/deleteconfirm$',views.PlannedSessionDelete.as_view()),
|
||||||
url(r'^sessions/(?P<id>\d+)/delete$',views.plannedsession_delete_view),
|
url(r'^sessions/(?P<pk>\d+)/delete$',views.PlannedSessionDelete.as_view(),
|
||||||
|
name='plannedsession_delete_view'),
|
||||||
url(r'^sessions/manage/session/(?P<initialsession>\d+)$',
|
url(r'^sessions/manage/session/(?P<initialsession>\d+)$',
|
||||||
views.plannedsessions_manage_view),
|
views.plannedsessions_manage_view),
|
||||||
url(r'^sessions/manage/user/(?P<userid>\d+)/session/(?P<initialsession>\d+)$',
|
url(r'^sessions/manage/user/(?P<userid>\d+)/session/(?P<initialsession>\d+)$',
|
||||||
|
|||||||
@@ -14786,6 +14786,78 @@ def plannedsession_view(request,id=0,userid=0):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class PlannedSessionDelete(DeleteView):
|
||||||
|
model = PlannedSession
|
||||||
|
template_name = 'plannedsessiondeleteconfirm.html'
|
||||||
|
|
||||||
|
# extra parameters
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(PlannedSessionDelete,self).get_context_data(**kwargs)
|
||||||
|
|
||||||
|
if 'userid' in kwargs:
|
||||||
|
userid = kwargs['userid']
|
||||||
|
else:
|
||||||
|
userid = 0
|
||||||
|
|
||||||
|
context['active']= 'nav-plan'
|
||||||
|
context['rower'] = getrequestrower(self.request,userid=userid)
|
||||||
|
context['ps'] = self.object
|
||||||
|
|
||||||
|
psdict = my_dict_from_instance(self.object,PlannedSession)
|
||||||
|
|
||||||
|
context['psdict'] = psdict
|
||||||
|
|
||||||
|
context['attrs'] = ['name','startdate','enddate','sessiontype']
|
||||||
|
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':reverse(plannedsessions_view,
|
||||||
|
kwargs={'userid':userid}),
|
||||||
|
'name': 'Plan'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url': reverse(plannedsessions_view,
|
||||||
|
kwargs={'userid':userid}),
|
||||||
|
'name': 'Sessions'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(plannedsession_view,
|
||||||
|
kwargs={
|
||||||
|
'userid':userid,
|
||||||
|
'id':self.object.pk,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
'name': self.object.pk
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('plannedsession_delete_view',
|
||||||
|
kwargs={'pk':self.object.pk}),
|
||||||
|
'name': 'Delete'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
context['breadcrumbs'] = breadcrumbs
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
ws = Workout.objects.filter(plannedsession=self.object)
|
||||||
|
for w in ws:
|
||||||
|
w.plannedsession = None
|
||||||
|
w.save()
|
||||||
|
|
||||||
|
url = reverse(plannedsessions_view)
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
|
def get_object(self, *args, **kwargs):
|
||||||
|
obj = super(PlannedSessionDelete, self).get_object(*args, **kwargs)
|
||||||
|
m = Rower.objects.get(user=obj.manager)
|
||||||
|
if not checkaccessuser(self.request.user,m):
|
||||||
|
raise PermissionDenied('You are not allowed to delete this planned session')
|
||||||
|
|
||||||
|
return obj
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def plannedsession_delete_view(request,id=0):
|
def plannedsession_delete_view(request,id=0):
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
|
|||||||
Reference in New Issue
Block a user