Translate changed state in motion log (Fixed #656)
The database has to be reset.
This commit is contained in:
parent
e76aa499f3
commit
148ac53d11
@ -102,7 +102,7 @@ def import_motions(csv_file, default_submitter, override=False, importing_person
|
|||||||
motion.clear_submitters()
|
motion.clear_submitters()
|
||||||
motion.add_submitter(new_submitter)
|
motion.add_submitter(new_submitter)
|
||||||
|
|
||||||
motion.write_log(message=ugettext_noop('Motion imported'),
|
motion.write_log(message_list=[ugettext_noop('Motion imported')],
|
||||||
person=importing_person)
|
person=importing_person)
|
||||||
count_success += 1
|
count_success += 1
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from django.utils import formats
|
|||||||
from django.utils.translation import pgettext
|
from django.utils.translation import pgettext
|
||||||
from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop
|
from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop
|
||||||
|
|
||||||
|
from openslides.utils.jsonfield import JSONField
|
||||||
from openslides.utils.person import PersonField
|
from openslides.utils.person import PersonField
|
||||||
from openslides.config.api import config
|
from openslides.config.api import config
|
||||||
from openslides.poll.models import (
|
from openslides.poll.models import (
|
||||||
@ -495,14 +496,14 @@ class Motion(SlideMixin, models.Model):
|
|||||||
actions['reset_state'] = actions['change_state']
|
actions['reset_state'] = actions['change_state']
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
def write_log(self, message, person=None):
|
def write_log(self, message_list, person=None):
|
||||||
"""
|
"""
|
||||||
Write a log message.
|
Write a log message.
|
||||||
|
|
||||||
The message should be in English and translatable,
|
The message should be in English and translatable,
|
||||||
e. g. motion.write_log(message=ugettext_noop('Message Text'))
|
e. g. motion.write_log(message_list=[ugettext_noop('Message Text')])
|
||||||
"""
|
"""
|
||||||
MotionLog.objects.create(motion=self, message=message, person=person)
|
MotionLog.objects.create(motion=self, message_list=message_list, person=person)
|
||||||
|
|
||||||
def set_active_version(self, version):
|
def set_active_version(self, version):
|
||||||
"""
|
"""
|
||||||
@ -652,10 +653,9 @@ class MotionLog(models.Model):
|
|||||||
motion = models.ForeignKey(Motion, related_name='log_messages')
|
motion = models.ForeignKey(Motion, related_name='log_messages')
|
||||||
"""The motion to witch the object belongs."""
|
"""The motion to witch the object belongs."""
|
||||||
|
|
||||||
message = models.CharField(max_length=255) # TODO: arguments in message, not translatable
|
message_list = JSONField()
|
||||||
"""The log message.
|
"""
|
||||||
|
The log message. It should be a list of strings in english.
|
||||||
Should be in english.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
person = PersonField(null=True)
|
person = PersonField(null=True)
|
||||||
@ -668,12 +668,16 @@ class MotionLog(models.Model):
|
|||||||
ordering = ['-time']
|
ordering = ['-time']
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
"""Return a string, representing the log message."""
|
"""
|
||||||
|
Return a string, representing the log message.
|
||||||
|
"""
|
||||||
time = formats.date_format(self.time, 'DATETIME_FORMAT')
|
time = formats.date_format(self.time, 'DATETIME_FORMAT')
|
||||||
if self.person is None:
|
return_message = '%s ' % time
|
||||||
return "%s %s" % (time, _(self.message))
|
for message in self.message_list:
|
||||||
else:
|
return_message += _(message)
|
||||||
return "%s %s by %s" % (time, _(self.message), self.person)
|
if self.person is not None:
|
||||||
|
return_message += ' by %s' % self.person
|
||||||
|
return return_message
|
||||||
|
|
||||||
|
|
||||||
class MotionVote(BaseVote):
|
class MotionVote(BaseVote):
|
||||||
|
@ -190,7 +190,7 @@ class MotionCreateView(MotionMixin, CreateView):
|
|||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Write a log message, if the form is valid."""
|
"""Write a log message, if the form is valid."""
|
||||||
value = super(MotionCreateView, self).form_valid(form)
|
value = super(MotionCreateView, self).form_valid(form)
|
||||||
self.object.write_log(ugettext_noop('Motion created'), self.request.user)
|
self.object.write_log([ugettext_noop('Motion created')], self.request.user)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def post_save(self, form):
|
def post_save(self, form):
|
||||||
@ -212,7 +212,7 @@ class MotionUpdateView(MotionMixin, UpdateView):
|
|||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Write a log message, if the form is valid."""
|
"""Write a log message, if the form is valid."""
|
||||||
value = super(MotionUpdateView, self).form_valid(form)
|
value = super(MotionUpdateView, self).form_valid(form)
|
||||||
self.object.write_log(ugettext_noop('Motion updated'), self.request.user)
|
self.object.write_log([ugettext_noop('Motion updated')], self.request.user)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
motion_edit = MotionUpdateView.as_view()
|
motion_edit = MotionUpdateView.as_view()
|
||||||
@ -266,7 +266,7 @@ class VersionPermitView(GetVersionMixin, SingleObjectMixin, QuestionMixin, Redir
|
|||||||
self.object.set_active_version(self.object.version)
|
self.object.set_active_version(self.object.version)
|
||||||
self.object.save(ignore_version_data=True)
|
self.object.save(ignore_version_data=True)
|
||||||
self.object.write_log(
|
self.object.write_log(
|
||||||
message=ugettext_noop('Version %d permitted') % self.object.version.version_number,
|
message_list=[ugettext_noop('Version %d permitted') % self.object.version.version_number],
|
||||||
person=self.request.user)
|
person=self.request.user)
|
||||||
|
|
||||||
version_permit = VersionPermitView.as_view()
|
version_permit = VersionPermitView.as_view()
|
||||||
@ -304,7 +304,7 @@ class VersionRejectView(GetVersionMixin, SingleObjectMixin, QuestionMixin, Redir
|
|||||||
self.object.reject_version(self.object.version)
|
self.object.reject_version(self.object.version)
|
||||||
self.object.save(ignore_version_data=True)
|
self.object.save(ignore_version_data=True)
|
||||||
self.object.write_log(
|
self.object.write_log(
|
||||||
message=ugettext_noop('Version %d rejected') % self.object.version.version_number,
|
message_list=[ugettext_noop('Version %d rejected') % self.object.version.version_number],
|
||||||
person=self.request.user)
|
person=self.request.user)
|
||||||
|
|
||||||
version_reject = VersionRejectView.as_view()
|
version_reject = VersionRejectView.as_view()
|
||||||
@ -389,10 +389,10 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
|
|||||||
user = self.request.user
|
user = self.request.user
|
||||||
if self.support:
|
if self.support:
|
||||||
self.object.support(person=user)
|
self.object.support(person=user)
|
||||||
self.object.write_log(ugettext_noop("Supporter: +%s") % user, user)
|
self.object.write_log([ugettext_noop("Supporter: +%s") % user], user)
|
||||||
else:
|
else:
|
||||||
self.object.unsupport(person=user)
|
self.object.unsupport(person=user)
|
||||||
self.object.write_log(ugettext_noop("Supporter: -%s") % user, user)
|
self.object.write_log([ugettext_noop("Supporter: -%s") % user], user)
|
||||||
|
|
||||||
def get_success_message(self):
|
def get_success_message(self):
|
||||||
"""Return the success message."""
|
"""Return the success message."""
|
||||||
@ -422,7 +422,7 @@ class PollCreateView(SingleObjectMixin, RedirectView):
|
|||||||
def pre_redirect(self, request, *args, **kwargs):
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
"""Create the poll for the motion."""
|
"""Create the poll for the motion."""
|
||||||
self.poll = self.object.create_poll()
|
self.poll = self.object.create_poll()
|
||||||
self.object.write_log(ugettext_noop("Poll created"), request.user)
|
self.object.write_log([ugettext_noop("Poll created")], request.user)
|
||||||
messages.success(request, _("New vote was successfully created."))
|
messages.success(request, _("New vote was successfully created."))
|
||||||
|
|
||||||
def get_redirect_url(self, **kwargs):
|
def get_redirect_url(self, **kwargs):
|
||||||
@ -487,7 +487,7 @@ class PollUpdateView(PollMixin, PollFormView):
|
|||||||
Write a log message, if the form is valid.
|
Write a log message, if the form is valid.
|
||||||
"""
|
"""
|
||||||
value = super(PollUpdateView, self).form_valid(form)
|
value = super(PollUpdateView, self).form_valid(form)
|
||||||
self.object.write_log(ugettext_noop('Poll updated'), self.request.user)
|
self.object.write_log([ugettext_noop('Poll updated')], self.request.user)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
poll_edit = PollUpdateView.as_view()
|
poll_edit = PollUpdateView.as_view()
|
||||||
@ -505,7 +505,7 @@ class PollDeleteView(PollMixin, DeleteView):
|
|||||||
Write a log message, if the form is valid.
|
Write a log message, if the form is valid.
|
||||||
"""
|
"""
|
||||||
super(PollDeleteView, self).case_yes()
|
super(PollDeleteView, self).case_yes()
|
||||||
self.object.write_log(ugettext_noop('Poll deleted'), self.request.user)
|
self.object.write_log([ugettext_noop('Poll deleted')], self.request.user)
|
||||||
|
|
||||||
def get_redirect_url(self, **kwargs):
|
def get_redirect_url(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -577,10 +577,10 @@ class MotionSetStateView(SingleObjectMixin, RedirectView):
|
|||||||
messages.error(request, e)
|
messages.error(request, e)
|
||||||
else:
|
else:
|
||||||
self.object.save(ignore_version_data=True)
|
self.object.save(ignore_version_data=True)
|
||||||
# TODO: the state is not translated
|
self.object.write_log(
|
||||||
self.object.write_log(ugettext_noop('State changed to %s') %
|
message_list=[ugettext_noop('State changed to '), self.object.state.name],
|
||||||
self.object.state.name, self.request.user)
|
person=self.request.user)
|
||||||
messages.success(request, _('Motion status was set to: %s.'
|
messages.success(request, _('The state of the motion was set to %s.'
|
||||||
% html_strong(self.object.state)))
|
% html_strong(self.object.state)))
|
||||||
|
|
||||||
set_state = MotionSetStateView.as_view()
|
set_state = MotionSetStateView.as_view()
|
||||||
@ -602,7 +602,7 @@ class CreateAgendaItemView(SingleObjectMixin, RedirectView):
|
|||||||
def pre_redirect(self, request, *args, **kwargs):
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
"""Create the agenda item."""
|
"""Create the agenda item."""
|
||||||
self.item = Item.objects.create(related_sid=self.object.sid)
|
self.item = Item.objects.create(related_sid=self.object.sid)
|
||||||
self.object.write_log(ugettext_noop('Agenda item created'), self.request.user)
|
self.object.write_log([ugettext_noop('Agenda item created')], self.request.user)
|
||||||
|
|
||||||
create_agenda_item = CreateAgendaItemView.as_view()
|
create_agenda_item = CreateAgendaItemView.as_view()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user