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:
|
except IndexError:
|
||||||
return None
|
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
|
@property
|
||||||
def versions(self):
|
def versions(self):
|
||||||
"""
|
"""
|
||||||
@ -99,11 +116,11 @@ class Application(models.Model):
|
|||||||
Return True if the application has unpermitted changes.
|
Return True if the application has unpermitted changes.
|
||||||
|
|
||||||
The application has unpermitted changes, if the permitted-version
|
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
|
TODO: rename the property in unchecked__changes
|
||||||
"""
|
"""
|
||||||
if (self.last_version != self.permitted
|
if (self.last_version != self.permitted
|
||||||
and not self.last_version.abjected):
|
and not self.last_version.rejected):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -384,7 +401,7 @@ class AVersion(models.Model):
|
|||||||
title = models.CharField(max_length=100)
|
title = models.CharField(max_length=100)
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
reason = models.TextField(null=True, blank=True)
|
reason = models.TextField(null=True, blank=True)
|
||||||
abjected = models.BooleanField()
|
rejected = models.BooleanField()
|
||||||
time = models.DateTimeField(auto_now=True)
|
time = models.DateTimeField(auto_now=True)
|
||||||
application = models.ForeignKey(Application)
|
application = models.ForeignKey(Application)
|
||||||
|
|
||||||
|
@ -239,7 +239,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for revision in application.versions %}
|
{% for revision in application.versions %}
|
||||||
<tr>
|
<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><i>{{ revision.time }}</i></td>
|
||||||
<td>
|
<td>
|
||||||
{% ifchanged %}
|
{% ifchanged %}
|
||||||
|
@ -38,6 +38,12 @@ urlpatterns = patterns('application.views',
|
|||||||
url(r'^application/(?P<application_id>\d+)/permit$', 'permit', \
|
url(r'^application/(?P<application_id>\d+)/permit$', 'permit', \
|
||||||
name='application_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', \
|
url(r'^application/(?P<application_id>\d+)/notpermit$', 'notpermit', \
|
||||||
name='application_notpermit'),
|
name='application_notpermit'),
|
||||||
|
|
||||||
@ -59,7 +65,8 @@ urlpatterns = patterns('application.views',
|
|||||||
url(r'^application/(?P<application_id>\d+)/print$', 'print_application', \
|
url(r'^application/(?P<application_id>\d+)/print$', 'print_application', \
|
||||||
name='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', \
|
url(r'^application/poll/(?P<poll_id>\d+)$', 'view_poll', \
|
||||||
name='application_poll_view'),
|
name='application_poll_view'),
|
||||||
|
@ -16,7 +16,7 @@ from django.contrib.auth.decorators import login_required
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.translation import ugettext as _
|
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, \
|
from openslides.application.forms import ApplicationForm, \
|
||||||
ApplicationManagerForm
|
ApplicationManagerForm
|
||||||
from openslides.poll.models import Poll
|
from openslides.poll.models import Poll
|
||||||
@ -351,3 +351,25 @@ def view_poll(request, poll_id):
|
|||||||
'options': options,
|
'options': options,
|
||||||
'ballot': ballot,
|
'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