newest version link for application
This commit is contained in:
parent
f6b335245d
commit
08a1e88e12
@ -62,6 +62,16 @@ class Application(models.Model):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
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):
|
def accept_version(self, version):
|
||||||
"""
|
"""
|
||||||
accept a Version
|
accept a Version
|
||||||
@ -358,15 +368,12 @@ class Application(models.Model):
|
|||||||
if name in ('title', 'text', 'reason', 'time', 'aid'):
|
if name in ('title', 'text', 'reason', 'time', 'aid'):
|
||||||
try:
|
try:
|
||||||
if name == 'aid':
|
if name == 'aid':
|
||||||
return self.permitted.aid
|
return self.last_version.aid
|
||||||
return self.permitted.__dict__[name]
|
return self.last_version.__dict__[name]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise AttributeError(name)
|
raise AttributeError(name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
if name == 'aid':
|
raise AttributeError(name)
|
||||||
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):
|
def gen_poll(self, user=None):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "application/base_application.html" %}
|
{% 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 %}
|
{% load tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -212,16 +212,23 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<i>[no number]</i>
|
<i>[no number]</i>
|
||||||
{% endif %}</h1>
|
{% endif %}</h1>
|
||||||
{% trans "Version" %} {{ application.aid }}
|
{% trans "Version" %} {{ version.aid }}
|
||||||
|
{% if application.public_version != application.last_version %}
|
||||||
|
{% if version == application.public_version %}
|
||||||
|
(<a href="{% url application_view_newest application.id %}">{% trans "Show newest Version" %}</a>)
|
||||||
|
{% else %}
|
||||||
|
(<a href="{% url application_view application.id %}">{% trans "Show permitted Version" %}</a>)
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h2>{{ application.title }}</h2>
|
<h2>{{ version.title }}</h2>
|
||||||
|
|
||||||
{{ application.text|linebreaks }}
|
{{ version.text|linebreaks }}
|
||||||
|
|
||||||
<h2>{% trans "Reason" %}:</h2>
|
<h2>{% trans "Reason" %}:</h2>
|
||||||
|
|
||||||
{% if application.reason %}
|
{% if version.reason %}
|
||||||
{{ application.reason|linebreaks }}
|
{{ version.reason|linebreaks }}
|
||||||
{% else %}
|
{% else %}
|
||||||
-
|
-
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -19,6 +19,9 @@ urlpatterns = patterns('application.views',
|
|||||||
url(r'^application/(?P<application_id>\d+)$', 'view', \
|
url(r'^application/(?P<application_id>\d+)$', 'view', \
|
||||||
name='application_view'),
|
name='application_view'),
|
||||||
|
|
||||||
|
url(r'^application/(?P<application_id>\d+)/newest$', 'view', {'newest': True}, \
|
||||||
|
name='application_view_newest'),
|
||||||
|
|
||||||
url(r'^application/new$', 'edit', \
|
url(r'^application/new$', 'edit', \
|
||||||
name='application_new'),
|
name='application_new'),
|
||||||
|
|
||||||
|
@ -63,11 +63,15 @@ def overview(request):
|
|||||||
|
|
||||||
@permission_required('application.can_see_application')
|
@permission_required('application.can_see_application')
|
||||||
@template('application/view.html')
|
@template('application/view.html')
|
||||||
def view(request, application_id):
|
def view(request, application_id, newest=False):
|
||||||
"""
|
"""
|
||||||
View one application.
|
View one application.
|
||||||
"""
|
"""
|
||||||
application = Application.objects.get(pk=application_id)
|
application = Application.objects.get(pk=application_id)
|
||||||
|
if newest:
|
||||||
|
version = application.last_version
|
||||||
|
else:
|
||||||
|
version = application.public_version
|
||||||
revisions = application.versions
|
revisions = application.versions
|
||||||
actions = application.get_allowed_actions(user=request.user)
|
actions = application.get_allowed_actions(user=request.user)
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ def view(request, application_id):
|
|||||||
'revisions': revisions,
|
'revisions': revisions,
|
||||||
'actions': actions,
|
'actions': actions,
|
||||||
'min_supporters': int(config_get('application_min_supporters')),
|
'min_supporters': int(config_get('application_min_supporters')),
|
||||||
|
'version': version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user