Fix appearance of agenda items with related sid, also some other small fixes and template fixes

This commit is contained in:
Norman Jäckel 2013-05-24 00:31:52 +02:00
parent ff183c03a3
commit 00910b218e
6 changed files with 34 additions and 26 deletions

View File

@ -111,21 +111,19 @@ class Item(MPTTModel, SlideMixin):
def __unicode__(self):
return self.get_title()
def get_absolute_url(self, link='view'):
def get_absolute_url(self, link='detail'):
"""
Return the URL to this item. By default it is the link to its
view or the view of a related object.
The link can be:
* view
* edit
* detail or view
* update or edit
* delete
"""
if link == 'view':
if self.related_sid:
return self.get_related_slide().get_absolute_url(link)
if link == 'detail' or link == 'view':
return reverse('item_view', args=[str(self.id)])
if link == 'edit':
if link == 'update' or link == 'edit':
if self.related_sid:
return self.get_related_slide().get_absolute_url(link)
return reverse('item_edit', args=[str(self.id)])
@ -139,7 +137,7 @@ class Item(MPTTModel, SlideMixin):
# TODO: Rename it to 'get_related_object'
object = get_slide_from_sid(self.related_sid, element=True)
if object is None:
self.title = 'Item for deleted slide: %s' % self.related_sid
self.title = _('Item for deleted slide %s') % self.related_sid
self.related_sid = None
self.save()
return self

View File

@ -4,7 +4,7 @@
{% load tags %}
{% load staticfiles %}
{% block title %}{{ block.super }} {{ item.title }}{% endblock %}
{% block title %}{{ block.super }} {{ item }}{% endblock %}
{% block header %}
<link type="text/css" rel="stylesheet" media="all" href="{% static 'styles/agenda.css' %}" />
@ -36,15 +36,21 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="{% url 'item_edit' item.id %}"><i class="icon-pencil"></i> {% trans 'Edit item' %}</a></li>
<li><a href="{% url 'item_delete' item.id %}"><i class="icon-remove"></i> {% trans 'Delete item' %}</a></li>
<li><a href="{% model_url item 'update' %}"><i class="icon-pencil"></i> {% trans 'Edit item' %}</a></li>
<li><a href="{% model_url item 'delete' %}"><i class="icon-remove"></i> {% trans 'Delete item' %}</a></li>
</ul>
{% endif %}
</div>
</div>
</small>
</h1>
<p>{{ item.text|safe|linebreaks }}</p>
<p>
{% if item.get_related_slide == item %}
{{ item.text|safe|linebreaks }}
{% else %}
<a href="{% model_url item.get_related_slide %}">{% trans 'Goto' %} {% trans item.get_related_type %} {{ item.get_related_slide }}</a>
{% endif %}
</p>
{% if perms.agenda.can_manage_agenda %}
{% if item.comment %}

View File

@ -37,7 +37,7 @@ class AssignmentCandidate(models.Model):
class Assignment(models.Model, SlideMixin):
prefix = 'assignment'
prefix = ugettext_noop('assignment')
STATUS = (
('sea', ugettext_lazy('Searching for candidates')),
('vot', ugettext_lazy('Voting')),
@ -226,10 +226,10 @@ class Assignment(models.Model, SlideMixin):
data['template'] = 'projector/Assignment.html'
return data
def get_absolute_url(self, link='view'):
if link == 'view':
def get_absolute_url(self, link='detail'):
if link == 'detail' or link == 'view':
return reverse('assignment_view', args=[str(self.id)])
if link == 'edit':
if link == 'update' or link == 'edit':
return reverse('assignment_edit', args=[str(self.id)])
if link == 'delete':
return reverse('assignment_delete', args=[str(self.id)])

View File

@ -43,7 +43,7 @@ class Motion(SlideMixin, models.Model):
This class is the main entry point to all other classes related to a motion.
"""
prefix = 'motion'
prefix = ugettext_noop('motion')
"""
Prefix for the slide system.
"""
@ -100,7 +100,7 @@ class Motion(SlideMixin, models.Model):
"""
Return a human readable name of this motion.
"""
return self.get_title()
return self.active_version.title
# TODO: Use transaction
def save(self, ignore_version_data=False, *args, **kwargs):
@ -163,11 +163,11 @@ class Motion(SlideMixin, models.Model):
"""
Return an URL for this version.
The keyword argument 'link' can be 'detail', 'view', 'edit' or 'delete'.
The keyword argument 'link' can be 'detail', 'view', 'edit', 'update' or 'delete'.
"""
if link == 'view' or link == 'detail':
return reverse('motion_detail', args=[str(self.id)])
if link == 'edit':
if link == 'update' or link == 'edit':
return reverse('motion_edit', args=[str(self.id)])
if link == 'delete':
return reverse('motion_delete', args=[str(self.id)])
@ -458,11 +458,15 @@ class Motion(SlideMixin, models.Model):
"""
Return a title for the Agenda.
"""
return self.last_version.title # TODO: nutze active_version
return self.active_version.title
## def get_agenda_title_supplement(self):
## number = self.number or '<i>[%s]</i>' % ugettext('no number')
## return '(%s %s)' % (ugettext('motion'), number)
def get_agenda_title_supplement(self):
"""
Returns the supplement to the title for the agenda item.
"""
if self.identifier:
return '(%s %s)' % (_('Motion'), self.identifier)
return '(%s)' % _('Motion')
def get_allowed_actions(self, person):
"""

View File

@ -50,7 +50,7 @@
{% for motion in motion_list %}
<tr class="{% if motion.active %}activeline{% endif %}">
<td class="nobr">{{ motion.identifier|default:'' }}</td>
<td><a href="{% model_url motion %}">{{ motion.title }}</a></td>
<td><a href="{% model_url motion %}">{{ motion }}</a></td>
<td class="optional">{% if motion.category %}{{ motion.category }}{% else %}{% endif %}</td>
<td><span class="label label-info">{% trans motion.state.name %}</span></td>
<td class="optional">

View File

@ -53,7 +53,7 @@
<h1>
{% if motion.identifier %}
{% trans "Motion No." %} {{ motion.identifier }}
{% trans "Motion" %} {{ motion.identifier }}
{% else %}
{% trans "Motion" %} [---]
{% endif %}