syncdb is required
This commit is contained in:
Oskar Hahn 2012-07-04 11:00:58 +02:00
parent 03fe1f84dd
commit a72832842b
8 changed files with 30 additions and 30 deletions

View File

@ -25,7 +25,7 @@ class ItemForm(ModelForm, CssClassMixin):
parent = TreeNodeChoiceField(queryset=Item.objects.all(), label=_("Parent item"), required=False) parent = TreeNodeChoiceField(queryset=Item.objects.all(), label=_("Parent item"), required=False)
class Meta: class Meta:
model = Item model = Item
exclude = ('closed', 'weight', 'releated_sid') exclude = ('closed', 'weight', 'related_sid')
def genweightchoices(): def genweightchoices():

View File

@ -42,27 +42,27 @@ class Item(MPTTModel, SlideMixin):
closed = models.BooleanField(default=False, verbose_name=_("Closed")) closed = models.BooleanField(default=False, verbose_name=_("Closed"))
weight = models.IntegerField(default=0, verbose_name=_("Weight")) weight = models.IntegerField(default=0, verbose_name=_("Weight"))
parent = TreeForeignKey('self', null=True, blank=True, related_name='children') parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
releated_sid = models.CharField(null=True, blank=True, max_length=64) related_sid = models.CharField(null=True, blank=True, max_length=64)
def get_releated_slide(self): def get_related_slide(self):
return get_slide_from_sid(self.releated_sid, True) return get_slide_from_sid(self.related_sid, True)
def get_releated_type(self): def get_related_type(self):
return self.get_releated_slide().prefix return self.get_related_slide().prefix
def print_releated_type(self): def print_related_type(self):
""" """
Print the type of the releated item. Print the type of the related item.
For use in Template For use in Template
??Why does {% trans item.print_releated_type|capfirst %} not work?? ??Why does {% trans item.print_related_type|capfirst %} not work??
""" """
return _(self.get_releated_type().capitalize()) return _(self.get_related_type().capitalize())
def get_title(self): def get_title(self):
if self.releated_sid is None: if self.related_sid is None:
return self.title return self.title
return self.get_releated_slide().get_agenda_title() return self.get_related_slide().get_agenda_title()
def slide(self): def slide(self):
""" """
@ -75,8 +75,8 @@ class Item(MPTTModel, SlideMixin):
'items': self.get_children(), 'items': self.get_children(),
'template': 'projector/AgendaSummary.html', 'template': 'projector/AgendaSummary.html',
} }
elif self.releated_sid: elif self.related_sid:
data = self.get_releated_slide().slide() data = self.get_related_slide().slide()
else: else:
data = { data = {
'item': self, 'item': self,
@ -142,12 +142,12 @@ class Item(MPTTModel, SlideMixin):
* delete * delete
""" """
if link == 'view': if link == 'view':
if self.releated_sid: if self.related_sid:
return self.get_releated_slide().get_absolute_url(link) 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 == 'edit':
if self.releated_sid: if self.related_sid:
return self.get_releated_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)])
if link == 'delete': if link == 'delete':
return reverse('item_delete', args=[str(self.id)]) return reverse('item_delete', args=[str(self.id)])

View File

@ -19,8 +19,8 @@
<div class="dragcell"></div> <div class="dragcell"></div>
{% endif %} {% endif %}
<a href="{{ item.get_absolute_url }}">{{ item }}</a> <a href="{{ item.get_absolute_url }}">{{ item }}</a>
{% if item.releated_sid %} {% if item.related_sid %}
({{ item.print_releated_type }}) ({{ item.print_related_type }})
{% endif %} {% endif %}
</td> </td>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}

View File

@ -32,7 +32,7 @@
{% for p in item.get_ancestors %} {% for p in item.get_ancestors %}
<span class="indentation">&nbsp;</span> <span class="indentation">&nbsp;</span>
{% endfor %} {% endfor %}
<a href="{% model_url item 'view' %}">{{ item }}</a>{% if item.releated_sid %} ({{ item.print_releated_type }}){% endif %} <a href="{% model_url item 'view' %}">{{ item }}</a>{% if item.related_sid %} ({{ item.print_related_type }}){% endif %}
{% if not item.is_leaf_node %} {% if not item.is_leaf_node %}
<a class="activate_link" href="{% url projector_activate_slide item.sid 'summary' %}"><img src="{% static 'images/icons/view-list-tree.png' %}" title="{% trans 'Activate summary for this item' %}"></a> <a class="activate_link" href="{% url projector_activate_slide item.sid 'summary' %}"><img src="{% static 'images/icons/view-list-tree.png' %}" title="{% trans 'Activate summary for this item' %}"></a>
{% endif %} {% endif %}

View File

@ -415,7 +415,7 @@ class Application(models.Model, SlideMixin):
'You can not delete it.') 'You can not delete it.')
for item in Item.objects.filter(releated_sid=self.sid): for item in Item.objects.filter(related_sid=self.sid):
item.delete() item.delete()
super(Application, self).delete() super(Application, self).delete()

View File

@ -683,7 +683,7 @@ class CreateAgendaItem(RedirectView):
def pre_redirect(self, request, *args, **kwargs): def pre_redirect(self, request, *args, **kwargs):
self.application = Application.objects.get(pk=kwargs['application_id']) self.application = Application.objects.get(pk=kwargs['application_id'])
self.item = Item(releated_sid=self.application.sid) self.item = Item(related_sid=self.application.sid)
self.item.save() self.item.save()
def get_redirect_url(self, **kwargs): def get_redirect_url(self, **kwargs):

View File

@ -112,12 +112,12 @@ class Assignment(models.Model, SlideMixin):
def vote_results(self): def vote_results(self):
""" """
returns a table represented as a list with all candidates from all returns a table represented as a list with all candidates from all
releated polls and their vote results. related polls and their vote results.
""" """
vote_results_dict = {} vote_results_dict = {}
# All polls releated to this assigment # All polls related to this assigment
polls = self.poll_set.all() polls = self.poll_set.all()
# All PollOption-Objects releated to this assignment # All PollOption-Objects related to this assignment
options = [] options = []
for poll in polls: for poll in polls:
options += poll.get_options() options += poll.get_options()
@ -130,13 +130,13 @@ class Assignment(models.Model, SlideMixin):
for poll in polls: for poll in polls:
try: try:
polloption = poll.get_options().get(candidate=candidate) polloption = poll.get_options().get(candidate=candidate)
# candidate is releated to this poll # candidate is related to this poll
votes = {} votes = {}
for vote in polloption.get_votes(): for vote in polloption.get_votes():
votes[vote.value] = vote.get_weight() votes[vote.value] = vote.get_weight()
vote_results_dict[candidate].append(votes) vote_results_dict[candidate].append(votes)
except AssignmentOption.DoesNotExist: except AssignmentOption.DoesNotExist:
# candidate not in releated to this poll # candidate not in related to this poll
vote_results_dict[candidate].append(None) vote_results_dict[candidate].append(None)
return vote_results_dict return vote_results_dict
@ -145,7 +145,7 @@ class Assignment(models.Model, SlideMixin):
return self.name return self.name
def delete(self): def delete(self):
for item in Item.objects.filter(releated_sid=self.sid): for item in Item.objects.filter(related_sid=self.sid):
item.delete() item.delete()
super(Assignment, self).delete() super(Assignment, self).delete()

View File

@ -463,7 +463,7 @@ class CreateAgendaItem(RedirectView):
def pre_redirect(self, request, *args, **kwargs): def pre_redirect(self, request, *args, **kwargs):
self.assignment = Assignment.objects.get(pk=kwargs['assignment_id']) self.assignment = Assignment.objects.get(pk=kwargs['assignment_id'])
self.item = Item(releated_sid=self.assignment.sid) self.item = Item(related_sid=self.assignment.sid)
self.item.save() self.item.save()
def get_redirect_url(self, **kwargs): def get_redirect_url(self, **kwargs):