#89: Delete custom slides.

This commit is contained in:
Emanuel Schuetze 2012-05-18 23:24:54 +02:00
parent 90787b2597
commit f2a93c4505
4 changed files with 30 additions and 2 deletions

View File

@ -36,6 +36,11 @@ class ProjectorSlide(models.Model, SlideMixin):
'template': 'projector/ProjectorSlide.html',
}
@models.permalink
def get_absolute_url(self, link='delete'):
if link == 'delete':
return ('customslide_delete', [str(self.id)])
def __unicode__(self):
return self.title

View File

@ -14,7 +14,7 @@ from django.conf.urls.defaults import *
from utils.views import CreateView
from views import ControlView, ActivateView, CustomSlideCreateView, CustomSlideUpdateView
from views import ControlView, ActivateView, CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView
from agenda.views import ItemUpdate
from models import ProjectorSlide
@ -50,11 +50,17 @@ urlpatterns = patterns('projector.views',
CustomSlideCreateView.as_view(),
name='customslide_new',
),
url(r'^(?P<pk>\d+)/edit/$',
CustomSlideUpdateView.as_view(),
name='customslide_edit',
),
url(r'^(?P<pk>\d+)/del/$',
CustomSlideDeleteView.as_view(),
name='customslide_delete',
),
url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},
name='projector_bigger'),

View File

@ -24,7 +24,7 @@ from django.template.loader import render_to_string
from django.db.models import Q
from utils.views import TemplateView, RedirectView, CreateView, UpdateView
from utils.views import TemplateView, RedirectView, CreateView, UpdateView, DeleteView
from utils.utils import template, permission_required, \
del_confirm_form, ajax_request
from utils.template import render_block_to_string
@ -115,6 +115,7 @@ class ActivateView(RedirectView):
config['bigger'] = 100
return context
class CustomSlideCreateView(CreateView):
permission_required = 'agenda.can_manage_agenda'
template_name = 'projector/new.html'
@ -129,6 +130,7 @@ class CustomSlideCreateView(CreateView):
return reverse(self.get_apply_url(), args=[self.object.id])
return reverse(super(CreateView, self).get_success_url())
class CustomSlideUpdateView(UpdateView):
permission_required = 'projector.can_manage_projector'
template_name = 'projector/new.html'
@ -143,6 +145,18 @@ class CustomSlideUpdateView(UpdateView):
return ''
return reverse(super(UpdateView, self).get_success_url())
class CustomSlideDeleteView(DeleteView):
permission_required = 'projector.can_manage_projector'
model = ProjectorSlide
url = 'projector_control'
def pre_post_redirect(self, request, *args, **kwargs):
self.object = self.get_object()
self.object.delete()
messages.success(request, _("Custom slide <b>%s</b> was successfully deleted.") % self.object)
@permission_required('projector.can_see_projector')
def active_slide(request, sid=None):
"""

View File

@ -581,6 +581,9 @@ ul.results {
.preview {
background:url("../images/icons/preview.png") no-repeat 0px 0px;
}
.delete {
background:url("../images/icons/delete.png") no-repeat 0px 0px;
}