From 965b682abc532e87221629082327eb20bd1beeca Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 3 Jun 2012 09:35:26 +0200 Subject: [PATCH] edit, delete, slide for releated item in agenda --- openslides/agenda/models.py | 21 +++++++++++-------- .../agenda/templates/agenda/item_row.html | 10 ++++----- openslides/application/models.py | 10 ++++----- .../templates/projector/control.html | 4 ++-- openslides/utils/templatetags/tags.py | 4 ++++ 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index f7e16c565..d37241925 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -16,6 +16,7 @@ except ImportError: import simplejson as json from django.db import models +from django.core.urlresolvers import reverse from mptt.models import MPTTModel, TreeForeignKey @@ -46,21 +47,20 @@ class Item(MPTTModel, SlideMixin): def get_releated_slide(self): return get_slide_from_sid(self.releated_sid, True) + def get_releated_type(self): + return self.get_releated_slide().prefix + def get_title(self): if self.releated_sid is None: return self.title return self.get_releated_slide().get_agenda_title() - def get_text(self): - if self.releated_sid is None: - return self.text - return self.get_releated_slide().get_agenda_text() - - def slide(self): """ Return a map with all Data for the Slide """ + if self.releated_sid: + return self.get_releated_slide().slide() data = { 'item': self, 'title': self.get_title(), @@ -103,7 +103,6 @@ class Item(MPTTModel, SlideMixin): } return ItemOrderForm(initial=initial, prefix="i%d" % self.id) - @models.permalink def get_absolute_url(self, link='view'): """ Return the URL to this item. By default it is the Link to its @@ -113,10 +112,14 @@ class Item(MPTTModel, SlideMixin): * view * delete """ + if self.releated_sid: + return self.get_releated_slide().get_absolute_url(link) if link == 'view': - return ('item_view', [str(self.id)]) + return reverse('item_view', args=[str(self.id)]) + if link == 'edit': + return reverse('item_edit', args=[str(self.id)]) if link == 'delete': - return ('item_delete', [str(self.id)]) + return reverse('item_delete', args=[str(self.id)]) def __unicode__(self): return self.get_title() diff --git a/openslides/agenda/templates/agenda/item_row.html b/openslides/agenda/templates/agenda/item_row.html index 2a4ca93c7..cfd0eb165 100644 --- a/openslides/agenda/templates/agenda/item_row.html +++ b/openslides/agenda/templates/agenda/item_row.html @@ -1,5 +1,6 @@ {% load i18n %} {% load staticfiles %} +{% load tags %} {% if perms.agenda.can_manage_agenda %} @@ -17,10 +18,9 @@ {% if perms.agenda.can_manage_agenda %}
{% endif %} - {% if item.text %} {{ item }} - {% else %} - {{ item }} + {% if item.releated_sid %} + ({{ item.get_releated_type }}) {% endif %} {% if perms.agenda.can_manage_agenda %} @@ -37,8 +37,8 @@ {% endif %} {% if perms.agenda.can_manage_agenda %} - - + + {% endif %} diff --git a/openslides/application/models.py b/openslides/application/models.py index 4d0632b3d..56c69fc28 100644 --- a/openslides/application/models.py +++ b/openslides/application/models.py @@ -423,9 +423,6 @@ class Application(models.Model, SlideMixin): def get_agenda_title(self): return self.title - def get_agenda_text(self): - return 'TODO' - def __getattr__(self, name): """ if name is title, text, reason or time, @@ -482,12 +479,13 @@ class Application(models.Model, SlideMixin): data['template'] = 'projector/Application.html' return data - @models.permalink def get_absolute_url(self, link='view'): if link == 'view': - return ('application_view', [str(self.id)]) + return reverse('application_view', args=[str(self.id)]) + if link == 'edit': + return reverse('application_edit', args=[str(self.id)]) if link == 'delete': - return ('application_delete', [str(self.id)]) + return reverse('application_delete', args=[str(self.id)]) def __unicode__(self): try: diff --git a/openslides/projector/templates/projector/control.html b/openslides/projector/templates/projector/control.html index 43b97095f..512efb59d 100644 --- a/openslides/projector/templates/projector/control.html +++ b/openslides/projector/templates/projector/control.html @@ -204,8 +204,8 @@        -