some errors occured with the new beamer app in agenda

This commit is contained in:
Oskar Hahn 2012-02-06 10:10:20 +01:00
parent 5f6c96b3e8
commit 8275484d84
3 changed files with 7 additions and 30 deletions

View File

@ -2,25 +2,7 @@
{% block title %}{{ block.super }} - {%trans "Item" %}{% endblock %}
{% block content %}
{% if item %}
<h1>{%trans "Edit item" %}</h1>
{% else %}
<h1>{%trans "New item" %}</h1>
<p>{%trans "Choose item type:" %}</p>
<p>
<a href="{% url item_new 'ItemText' %}"
{% ifequal request.path '/agenda/new/ItemText/' %}style='font-size:15px; font-weight:bold;'{% endifequal %}
>{%trans "Item of Text" %}</a> |
<a href="{% url item_new 'ItemApplication' %}"
{% ifequal request.path '/agenda/new/ItemApplication/' %}style='font-size:15px; font-weight:bold;'{% endifequal %}
>{%trans "Item of Application" %}</a> |
<a href="{% url item_new 'ItemAssignment' %}"
{% ifequal request.path '/agenda/new/ItemAssignment/' %}style='font-size:15px; font-weight:bold;'{% endifequal %}
>{%trans "Item of Election" %}</a>
</p>
{% endif %}
<h1>{%trans "Edit item" %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button class="button" type="submit">

View File

@ -128,13 +128,13 @@ def set_closed(request, item_id, closed=True):
@permission_required('agenda.can_manage_agenda')
@template('agenda/edit.html')
def edit(request, item_id=None, form='ItemText', default=None):
def edit(request, item_id=None):
"""
Show a form to edit an existing Item, or create a new one.
"""
if item_id is not None:
try:
item = Item.objects.get(id=item_id).cast()
item = Item.objects.get(pk=item_id)
except Item.DoesNotExist:
messages.error(request, _('Item ID %d does not exist.') % int(item_id))
return redirect(reverse('item_overview'))
@ -142,21 +142,14 @@ def edit(request, item_id=None, form='ItemText', default=None):
item = None
if request.method == 'POST':
if item_id is None:
form = MODELFORM[form](request.POST)
else:
form = item.edit_form(request.POST)
form = ItemFormText(request.POST, instance=item)
if form.is_valid():
item = form.save()
if item_id is None:
messages.success(request, _('New item was successfully created.'))
if "application" in request.POST:
item.application.writelog(_('Agenda item created'), request.user)
else:
messages.success(request, _('Item was successfully modified.'))
if "application" in request.POST:
item.application.writelog(_('Agenda item modified'), request.user)
if not 'apply' in request.POST:
return redirect(reverse('item_overview'))
if item_id is None:
@ -164,7 +157,7 @@ def edit(request, item_id=None, form='ItemText', default=None):
else:
messages.error(request, _('Please check the form for errors.'))
else:
form = ItemFormText()
form = ItemFormText(instance=item)
return { 'form': form,
'item': item }

View File

@ -7,6 +7,8 @@ def get_element_from_eid(eid):
model, id = eid.split()
except ValueError:
return None # We need a elementError hier
except AttributeError:
return None
return ELEMENT[model].objects.get(pk=id)