Merge pull request #1705 from ostcar/assignment_js

Added assignment poll and assignment related user to js
This commit is contained in:
Norman Jäckel 2015-11-25 23:17:21 +01:00
commit 91cc2b1bc1
3 changed files with 59 additions and 5 deletions

View File

@ -29,7 +29,8 @@ class AssignmentRelatedUserSerializer(ModelSerializer):
fields = (
'id',
'user',
'status')
'status',
'assignment') # js-data needs the assignment-id in the nested object to define relations.
class AssignmentVoteSerializer(ModelSerializer):
@ -91,7 +92,8 @@ class AssignmentAllPollSerializer(ModelSerializer):
'votesvalid',
'votesinvalid',
'votescast',
'votes',)
'votes',
'assignment') # js-data needs the assignment-id in the nested object to define relations.
read_only_fields = ('yesnoabstain',)
@transaction.atomic

View File

@ -4,10 +4,47 @@
angular.module('OpenSlidesApp.assignments', [])
.factory('AssignmentPoll', [
'DS',
'Config',
function (DS, Config) {
return DS.defineResource({
name: 'assignments/poll',
relations: {
belongsTo: {
'assignments/assignment': {
localField: 'assignment',
localKey: 'assignment_id',
}
}
},
})
}
])
.factory('AssignmentRelatedUser', [
'DS',
function (DS) {
return DS.defineResource({
name: 'assignments/relateduser',
relations: {
belongsTo: {
'users/user': {
localField: 'user',
localKey: 'user_id',
}
}
}
})
}
])
.factory('Assignment', [
'DS',
'AssignmentRelatedUser',
'AssignmentPoll',
'jsDataModel',
function(DS, jsDataModel) {
function (DS, AssignmentRelatedUser, AssignmentPoll, jsDataModel) {
var name = 'assignments/assignment';
return DS.defineResource({
name: name,
@ -27,6 +64,16 @@ angular.module('OpenSlidesApp.assignments', [])
localKey: 'agenda_item_id',
localField: 'agenda_item',
}
},
hasMany: {
'core/tag': {
localField: 'tags',
localKeys: 'tags_id',
},
'assignments/relateduser': {
localField: 'assignment_related_users',
foreignKey: 'assignment_id',
}
}
}
});

View File

@ -24,13 +24,18 @@
</a>
</div>
{{ assignment.agenda_item }}
Agenda Item: {{ assignment.agenda_item }}
<h3 translate>Description</h3>
<div class="white-space-pre-line">{{ assignment.description }}</div>
<h3 translate>Candidates</h3>
<!-- TODO -->
<ul>
<li ng-repeat="related_user in assignment.assignment_related_users" ng-if="related_user.status == 1">
User: {{ related_user.user.get_full_name() }}
</li>
</ul>
<h3 translate>Election result</h3>
<!-- TODO -->