From f2a93c450575ebb387e8fbc68cd5cd0c107a1d03 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 18 May 2012 23:24:54 +0200 Subject: [PATCH] #89: Delete custom slides. --- openslides/projector/models.py | 5 +++++ openslides/projector/urls.py | 8 +++++++- openslides/projector/views.py | 16 +++++++++++++++- openslides/static/styles/base.css | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/openslides/projector/models.py b/openslides/projector/models.py index c9bf3725e..4853baf7d 100644 --- a/openslides/projector/models.py +++ b/openslides/projector/models.py @@ -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 diff --git a/openslides/projector/urls.py b/openslides/projector/urls.py index 3385ffcc6..460124915 100644 --- a/openslides/projector/urls.py +++ b/openslides/projector/urls.py @@ -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\d+)/edit/$', CustomSlideUpdateView.as_view(), name='customslide_edit', ), + url(r'^(?P\d+)/del/$', + CustomSlideDeleteView.as_view(), + name='customslide_delete', + ), + url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'}, name='projector_bigger'), diff --git a/openslides/projector/views.py b/openslides/projector/views.py index f008c32a6..be4a4f2f2 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -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 %s was successfully deleted.") % self.object) + + @permission_required('projector.can_see_projector') def active_slide(request, sid=None): """ diff --git a/openslides/static/styles/base.css b/openslides/static/styles/base.css index 0344e6602..1a94e9020 100644 --- a/openslides/static/styles/base.css +++ b/openslides/static/styles/base.css @@ -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; +}