#191 Create assignment-agenda Items

This commit is contained in:
Oskar Hahn 2012-06-23 10:27:58 +02:00
parent f13ee5f409
commit b12ae6b0a0
6 changed files with 38 additions and 8 deletions

View File

@ -110,6 +110,7 @@ class Item(MPTTModel, SlideMixin):
link can be:
* view
* edit
* delete
"""
if link == 'view':

View File

@ -39,7 +39,7 @@
{% block content %}
<form action="/agenda/" method="post">{% csrf_token %}
<form action="" method="post">{% csrf_token %}
{% if perms.agenda.can_manage_agenda %}
<div id="changed-order-message" style="display:none" class="notification warning">
<em>{% trans "Do you want to save the changed order of agenda items?" %}<br>

View File

@ -129,6 +129,8 @@ class Assignment(models.Model, SlideMixin):
votes.append(tmplist)
return votes
def get_agenda_title(self):
return self.name
def slide(self):
"""
@ -144,11 +146,11 @@ class Assignment(models.Model, SlideMixin):
def get_absolute_url(self, link='view'):
if link == 'view':
return reverse('assignment_view', [str(self.id)])
return reverse('assignment_view', args=(str(self.id)))
if link == 'edit':
return reverse('assignment_edit', args=[str(self.id)])
return reverse('assignment_edit', args=(str(self.id)))
if link == 'delete':
return reverse('assignment_delete', [str(self.id)])
return reverse('assignment_delete', args=(str(self.id)))
def __unicode__(self):
return self.name

View File

@ -45,6 +45,13 @@
<li><a href="{% url projector_activate_slide assignment.sid %}"><img src="{% static 'images/icons/projector.png' %}"> {%trans 'Show election' %}</a></li>
{% endif %}
{# agenda #}
{% if perms.agenda.can_manage_agenda %}
<li>
<a href="{% url assignment_create_agenda assignment.id %}">{%trans 'New agenda item' %}</a>
</li>
{% endif %}
{# polls #}
{% if perms.assignment.can_manage_assignment %}
{% for poll in polls %}

View File

@ -12,7 +12,8 @@
from django.conf.urls.defaults import *
from assignment.views import ViewPoll, AssignmentPDF, AssignmentPollPDF, AssignmentPollDelete
from assignment.views import (ViewPoll, AssignmentPDF, AssignmentPollPDF,
AssignmentPollDelete, CreateAgendaItem)
urlpatterns = patterns('assignment.views',
url(r'^$',
@ -64,12 +65,17 @@ urlpatterns = patterns('assignment.views',
name='assignment_activate_item',
),
url(r'^poll/(?P<poll_id>\d+)/print$',
url(r'^poll/(?P<poll_id>\d+)/print/$',
AssignmentPollPDF.as_view(),
name='print_assignment_poll',
),
url(r'^print$',
url(r'^(?P<assignment_id>\d+)/agenda/$',
CreateAgendaItem.as_view(),
name='assignment_create_agenda',
),
url(r'^print/$',
AssignmentPDF.as_view(),
name='print_assignment',
),

View File

@ -28,13 +28,15 @@ from settings import SITE_ROOT
from utils.utils import template, permission_required, gen_confirm_form, del_confirm_form, ajax_request
from utils.pdf import stylesheet
from utils.views import FormView, DeleteView, PDFView
from utils.views import FormView, DeleteView, PDFView, RedirectView
from utils.template import Tab
from projector.api import get_model_widget
from poll.views import PollFormView
from agenda.models import Item
from assignment.models import Assignment, AssignmentPoll, AssignmentOption
from assignment.forms import AssignmentForm, AssignmentRunForm, ConfigForm
@ -463,6 +465,18 @@ class AssignmentPDF(PDFView):
return votes
class CreateAgendaItem(RedirectView):
permission_required = 'agenda.can_manage_agenda'
def pre_redirect(self, request, *args, **kwargs):
self.assignment = Assignment.objects.get(pk=kwargs['assignment_id'])
self.item = Item(releated_sid=self.assignment.sid)
self.item.save()
def get_redirect_url(self, **kwargs):
return reverse('item_overview')
class AssignmentPollPDF(PDFView):
permission_required = 'assignment.can_manage_assignment'
top_space = 0