Added motion log entry for creating polls.
Use timezone support for motion log time.
This commit is contained in:
parent
cac15db50a
commit
4ebc238ea2
@ -3,7 +3,7 @@ from django.contrib.contenttypes.fields import GenericRelation
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import models
|
||||
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_lazy, ugettext_noop
|
||||
from jsonfield import JSONField
|
||||
@ -866,7 +866,8 @@ class MotionLog(RESTModelMixin, models.Model):
|
||||
"""
|
||||
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))
|
||||
if self.person is not None:
|
||||
return _('%(time_and_messages)s by %(person)s') % {'time_and_messages': time_and_messages,
|
||||
|
@ -338,6 +338,7 @@ class MotionViewSet(ModelViewSet):
|
||||
motion.create_poll()
|
||||
except WorkflowError as e:
|
||||
raise ValidationError({'detail': e})
|
||||
motion.write_log([ugettext_noop('Vote created')], request.user)
|
||||
return Response({'detail': _('Vote created successfully.')})
|
||||
|
||||
|
||||
@ -357,6 +358,24 @@ class MotionPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
return (has_perm(self.request.user, 'motions.can_see') and
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user