Angular: Added js-data models for assignment poll candidates
This commit is contained in:
parent
6a4cc97469
commit
99ef185502
@ -24,4 +24,4 @@ class AssignmentsAppConfig(AppConfig):
|
||||
|
||||
# Register viewsets.
|
||||
router.register('assignments/assignment', AssignmentViewSet)
|
||||
router.register('assignments/assignmentpoll', AssignmentPollViewSet)
|
||||
router.register('assignments/poll', AssignmentPollViewSet)
|
||||
|
@ -50,7 +50,7 @@ class AssignmentOptionSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = AssignmentOption
|
||||
fields = ('candidate', 'votes',)
|
||||
fields = ('id', 'candidate', 'votes', 'poll')
|
||||
|
||||
|
||||
class FilterPollListSerializer(ListSerializer):
|
||||
|
@ -4,18 +4,45 @@
|
||||
|
||||
angular.module('OpenSlidesApp.assignments', [])
|
||||
|
||||
.factory('AssignmentPollOption', [
|
||||
'DS',
|
||||
function (DS) {
|
||||
return DS.defineResource({
|
||||
name: 'assignments/polloption',
|
||||
relations: {
|
||||
belongsTo: {
|
||||
'assignments/poll': {
|
||||
localField: 'poll',
|
||||
localKey: 'poll_id',
|
||||
},
|
||||
'users/user': {
|
||||
localField: 'candidate',
|
||||
localKey: 'candidate_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
])
|
||||
|
||||
.factory('AssignmentPoll', [
|
||||
'DS',
|
||||
'Config',
|
||||
function (DS, Config) {
|
||||
'AssignmentPollOption',
|
||||
function (DS, AssignmentPollOption) {
|
||||
return DS.defineResource({
|
||||
name: 'assignments/assignmentpoll',
|
||||
name: 'assignments/poll',
|
||||
relations: {
|
||||
belongsTo: {
|
||||
'assignments/assignment': {
|
||||
localField: 'assignment',
|
||||
localKey: 'assignment_id',
|
||||
}
|
||||
},
|
||||
hasMany: {
|
||||
'assignments/polloption': {
|
||||
localField: 'options',
|
||||
foreignKey: 'poll_id',
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -75,7 +102,7 @@ angular.module('OpenSlidesApp.assignments', [])
|
||||
localField: 'assignment_related_users',
|
||||
foreignKey: 'assignment_id',
|
||||
},
|
||||
'assignments/assignmentpoll': {
|
||||
'assignments/poll': {
|
||||
localField: 'polls',
|
||||
foreignKey: 'assignment_id',
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
|
||||
$scope.formFields.push(
|
||||
{
|
||||
noFormControl: true,
|
||||
template: '<strong>User#' + option.candidate_id + '</strong>'
|
||||
template: '<strong>' + option.candidate.get_full_name() + '</strong>'
|
||||
},
|
||||
{
|
||||
key: 'yes_' + option.candidate_id,
|
||||
|
Loading…
Reference in New Issue
Block a user