Merge pull request #690 from normanjaeckel/DeleteFeatureRejectVersion

Fix #679
This commit is contained in:
Oskar Hahn 2013-05-31 06:44:59 -07:00
commit 4aeb329d7c
4 changed files with 9 additions and 91 deletions

View File

@ -343,18 +343,13 @@ class Motion(SlideMixin, models.Model):
"""
Return the newest version of the motion.
"""
# TODO: Fix the case, that the motion has no version
# TODO: Fix the case, that the motion has no version.
# Check whether the case, that a motion has not any version, can still appear.
try:
return self.versions.order_by('-version_number')[0]
except IndexError:
return self.new_version
def get_last_not_rejected_version(self):
"""
Returns the newest version of the motion, which is not rejected.
"""
return self.versions.filter(rejected=False).order_by('-version_number')[0]
@property
def submitters(self):
return sorted([object.person for object in self.submitter.all()],
@ -517,7 +512,7 @@ class Motion(SlideMixin, models.Model):
def set_active_version(self, version):
"""
Set the active state of a version to 'version'.
Set the active version of a motion to 'version'.
'version' can be a version object, or the version_number of a version.
"""
@ -525,25 +520,6 @@ class Motion(SlideMixin, models.Model):
version = self.versions.get(version_number=version)
self.active_version = version
if version.rejected:
version.rejected = False
version.save()
def reject_version(self, version):
"""
Reject a version of this motion.
'version' can be a version object, or the version_number of a version.
"""
if type(version) is int:
version = self.versions.get(version_number=version)
if version.active:
raise MotionError('The active version can not be rejected')
version.rejected = True
version.save()
class MotionVersion(models.Model):
"""
@ -568,9 +544,6 @@ class MotionVersion(models.Model):
reason = models.TextField(null=True, blank=True, verbose_name=ugettext_lazy("Reason"))
"""The reason for a motion."""
rejected = models.BooleanField(default=False)
"""Saves if the version is rejected."""
creation_time = models.DateTimeField(auto_now=True)
"""Time when the version was saved."""

View File

@ -57,18 +57,18 @@
<div class="row-fluid">
<div class="span8">
{# TODO: show only for workflow with versioning #}
{% if motion.version.version_number != motion.get_last_not_rejected_version.version_number %}
{% if motion.version.version_number != motion.last_version.version_number %}
<span class="label label-warning">
<i class="icon-warning-sign icon-white"></i> {% trans "This is not the last not rejected version." %}
<i class="icon-warning-sign icon-white"></i> {% trans "This is not the newest version." %}
</span>
<a href="{% model_url motion.get_last_not_rejected_version %}" class="btn btn-small">{% trans "Go to last not rejected version" %}
(# {{ motion.get_last_not_rejected_version.version_number }})</a>
<a href="{% model_url motion.last_version %}" class="btn btn-small">{% trans "Go to the newest version" %}
(# {{ motion.last_version.version_number }})</a>
{% endif %}
{% if motion.version.version_number != motion.active_version.version_number %}
<span class="label label-warning">
<i class="icon-warning-sign icon-white"></i> {% trans "This version is not authorized." %}
</span>
<a href="{% model_url motion.active_version %}" class="btn btn-small">{% trans "Go to last authorized version" %}
<a href="{% model_url motion.active_version %}" class="btn btn-small">{% trans "Go to the authorized version" %}
(# {{ motion.active_version.version_number }})</a>
{% endif %}
@ -110,12 +110,6 @@
{% if perms.motion.can_manage_motion %}
<a class="btn btn-mini" href="{% url 'motion_version_permit' motion.id version.version_number %}" title="{% trans 'Permit this version' %}"><i class="icon-ok"></i></a>
{% endif %}
{% if not version.rejected and version.id > motion.active_version.id and perms.motion.can_manage_motion %}
<a class="btn btn-mini" href="{% url 'motion_version_reject' motion.id version.version_number %}" title="{% trans 'Reject this version' %}"><i class="icon-ban-circle"></i></a>
{% endif %}
{% endif %}
{% if version.rejected %}
<span class="badge badge-important" title="{% trans 'This version is rejected' %}"><i class="icon-ban-circle icon-white"></i></span>
{% endif %}
</td>
<td>{{ version.version_number }}</td>

View File

@ -50,11 +50,6 @@ urlpatterns = patterns('openslides.motion.views',
name='motion_version_permit',
),
url(r'^(?P<pk>\d+)/version/(?P<version_number>\d+)/reject/$',
'version_reject',
name='motion_version_reject',
),
url(r'^(?P<pk>\d+)/diff/$',
'version_diff',
name='motion_version_diff',

View File

@ -65,7 +65,7 @@ class GetVersionMixin(object):
except MotionVersion.DoesNotExist:
raise Http404('Version %s not found' % version_number)
else:
object.version = object.get_last_not_rejected_version()
object.version = object.active_version
return object
@ -277,50 +277,6 @@ class VersionPermitView(GetVersionMixin, SingleObjectMixin, QuestionMixin, Redir
version_permit = VersionPermitView.as_view()
class VersionRejectView(GetVersionMixin, SingleObjectMixin, QuestionMixin, RedirectView):
"""
View to reject a version.
"""
model = Motion
question_url_name = 'motion_version_detail'
success_url_name = 'motion_detail'
def get(self, *args, **kwargs):
"""
Set self.object to a motion.
"""
self.object = self.get_object()
return super(VersionRejectView, self).get(*args, **kwargs)
def get_url_name_args(self):
"""
Return a list with arguments to create the success- and question_url.
"""
return [self.object.pk, self.object.version.version_number]
def get_question(self):
return _('Are you sure you want reject Version %s?') % self.object.version.version_number
def case_yes(self):
"""
Reject the version, if the user chooses 'yes'.
"""
self.object.reject_version(self.object.version)
self.object.save(ignore_version_data=True)
self.object.write_log(
message_list=[ugettext_noop('Version %d rejected') % self.object.version.version_number],
person=self.request.user)
def get_success_url_name_args(self):
"""
Returns the motion pk as argument for the success url name.
"""
return [self.object.pk]
version_reject = VersionRejectView.as_view()
class VersionDiffView(DetailView):
"""Show diff between two versions of a motion."""
permission_required = 'motion.can_see_motion'