From 0b9a64f9687de68f0e3ccc13c29690137e40d5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 13 Jul 2016 14:45:40 +0200 Subject: [PATCH] Added motion origin field. --- CHANGELOG | 3 +++ .../motions/migrations/0002_motion_origin.py | 20 ++++++++++++++++++ openslides/motions/models.py | 6 ++++++ openslides/motions/serializers.py | 6 ++++-- openslides/motions/static/js/motions/site.js | 21 ++++++++++++++----- .../templates/motions/motion-import.html | 8 ++++--- 6 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 openslides/motions/migrations/0002_motion_origin.py diff --git a/CHANGELOG b/CHANGELOG index 5cec85e26..0e40243c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,9 @@ Core: - Used Django Channels instead of Tornado. - Added support for big assemblies with lots of users. +Motions: +- Added origin field. + Other: - Removed config cache to support multiple threads or processes. - Fixed bug, that the last change of a config value was not send via autoupdate. diff --git a/openslides/motions/migrations/0002_motion_origin.py b/openslides/motions/migrations/0002_motion_origin.py new file mode 100644 index 000000000..55887d1a6 --- /dev/null +++ b/openslides/motions/migrations/0002_motion_origin.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-13 14:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('motions', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='motion', + name='origin', + field=models.CharField(blank=True, max_length=255), + ), + ] diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 4f51ab033..ac1de7607 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -81,6 +81,12 @@ class Motion(RESTModelMixin, models.Model): ForeignKey to one category of motions. """ + origin = models.CharField(max_length=255, blank=True) + """ + A string to describe the origin of this motion e. g. that it was + discussed at another assembly/conference. + """ + attachments = models.ManyToManyField(Mediafile, blank=True) """ Many to many relation to mediafile objects. diff --git a/openslides/motions/serializers.py b/openslides/motions/serializers.py index 8932dda2c..c1f4a291c 100644 --- a/openslides/motions/serializers.py +++ b/openslides/motions/serializers.py @@ -233,6 +233,7 @@ class MotionSerializer(ModelSerializer): 'active_version', 'parent', 'category', + 'origin', 'submitters', 'supporters', 'state', @@ -255,6 +256,7 @@ class MotionSerializer(ModelSerializer): motion.reason = validated_data.get('reason', '') motion.identifier = validated_data.get('identifier') motion.category = validated_data.get('category') + motion.origin = validated_data.get('origin', '') motion.reset_state(validated_data.get('workflow_id')) motion.save() if validated_data.get('submitters'): @@ -271,8 +273,8 @@ class MotionSerializer(ModelSerializer): """ Customized method to update a motion. """ - # Identifier and category. - for key in ('identifier', 'category'): + # Identifier, category and origin. + for key in ('identifier', 'category', 'origin'): if key in validated_data.keys(): setattr(motion, key, validated_data[key]) diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 93896fd5d..c9fbd82d2 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -296,6 +296,14 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) }, hideExpression: '!model.more' }, + { + key: 'origin', + type: 'input', + templateOptions: { + label: gettextCatalog.getString('Origin'), + }, + hideExpression: '!model.more' + }, { key: 'tags_id', type: 'select-multiple', @@ -917,6 +925,10 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) if (motion.category && motion.category !== '' && !motion.category_id) { motion.category_create = gettext('New category will be created.'); } + // origin + if (motion.origin) { + motion.origin = motion.origin.replace(quotionRe, '$1'); + } $scope.motions.push(motion); }); }); @@ -971,12 +983,11 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) var element = document.getElementById('downloadLink'); var csvRows = [ // column header line - ['identifier', 'title', 'text', 'reason', 'submitter', 'category'], + ['identifier', 'title', 'text', 'reason', 'submitter', 'category', 'origin'], // example entries - ['A1', 'title 1', 'text 1', 'reason 1', 'Submitter A', 'Category A'], - ['B1', 'title 2', 'text 2', 'reason 2', 'Submitter B', 'Category B'], - ['' , 'title 3', 'text 3', '', '', ''] - + ['A1', 'Title 1', 'Text 1', 'Reason 1', 'Submitter A', 'Category A', 'Last Year Conference A'], + ['B1', 'Title 2', 'Text 2', 'Reason 2', 'Submitter B', 'Category B', '' ], + ['' , 'Title 3', 'Text 3', '' , '' , '' , '' ], ]; var csvString = csvRows.join("%0A"); element.href = 'data:text/csv;charset=utf-8,' + csvString; diff --git a/openslides/motions/static/templates/motions/motion-import.html b/openslides/motions/static/templates/motions/motion-import.html index a5cf49078..8911da8e8 100644 --- a/openslides/motions/static/templates/motions/motion-import.html +++ b/openslides/motions/static/templates/motions/motion-import.html @@ -39,8 +39,8 @@

Please note:

@@ -57,7 +57,8 @@ Text Reason Submitter - Category + Category + Origin {{ motion.category }} + {{ motion.origin | limitTo:30 }}{{ motion.origin.length > 30 ? '...' : '' }}