accept and reject links for applications
This commit is contained in:
parent
e849716ee4
commit
5543320e0d
@ -62,6 +62,23 @@ class Application(models.Model):
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def accept_version(self, version):
|
||||
"""
|
||||
accept a Version
|
||||
"""
|
||||
if version.id > self.permitted.id:
|
||||
self.permitted = version
|
||||
self.save()
|
||||
return True
|
||||
return False
|
||||
|
||||
def reject_version(self, version):
|
||||
if version.id > self.permitted.id:
|
||||
version.rejected = True
|
||||
version.save()
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def versions(self):
|
||||
"""
|
||||
@ -99,11 +116,11 @@ class Application(models.Model):
|
||||
Return True if the application has unpermitted changes.
|
||||
|
||||
The application has unpermitted changes, if the permitted-version
|
||||
is not the lastone and the lastone is not abjected.
|
||||
is not the lastone and the lastone is not rejected.
|
||||
TODO: rename the property in unchecked__changes
|
||||
"""
|
||||
if (self.last_version != self.permitted
|
||||
and not self.last_version.abjected):
|
||||
and not self.last_version.rejected):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -384,7 +401,7 @@ class AVersion(models.Model):
|
||||
title = models.CharField(max_length=100)
|
||||
text = models.TextField()
|
||||
reason = models.TextField(null=True, blank=True)
|
||||
abjected = models.BooleanField()
|
||||
rejected = models.BooleanField()
|
||||
time = models.DateTimeField(auto_now=True)
|
||||
application = models.ForeignKey(Application)
|
||||
|
||||
|
@ -97,10 +97,10 @@
|
||||
</ul>
|
||||
{% endwith %}
|
||||
|
||||
|
||||
|
||||
<h4>{% trans "Creation Time" %}:</h4>
|
||||
{{ application.creation_time }}
|
||||
|
||||
|
||||
<p></p>
|
||||
{% if "edit" in actions %}
|
||||
<a href="{% url application_edit application.id %}">
|
||||
@ -132,7 +132,7 @@
|
||||
{% if min_supporters > 0 %}
|
||||
<small>* {% trans "minimum required supporters" %}: {{ min_supporters }}</small>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<br><br>
|
||||
|
||||
{% if perms.application.can_manage_application %}
|
||||
@ -239,7 +239,18 @@
|
||||
</tr>
|
||||
{% for revision in application.versions %}
|
||||
<tr>
|
||||
<td>{{ revision.aid }} </td>
|
||||
<td>{{ revision.aid }}
|
||||
{% if revision.rejected %}
|
||||
Version Abgelehnt
|
||||
{% else %}
|
||||
{% if revision == application.permitted %}
|
||||
Akzeptierte Version
|
||||
{% else %}{% if revision.id > application.permitted.id and perms.application.can_manage_application %}
|
||||
<a href="{% url application_version_permit revision.id %}">Akzeptieren</a><br>
|
||||
<a href="{% url application_version_reject revision.id %}">Ablehnen</a>
|
||||
{% endif %}{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><i>{{ revision.time }}</i></td>
|
||||
<td>
|
||||
{% ifchanged %}
|
||||
|
@ -38,6 +38,12 @@ urlpatterns = patterns('application.views',
|
||||
url(r'^application/(?P<application_id>\d+)/permit$', 'permit', \
|
||||
name='application_permit'),
|
||||
|
||||
url(r'^application/version/(?P<aversion_id>\d+)/permit$', 'permit_version', \
|
||||
name='application_version_permit'),
|
||||
|
||||
url(r'^application/version/(?P<aversion_id>\d+)/reject$', 'reject_version', \
|
||||
name='application_version_reject'),
|
||||
|
||||
url(r'^application/(?P<application_id>\d+)/notpermit$', 'notpermit', \
|
||||
name='application_notpermit'),
|
||||
|
||||
@ -59,7 +65,8 @@ urlpatterns = patterns('application.views',
|
||||
url(r'^application/(?P<application_id>\d+)/print$', 'print_application', \
|
||||
name='print_application'),
|
||||
|
||||
url(r'^application/poll/(?P<poll_id>\d+)/print$', 'print_application_poll', name='print_application_poll'),
|
||||
url(r'^application/poll/(?P<poll_id>\d+)/print$', 'print_application_poll', \
|
||||
name='print_application_poll'),
|
||||
|
||||
url(r'^application/poll/(?P<poll_id>\d+)$', 'view_poll', \
|
||||
name='application_poll_view'),
|
||||
|
@ -16,7 +16,7 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from openslides.application.models import Application
|
||||
from openslides.application.models import Application, AVersion
|
||||
from openslides.application.forms import ApplicationForm, \
|
||||
ApplicationManagerForm
|
||||
from openslides.poll.models import Poll
|
||||
@ -351,3 +351,25 @@ def view_poll(request, poll_id):
|
||||
'options': options,
|
||||
'ballot': ballot,
|
||||
}
|
||||
|
||||
@permission_required('application.can_manage_application')
|
||||
def permit_version(request, aversion_id):
|
||||
aversion = AVersion.objects.get(pk=aversion_id)
|
||||
application = aversion.application
|
||||
if application.accept_version(aversion):
|
||||
messages.success(request, _("Version accepted") )
|
||||
else:
|
||||
messages.error(request, _("ERROR by accepting the Version") )
|
||||
return redirect(reverse('application_view', args=[application.id]))
|
||||
|
||||
|
||||
@permission_required('application.can_manage_application')
|
||||
def reject_version(request, aversion_id):
|
||||
aversion = AVersion.objects.get(pk=aversion_id)
|
||||
application = aversion.application
|
||||
if application.reject_version(aversion):
|
||||
messages.success(request, _("Version rejected") )
|
||||
else:
|
||||
messages.error(request, _("ERROR by rejecting the Version") )
|
||||
return redirect(reverse('application_view', args=[application.id]))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user