Merge pull request #2993 from emanuelschuetze/motion-poll-log
Added motion log entry for creating polls.
This commit is contained in:
commit
6b74bf635d
@ -3,7 +3,7 @@ from django.contrib.contenttypes.fields import GenericRelation
|
|||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
from django.utils import formats
|
from django.utils import formats, timezone
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.utils.translation import ugettext_lazy, ugettext_noop
|
from django.utils.translation import ugettext_lazy, ugettext_noop
|
||||||
from jsonfield import JSONField
|
from jsonfield import JSONField
|
||||||
@ -866,7 +866,8 @@ class MotionLog(RESTModelMixin, models.Model):
|
|||||||
"""
|
"""
|
||||||
Return a string, representing the log message.
|
Return a string, representing the log message.
|
||||||
"""
|
"""
|
||||||
time = formats.date_format(self.time, 'DATETIME_FORMAT')
|
localtime = timezone.localtime(self.time)
|
||||||
|
time = formats.date_format(localtime, 'DATETIME_FORMAT')
|
||||||
time_and_messages = '%s ' % time + ''.join(map(_, self.message_list))
|
time_and_messages = '%s ' % time + ''.join(map(_, self.message_list))
|
||||||
if self.person is not None:
|
if self.person is not None:
|
||||||
return _('%(time_and_messages)s by %(person)s') % {'time_and_messages': time_and_messages,
|
return _('%(time_and_messages)s by %(person)s') % {'time_and_messages': time_and_messages,
|
||||||
|
@ -356,6 +356,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
motion.create_poll()
|
motion.create_poll()
|
||||||
except WorkflowError as e:
|
except WorkflowError as e:
|
||||||
raise ValidationError({'detail': e})
|
raise ValidationError({'detail': e})
|
||||||
|
motion.write_log([ugettext_noop('Vote created')], request.user)
|
||||||
return Response({'detail': _('Vote created successfully.')})
|
return Response({'detail': _('Vote created successfully.')})
|
||||||
|
|
||||||
|
|
||||||
@ -375,6 +376,24 @@ class MotionPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
|||||||
return (has_perm(self.request.user, 'motions.can_see') and
|
return (has_perm(self.request.user, 'motions.can_see') and
|
||||||
has_perm(self.request.user, 'motions.can_manage'))
|
has_perm(self.request.user, 'motions.can_manage'))
|
||||||
|
|
||||||
|
def update(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Customized view endpoint to update a motion poll.
|
||||||
|
"""
|
||||||
|
result = super().update(*args, **kwargs)
|
||||||
|
poll = self.get_object()
|
||||||
|
poll.motion.write_log([ugettext_noop('Vote updated')], self.request.user)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def destroy(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Customized view endpoint to delete a motion poll.
|
||||||
|
"""
|
||||||
|
result = super().destroy(*args, **kwargs)
|
||||||
|
poll = self.get_object()
|
||||||
|
poll.motion.write_log([ugettext_noop('Vote deleted')], self.request.user)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class MotionChangeRecommendationViewSet(ModelViewSet):
|
class MotionChangeRecommendationViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user