Merge pull request #659 from normanjaeckel/LogMotionImport

Log Entry for imported motions Fixed #655
This commit is contained in:
Oskar Hahn 2013-05-16 04:36:39 -07:00
commit e76aa499f3
3 changed files with 11 additions and 8 deletions

View File

@ -17,14 +17,14 @@
import csv import csv
from django.db import transaction from django.db import transaction
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _, ugettext_noop
from openslides.utils.person.api import Persons from openslides.utils.person.api import Persons
from .models import Motion, Category from .models import Motion, Category
def import_motions(csv_file, default_submitter, override=False): def import_motions(csv_file, default_submitter, override=False, importing_person=None):
""" """
Imports motions from a csv file. Imports motions from a csv file.
@ -102,6 +102,8 @@ def import_motions(csv_file, default_submitter, override=False):
motion.clear_submitters() motion.clear_submitters()
motion.add_submitter(new_submitter) motion.add_submitter(new_submitter)
motion.write_log(message=ugettext_noop('Motion imported'),
person=importing_person)
count_success += 1 count_success += 1
return (count_success, error_messages, warning_messages) return (count_success, error_messages, warning_messages)

View File

@ -496,11 +496,11 @@ class Motion(SlideMixin, models.Model):
return actions return actions
def write_log(self, message, person=None): def write_log(self, message, person=None):
"""Write a log message. """
Write a log message.
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(ugettext_noob('Message Text'))
""" """
MotionLog.objects.create(motion=self, message=message, person=person) MotionLog.objects.create(motion=self, message=message, person=person)

View File

@ -698,8 +698,9 @@ class MotionCSVImportView(FormView):
""" """
count_success, error_messages, warning_messages = import_motions( count_success, error_messages, warning_messages = import_motions(
self.request.FILES['csvfile'], self.request.FILES['csvfile'],
default_submitter=self.request.user, default_submitter=form.cleaned_data['default_submitter'],
override=form.cleaned_data['override']) override=form.cleaned_data['override'],
importing_person=self.request.user)
for message in error_messages: for message in error_messages:
messages.error(self.request, message) messages.error(self.request, message)
for message in warning_messages: for message in warning_messages: