#89: Edit custom slides.

This commit is contained in:
Emanuel Schuetze 2012-05-18 23:07:09 +02:00
parent ebe5381439
commit 90787b2597
5 changed files with 45 additions and 19 deletions

View File

@ -25,7 +25,7 @@ from utils.translation_ext import ugettext as _
class ProjectorSlide(models.Model, SlideMixin):
prefix = 'ProjectorSlide'
title = models.CharField(max_length=100, verbose_name=_("Title"))
title = models.CharField(max_length=256, verbose_name=_("Title"))
text = models.TextField(null=True, blank=True, verbose_name=_("Text"))
#weight = models.IntegerField(default=0, verbose_name=_("Weight"))
@ -57,7 +57,7 @@ class ProjectorOverlay(models.Model):
return self.def_name
register_slidemodel(ProjectorSlide, model_name='customslide')
register_slidemodel(ProjectorSlide, control_template='projector/control_customslide.html')
@receiver(default_config_value, dispatch_uid="projector_default_config")

View File

@ -259,8 +259,8 @@
<hr>
{% endif %}
{% endfor %}
<a href='{% url custom_slides_new %}'>
<button class="button" type="button" onclick="window.location='{% url custom_slides_new %}'">
<a href='{% url customslide_new %}'>
<button class="button" type="button" onclick="window.location='{% url customslide_new %}'">
<span class="icon add">{%trans 'New slide' %}</span>
</button>
</a>

View File

@ -3,10 +3,10 @@
{% load tags %}
{% load i18n %}
{% block title %}{{ block.super }} {%trans "New custom slide" %}{% endblock %}
{% block title %}{{ block.super }} {%trans "Custom slide" %}{% endblock %}
{% block content %}
<h1>{% trans 'New custom slide' %}</h1>
<h1>{% trans 'Custom slide' %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button class="button" type="submit">
@ -15,11 +15,10 @@
<button class="button" type="submit" name="apply">
<span class="icon apply">{%trans 'Apply' %}</span>
</button>
<a href='{% url item_overview %}'>
<button class="button" type="button" onclick="window.location='{% url item_overview %}'">
<a href='{% url projector_control %}'>
<button class="button" type="button" onclick="window.location='{% url projector_control %}'">
<span class="icon cancel">{%trans 'Cancel' %}</span>
</button>
</a>
</form>
{% endblock %}

View File

@ -14,7 +14,7 @@ from django.conf.urls.defaults import *
from utils.views import CreateView
from views import ControlView, ActivateView
from views import ControlView, ActivateView, CustomSlideCreateView, CustomSlideUpdateView
from agenda.views import ItemUpdate
from models import ProjectorSlide
@ -47,13 +47,12 @@ urlpatterns = patterns('projector.views',
),
url(r'^new/$',
CreateView.as_view(
success_url='projector_control',
model=ProjectorSlide,
template_name='projector/new.html',
permission_required='projector.can_manage_projector'
CustomSlideCreateView.as_view(),
name='customslide_new',
),
name='custom_slides_new',
url(r'^(?P<pk>\d+)/edit/$',
CustomSlideUpdateView.as_view(),
name='customslide_edit',
),
url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},

View File

@ -13,6 +13,7 @@
from datetime import datetime
from time import time
from django.contrib import messages
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.core.urlresolvers import reverse
@ -23,7 +24,7 @@ from django.template.loader import render_to_string
from django.db.models import Q
from utils.views import TemplateView, RedirectView
from utils.views import TemplateView, RedirectView, CreateView, UpdateView
from utils.utils import template, permission_required, \
del_confirm_form, ajax_request
from utils.template import render_block_to_string
@ -33,7 +34,7 @@ from config.models import config
from api import get_active_slide, set_active_slide, projector_message_set, projector_message_delete, get_slide_from_sid
from projector import SLIDE
from models import ProjectorOverlay
from models import ProjectorOverlay, ProjectorSlide
from openslides.projector.signals import projector_overlays, projector_control_box
from openslides.utils.signals import template_manipulation
@ -114,6 +115,33 @@ class ActivateView(RedirectView):
config['bigger'] = 100
return context
class CustomSlideCreateView(CreateView):
permission_required = 'agenda.can_manage_agenda'
template_name = 'projector/new.html'
model = ProjectorSlide
context_object_name = 'customslide'
success_url = 'projector_control'
apply_url = 'customslide_edit'
def get_success_url(self):
messages.success(self.request, _("Custom slide <b>%s</b> was successfully created.") % self.request.POST['title'])
if 'apply' in self.request.POST:
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'
model = ProjectorSlide
context_object_name = 'customslide'
success_url = 'projector_control'
apply_url = 'customslide_edit'
def get_success_url(self):
messages.success(self.request, _("Custom slide <b>%s</b> was successfully modified.") % self.request.POST['title'])
if 'apply' in self.request.POST:
return ''
return reverse(super(UpdateView, self).get_success_url())
@permission_required('projector.can_see_projector')
def active_slide(request, sid=None):