Merge pull request #2367 from emanuelschuetze/motionCommentFixes

Fixes and template improvements for motion comments.
This commit is contained in:
Norman Jäckel 2016-09-08 13:24:08 +02:00 committed by GitHub
commit ddc1f5d0b9
5 changed files with 24 additions and 14 deletions

View File

@ -591,6 +591,8 @@ class Motion(RESTModelMixin, models.Model):
The message should be in English and translatable, The message should be in English and translatable,
e. g. motion.write_log(message_list=[ugettext_noop('Message Text')]) e. g. motion.write_log(message_list=[ugettext_noop('Message Text')])
""" """
if person and not person.is_authenticated():
person = None
MotionLog.objects.create(motion=self, message_list=message_list, person=person) MotionLog.objects.create(motion=self, message_list=message_list, person=person)
def is_amendment(self): def is_amendment(self):

View File

@ -290,7 +290,7 @@ class MotionSerializer(ModelSerializer):
motion.save() motion.save()
if validated_data.get('submitters'): if validated_data.get('submitters'):
motion.submitters.add(*validated_data['submitters']) motion.submitters.add(*validated_data['submitters'])
else: elif validated_data['request_user'].is_authenticated():
motion.submitters.add(validated_data['request_user']) motion.submitters.add(validated_data['request_user'])
motion.supporters.add(*validated_data.get('supporters', [])) motion.supporters.add(*validated_data.get('supporters', []))
motion.attachments.add(*validated_data.get('attachments', [])) motion.attachments.add(*validated_data.get('attachments', []))

View File

@ -1209,6 +1209,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
'$state', '$state',
'gettext', 'gettext',
'gettextCatalog', 'gettextCatalog',
'operator',
'Motion', 'Motion',
'MotionForm', 'MotionForm',
'Category', 'Category',
@ -1219,7 +1220,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
'Workflow', 'Workflow',
'Agenda', 'Agenda',
'AgendaUpdate', 'AgendaUpdate',
function($scope, $state, gettext, gettextCatalog, Motion, MotionForm, Category, Config, Mediafile, Tag, User, Workflow, Agenda, AgendaUpdate) { function($scope, $state, gettext, gettextCatalog, operator, Motion, MotionForm, Category, Config, Mediafile, Tag, User, Workflow, Agenda, AgendaUpdate) {
Category.bindAll({}, $scope, 'categories'); Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles'); Mediafile.bindAll({}, $scope, 'mediafiles');
Tag.bindAll({}, $scope, 'tags'); Tag.bindAll({}, $scope, 'tags');
@ -1252,11 +1253,14 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions', 'OpenSlid
$scope.save = function (motion) { $scope.save = function (motion) {
Motion.create(motion).then( Motion.create(motion).then(
function(success) { function(success) {
// type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item, // change agenda item only if user has the permission to do that
// see openslides.agenda.models.Item.ITEM_TYPE. if (operator.hasPerms('agenda.can_manage')) {
var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)}, // type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item,
{key: 'parent_id', value: motion.agenda_parent_item_id}]; // see openslides.agenda.models.Item.ITEM_TYPE.
AgendaUpdate.saveChanges(success.agenda_item_id, changes); var changes = [{key: 'type', value: (motion.showAsAgendaItem ? 1 : 2)},
{key: 'parent_id', value: motion.agenda_parent_item_id}];
AgendaUpdate.saveChanges(success.agenda_item_id, changes);
}
if (isAmendment) { if (isAmendment) {
$state.go('motions.motion.detail', {id: success.id}); $state.go('motions.motion.detail', {id: success.id});
} }

View File

@ -398,11 +398,14 @@
</div> </div>
</div> </div>
<div class="details"> <div class="details" ng-if="motion.comments">
<h3>Motion Comments</h3> <h3>Motion Comments</h3>
<div ng-repeat="field in commentsFields"> <div ng-repeat="field in commentsFields">
<p ng-if="field.public || operator.hasPerms('motions.can_see_and_manage_comments')"> <p ng-if="field.public || operator.hasPerms('motions.can_see_and_manage_comments')">
{{ field.name }}: {{ motion.comments[$index] }} <b>{{ field.name }}:</b>
</p> <span ng-if="!field.public" class="label label-warning" translate>internal</span>
</div> <br>
{{ motion.comments[$index] }}
</p>
</div>
</div> </div>

View File

@ -1311,6 +1311,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
gettext('Can create motions'); gettext('Can create motions');
gettext('Can support motions'); gettext('Can support motions');
gettext('Can manage motions'); gettext('Can manage motions');
gettext('Can see and manage comments');
// users // users
gettext('Can see names of users'); gettext('Can see names of users');
gettext('Can see extra data of users (e.g. present and comment)'); gettext('Can see extra data of users (e.g. present and comment)');