newest version link for application
This commit is contained in:
parent
f6b335245d
commit
08a1e88e12
@ -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):
|
||||
|
@ -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 %}
|
||||
<i>[no number]</i>
|
||||
{% endif %}</h1>
|
||||
{% trans "Version" %} {{ application.aid }}
|
||||
|
||||
<h2>{{ application.title }}</h2>
|
||||
{% 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 %}
|
||||
|
||||
{{ application.text|linebreaks }}
|
||||
<h2>{{ version.title }}</h2>
|
||||
|
||||
{{ version.text|linebreaks }}
|
||||
|
||||
<h2>{% trans "Reason" %}:</h2>
|
||||
|
||||
{% if application.reason %}
|
||||
{{ application.reason|linebreaks }}
|
||||
{% if version.reason %}
|
||||
{{ version.reason|linebreaks }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
|
@ -19,6 +19,9 @@ urlpatterns = patterns('application.views',
|
||||
url(r'^application/(?P<application_id>\d+)$', 'view', \
|
||||
name='application_view'),
|
||||
|
||||
url(r'^application/(?P<application_id>\d+)/newest$', 'view', {'newest': True}, \
|
||||
name='application_view_newest'),
|
||||
|
||||
url(r'^application/new$', 'edit', \
|
||||
name='application_new'),
|
||||
|
||||
|
@ -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 <b>%s</b> rejected.") % (aversion.aid))
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user