edit, delete, slide for releated item in agenda
This commit is contained in:
parent
79893687f3
commit
965b682abc
@ -16,6 +16,7 @@ except ImportError:
|
|||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from mptt.models import MPTTModel, TreeForeignKey
|
from mptt.models import MPTTModel, TreeForeignKey
|
||||||
|
|
||||||
@ -46,21 +47,20 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
def get_releated_slide(self):
|
def get_releated_slide(self):
|
||||||
return get_slide_from_sid(self.releated_sid, True)
|
return get_slide_from_sid(self.releated_sid, True)
|
||||||
|
|
||||||
|
def get_releated_type(self):
|
||||||
|
return self.get_releated_slide().prefix
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
if self.releated_sid is None:
|
if self.releated_sid is None:
|
||||||
return self.title
|
return self.title
|
||||||
return self.get_releated_slide().get_agenda_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):
|
def slide(self):
|
||||||
"""
|
"""
|
||||||
Return a map with all Data for the Slide
|
Return a map with all Data for the Slide
|
||||||
"""
|
"""
|
||||||
|
if self.releated_sid:
|
||||||
|
return self.get_releated_slide().slide()
|
||||||
data = {
|
data = {
|
||||||
'item': self,
|
'item': self,
|
||||||
'title': self.get_title(),
|
'title': self.get_title(),
|
||||||
@ -103,7 +103,6 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
}
|
}
|
||||||
return ItemOrderForm(initial=initial, prefix="i%d" % self.id)
|
return ItemOrderForm(initial=initial, prefix="i%d" % self.id)
|
||||||
|
|
||||||
@models.permalink
|
|
||||||
def get_absolute_url(self, link='view'):
|
def get_absolute_url(self, link='view'):
|
||||||
"""
|
"""
|
||||||
Return the URL to this item. By default it is the Link to its
|
Return the URL to this item. By default it is the Link to its
|
||||||
@ -113,10 +112,14 @@ class Item(MPTTModel, SlideMixin):
|
|||||||
* view
|
* view
|
||||||
* delete
|
* delete
|
||||||
"""
|
"""
|
||||||
|
if self.releated_sid:
|
||||||
|
return self.get_releated_slide().get_absolute_url(link)
|
||||||
if link == 'view':
|
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':
|
if link == 'delete':
|
||||||
return ('item_delete', [str(self.id)])
|
return reverse('item_delete', args=[str(self.id)])
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.get_title()
|
return self.get_title()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
|
{% load tags %}
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% if perms.agenda.can_manage_agenda %}
|
{% if perms.agenda.can_manage_agenda %}
|
||||||
@ -17,10 +18,9 @@
|
|||||||
{% if perms.agenda.can_manage_agenda %}
|
{% if perms.agenda.can_manage_agenda %}
|
||||||
<div class="dragcell"></div>
|
<div class="dragcell"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.text %}
|
|
||||||
<a href="{{ item.get_absolute_url }}">{{ item }}</a>
|
<a href="{{ item.get_absolute_url }}">{{ item }}</a>
|
||||||
{% else %}
|
{% if item.releated_sid %}
|
||||||
{{ item }}
|
({{ item.get_releated_type }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if perms.agenda.can_manage_agenda %}
|
{% if perms.agenda.can_manage_agenda %}
|
||||||
@ -37,8 +37,8 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.agenda.can_manage_agenda %}
|
{% 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="{% model_url item 'edit' %}"><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 'delete' %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Delete item' %}"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
@ -423,9 +423,6 @@ class Application(models.Model, SlideMixin):
|
|||||||
def get_agenda_title(self):
|
def get_agenda_title(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
def get_agenda_text(self):
|
|
||||||
return 'TODO'
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""
|
"""
|
||||||
if name is title, text, reason or time,
|
if name is title, text, reason or time,
|
||||||
@ -482,12 +479,13 @@ class Application(models.Model, SlideMixin):
|
|||||||
data['template'] = 'projector/Application.html'
|
data['template'] = 'projector/Application.html'
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@models.permalink
|
|
||||||
def get_absolute_url(self, link='view'):
|
def get_absolute_url(self, link='view'):
|
||||||
if 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':
|
if link == 'delete':
|
||||||
return ('application_delete', [str(self.id)])
|
return reverse('application_delete', args=[str(self.id)])
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -204,8 +204,8 @@
|
|||||||
<img src="{% static 'images/icons/document-save.png' %}" />
|
<img src="{% static 'images/icons/document-save.png' %}" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="projector_countdown_btn" href="{% url countdown_reset %}" title="{% trans 'Reset countdown' %}" onclick="javascript:switchButtons('play')"><button
|
<a class="projector_countdown_btn" href="{% url countdown_reset %}" title="{% trans 'Reset countdown' %}" onclick="javascript:switchButtons('play')">
|
||||||
type="submit" class="button" style="padding:4px;" name='message-clean'>
|
<button type="submit" class="button" style="padding:4px;" name='message-clean'>
|
||||||
<span class="icon backward"> </span>
|
<span class="icon backward"> </span>
|
||||||
</button></a>
|
</button></a>
|
||||||
<a id="countdown_play" class="projector_countdown_btn" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}" onclick="javascript:switchButtons('stop')"><button
|
<a id="countdown_play" class="projector_countdown_btn" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}" onclick="javascript:switchButtons('stop')"><button
|
||||||
|
@ -30,3 +30,7 @@ def active(request, pattern):
|
|||||||
if request.path.startswith(pattern):
|
if request.path.startswith(pattern):
|
||||||
return 'selected'
|
return 'selected'
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def model_url(object, link='view'):
|
||||||
|
return object.get_absolute_url(link)
|
||||||
|
Loading…
Reference in New Issue
Block a user