edit, delete, slide for releated item in agenda

This commit is contained in:
Oskar Hahn 2012-06-03 09:35:26 +02:00
parent 79893687f3
commit 965b682abc
5 changed files with 27 additions and 22 deletions

View File

@ -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()

View File

@ -1,5 +1,6 @@
{% load i18n %}
{% load staticfiles %}
{% load tags %}
<td>
{% if perms.agenda.can_manage_agenda %}
@ -17,10 +18,9 @@
{% if perms.agenda.can_manage_agenda %}
<div class="dragcell"></div>
{% endif %}
{% if item.text %}
<a href="{{ item.get_absolute_url }}">{{ item }}</a>
{% else %}
{{ item }}
{% if item.releated_sid %}
({{ item.get_releated_type }})
{% endif %}
</td>
{% if perms.agenda.can_manage_agenda %}
@ -37,8 +37,8 @@
</a>
{% endif %}
{% if perms.agenda.can_manage_agenda %}
<a href="{% url item_edit item.id %}"><img src="{% static 'images/icons/edit.png' %}" title="{% trans 'Edit item' %}"></a>
<a href="{% url item_delete item.id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Delete item' %}"></a>
<a href="{% model_url item 'edit' %}"><img src="{% static 'images/icons/edit.png' %}" title="{% trans 'Edit item' %}"></a>
<a href="{% model_url item 'delete' %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Delete item' %}"></a>
{% endif %}
</span>
</td>

View File

@ -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:

View File

@ -204,8 +204,8 @@
<img src="{% static 'images/icons/document-save.png' %}" />
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="projector_countdown_btn" href="{% url countdown_reset %}" title="{% trans 'Reset countdown' %}" onclick="javascript:switchButtons('play')"><button
type="submit" class="button" style="padding:4px;" name='message-clean'>
<a class="projector_countdown_btn" href="{% url countdown_reset %}" title="{% trans 'Reset countdown' %}" onclick="javascript:switchButtons('play')">
<button type="submit" class="button" style="padding:4px;" name='message-clean'>
<span class="icon backward">&nbsp;</span>
</button></a>&nbsp;
<a id="countdown_play" class="projector_countdown_btn" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}" onclick="javascript:switchButtons('stop')"><button

View File

@ -30,3 +30,7 @@ def active(request, pattern):
if request.path.startswith(pattern):
return 'selected'
return ''
@register.simple_tag
def model_url(object, link='view'):
return object.get_absolute_url(link)