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

View File

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

View File

@ -37,7 +37,7 @@ class AssignmentCandidate(models.Model):
class Assignment(models.Model, SlideMixin): class Assignment(models.Model, SlideMixin):
prefix = 'assignment' prefix = ugettext_noop('assignment')
STATUS = ( STATUS = (
('sea', ugettext_lazy('Searching for candidates')), ('sea', ugettext_lazy('Searching for candidates')),
('vot', ugettext_lazy('Voting')), ('vot', ugettext_lazy('Voting')),
@ -226,10 +226,10 @@ class Assignment(models.Model, SlideMixin):
data['template'] = 'projector/Assignment.html' data['template'] = 'projector/Assignment.html'
return data return data
def get_absolute_url(self, link='view'): def get_absolute_url(self, link='detail'):
if link == 'view': if link == 'detail' or link == 'view':
return reverse('assignment_view', args=[str(self.id)]) 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)]) return reverse('assignment_edit', args=[str(self.id)])
if link == 'delete': if link == 'delete':
return reverse('assignment_delete', args=[str(self.id)]) 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. 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. Prefix for the slide system.
""" """
@ -100,7 +100,7 @@ class Motion(SlideMixin, models.Model):
""" """
Return a human readable name of this motion. Return a human readable name of this motion.
""" """
return self.get_title() return self.active_version.title
# TODO: Use transaction # TODO: Use transaction
def save(self, ignore_version_data=False, *args, **kwargs): def save(self, ignore_version_data=False, *args, **kwargs):
@ -163,11 +163,11 @@ class Motion(SlideMixin, models.Model):
""" """
Return an URL for this version. 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': if link == 'view' or link == 'detail':
return reverse('motion_detail', args=[str(self.id)]) 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)]) return reverse('motion_edit', args=[str(self.id)])
if link == 'delete': if link == 'delete':
return reverse('motion_delete', args=[str(self.id)]) return reverse('motion_delete', args=[str(self.id)])
@ -458,11 +458,15 @@ class Motion(SlideMixin, models.Model):
""" """
Return a title for the Agenda. 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): def get_agenda_title_supplement(self):
## number = self.number or '<i>[%s]</i>' % ugettext('no number') """
## return '(%s %s)' % (ugettext('motion'), number) 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): def get_allowed_actions(self, person):
""" """

View File

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

View File

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