Added motion widget and deletion of motions

This commit is contained in:
Oskar Hahn 2013-02-02 00:27:16 +01:00
parent 0f7d0e349c
commit 1518543a9a
6 changed files with 69 additions and 2 deletions

View File

@ -1 +1,3 @@
import openslides.motion.signals
import openslides.motion.slides

View File

@ -54,7 +54,7 @@ class Motion(SlideMixin, models.Model):
"""
The Motion-Model.
"""
prefix = "motion" # Rename this in the slide-system
prefix = "motion"
# TODO: Use this attribute for the default_version, if the permission system
# is deactivated. Maybe it has to be renamed.
@ -278,7 +278,10 @@ class Motion(SlideMixin, models.Model):
"""
Get the state of this motion. Return a State object.
"""
return get_state(self.state_id)
try:
return get_state(self.state_id)
except WorkflowError:
return None
def set_state(self, next_state):
"""

View File

@ -0,0 +1,4 @@
from openslides.projector.api import register_slidemodel
from .models import Motion
register_slidemodel(Motion)

View File

@ -0,0 +1,34 @@
{% load staticfiles %}
{% load i18n %}
{% load tags %}
<ul style="line-height: 180%">
{% for motion in motions %}
<li class="{% if motion.active %}activeline{% endif %}">
<a href="{% url 'projector_activate_slide' motion.sid %}" class="activate_link {% if motion.active %}active{% endif %}">
<div></div>
</a>
<a href="{% model_url motion 'delete' %}" title="{% trans 'Delete' %}" class="icon delete right">
<span></span>
</a>
<a href="{% model_url motion 'edit' %}" title="{% trans 'Edit' %}" class="icon edit right">
<span></span>
</a>
<a href="{% url 'projctor_preview_slide' motion.sid %}" title="{% trans 'Preview' %}" class="icon preview right">
<span></span>
</a>
<a href="{% model_url motion 'view' %}">
{{ motion.public_version.title }}
</a>
({% trans "motion" %}
{% if motion.number %}
{{ motion.number }})
{% else %}
<i>[{% trans "no number" %}]</i>)
{% endif %}
</li>
{% empty %}
<li>{% trans 'No motion available.' %}</li>
{% endfor %}
</ul>

View File

@ -33,6 +33,11 @@ urlpatterns = patterns('openslides.motion.views',
name='motion_edit',
),
url(r'^(?P<pk>\d+)/del/$',
'motion_delete',
name='motion_delete',
),
url(r'^(?P<pk>\d+)/version/(?P<version_id>[1-9]\d*)/$',
'motion_detail',
name='motion_version_detail',

View File

@ -125,6 +125,17 @@ class MotionUpdateView(MotionMixin, UpdateView):
motion_edit = MotionUpdateView.as_view()
class MotionDeleteView(DeleteView):
"""
Delete one Motion.
"""
model = Motion
success_url_name = 'motion_list'
# TODO: Check permissions
motion_delete = MotionDeleteView.as_view()
class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
"""
Classed based view to support or unsupport a motion. Use
@ -304,3 +315,11 @@ def register_tab(request):
permission=request.user.has_perm('motion.can_see_motion'),
selected=selected,
)
def get_widgets(request):
return [Widget(
name='motions',
display_name=_('Motions'),
template='motion/widget.html',
context={'motions': Motion.objects.all()},
permission_required='projector.can_manage_projector')]