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