diff --git a/openslides/application/models.py b/openslides/application/models.py
index 827fb8de9..c953acd8d 100644
--- a/openslides/application/models.py
+++ b/openslides/application/models.py
@@ -62,6 +62,16 @@ class Application(models.Model):
except IndexError:
return None
+ @property
+ def public_version(self):
+ """
+ Return permitted, if the application was permitted, else last_version
+ """
+ if self.permitted is not None:
+ return self.permitted
+ else:
+ return self.last_version
+
def accept_version(self, version):
"""
accept a Version
@@ -358,15 +368,12 @@ class Application(models.Model):
if name in ('title', 'text', 'reason', 'time', 'aid'):
try:
if name == 'aid':
- return self.permitted.aid
- return self.permitted.__dict__[name]
+ return self.last_version.aid
+ return self.last_version.__dict__[name]
except TypeError:
raise AttributeError(name)
except AttributeError:
- if name == 'aid':
- return self.last_version.aid
- return self.last_version.__dict__[name]
- #raise AttributeError(name)
+ raise AttributeError(name)
raise AttributeError(name)
def gen_poll(self, user=None):
diff --git a/openslides/application/templates/application/view.html b/openslides/application/templates/application/view.html
index c13a94136..e303f9a1a 100644
--- a/openslides/application/templates/application/view.html
+++ b/openslides/application/templates/application/view.html
@@ -1,5 +1,5 @@
{% extends "application/base_application.html" %}
-{% block title %}{{ block.super }} - {% trans "Application" %} "{{ application.title }}"{% endblock %}
+{% block title %}{{ block.super }} - {% trans "Application" %} "{{ version.title }}"{% endblock %}
{% load tags %}
{% block content %}
@@ -212,16 +212,23 @@
{% else %}
[no number]
{% endif %}
- {% trans "Version" %} {{ application.aid }}
-
-
{{ application.title }}
+ {% trans "Version" %} {{ version.aid }}
+ {% if application.public_version != application.last_version %}
+ {% if version == application.public_version %}
+ ({% trans "Show newest Version" %})
+ {% else %}
+ ({% trans "Show permitted Version" %})
+ {% endif %}
+ {% endif %}
- {{ application.text|linebreaks }}
+ {{ version.title }}
+
+ {{ version.text|linebreaks }}
{% trans "Reason" %}:
- {% if application.reason %}
- {{ application.reason|linebreaks }}
+ {% if version.reason %}
+ {{ version.reason|linebreaks }}
{% else %}
-
{% endif %}
diff --git a/openslides/application/urls.py b/openslides/application/urls.py
index f86fd9fb4..e98ba4388 100644
--- a/openslides/application/urls.py
+++ b/openslides/application/urls.py
@@ -19,6 +19,9 @@ urlpatterns = patterns('application.views',
url(r'^application/(?P\d+)$', 'view', \
name='application_view'),
+ url(r'^application/(?P\d+)/newest$', 'view', {'newest': True}, \
+ name='application_view_newest'),
+
url(r'^application/new$', 'edit', \
name='application_new'),
diff --git a/openslides/application/views.py b/openslides/application/views.py
index 24f689a56..fb83fc3e4 100644
--- a/openslides/application/views.py
+++ b/openslides/application/views.py
@@ -63,11 +63,15 @@ def overview(request):
@permission_required('application.can_see_application')
@template('application/view.html')
-def view(request, application_id):
+def view(request, application_id, newest=False):
"""
View one application.
"""
application = Application.objects.get(pk=application_id)
+ if newest:
+ version = application.last_version
+ else:
+ version = application.public_version
revisions = application.versions
actions = application.get_allowed_actions(user=request.user)
@@ -76,6 +80,7 @@ def view(request, application_id):
'revisions': revisions,
'actions': actions,
'min_supporters': int(config_get('application_min_supporters')),
+ 'version': version
}
@@ -373,7 +378,7 @@ def permit_version(request, aversion_id):
@permission_required('application.can_manage_application')
def reject_version(request, aversion_id):
aversion = AVersion.objects.get(pk=aversion_id)
- application = aversion.application
+ application = aversion.application
if request.method == 'POST':
if application.reject_version(aversion):
messages.success(request, _("Version %s rejected.") % (aversion.aid))
diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py
index 46122a888..99ea68d0f 100644
--- a/openslides/assignment/views.py
+++ b/openslides/assignment/views.py
@@ -82,7 +82,7 @@ def view(request, assignment_id=None):
polls = []
for poll in assignment.poll_set.filter(assignment=assignment):
polls.append(poll)
-
+
return {'assignment': assignment,
'form': form,
'votes': votes,