added config for default poll type
This commit is contained in:
parent
b7b27d2e88
commit
fa63ef0307
@ -10,7 +10,7 @@ import {
|
||||
AssignmentPollMethod,
|
||||
AssignmentPollPercentBase
|
||||
} from 'app/shared/models/assignments/assignment-poll';
|
||||
import { MajorityMethod, VOTE_UNDOCUMENTED } from 'app/shared/models/poll/base-poll';
|
||||
import { MajorityMethod, PollType, VOTE_UNDOCUMENTED } from 'app/shared/models/poll/base-poll';
|
||||
import { ParsePollNumberPipe } from 'app/shared/pipes/parse-poll-number.pipe';
|
||||
import { PollKeyVerbosePipe } from 'app/shared/pipes/poll-key-verbose.pipe';
|
||||
import {
|
||||
@ -41,6 +41,8 @@ export class AssignmentPollService extends PollService {
|
||||
|
||||
public defaultPollMethod: AssignmentPollMethod;
|
||||
|
||||
public defaultPollType: PollType;
|
||||
|
||||
private sortByVote: boolean;
|
||||
|
||||
/**
|
||||
@ -66,6 +68,7 @@ export class AssignmentPollService extends PollService {
|
||||
config
|
||||
.get<AssignmentPollMethod>(AssignmentPoll.defaultPollMethodConfig)
|
||||
.subscribe(method => (this.defaultPollMethod = method));
|
||||
config.get<PollType>('assignment_poll_default_type').subscribe(type => (this.defaultPollType = type));
|
||||
config.get<boolean>('assignment_poll_sort_poll_result_by_votes').subscribe(sort => (this.sortByVote = sort));
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { ConstantsService } from 'app/core/core-services/constants.service';
|
||||
import { MotionPollRepositoryService } from 'app/core/repositories/motions/motion-poll-repository.service';
|
||||
import { ConfigService } from 'app/core/ui-services/config.service';
|
||||
import { MotionPoll, MotionPollMethod } from 'app/shared/models/motions/motion-poll';
|
||||
import { MajorityMethod, PercentBase } from 'app/shared/models/poll/base-poll';
|
||||
import { MajorityMethod, PercentBase, PollType } from 'app/shared/models/poll/base-poll';
|
||||
import { ParsePollNumberPipe } from 'app/shared/pipes/parse-poll-number.pipe';
|
||||
import { PollKeyVerbosePipe } from 'app/shared/pipes/poll-key-verbose.pipe';
|
||||
import { PollData, PollService, PollTableData, VotingResult } from 'app/site/polls/services/poll.service';
|
||||
@ -38,6 +38,8 @@ export class MotionPollService extends PollService {
|
||||
|
||||
public defaultGroupIds: number[];
|
||||
|
||||
public defaultPollType: PollType;
|
||||
|
||||
/**
|
||||
* Constructor. Subscribes to the configuration values needed
|
||||
* @param config ConfigService
|
||||
@ -57,6 +59,7 @@ export class MotionPollService extends PollService {
|
||||
config
|
||||
.get<MajorityMethod>('motion_poll_default_majority_method')
|
||||
.subscribe(method => (this.defaultMajorityMethod = method));
|
||||
config.get<PollType>('motion_poll_default_type').subscribe(type => (this.defaultPollType = type));
|
||||
|
||||
config.get<number[]>(MotionPoll.defaultGroupsConfig).subscribe(ids => (this.defaultGroupIds = ids));
|
||||
}
|
||||
|
@ -178,6 +178,11 @@ export abstract class PollService {
|
||||
*/
|
||||
public abstract defaultGroupIds: number[];
|
||||
|
||||
/**
|
||||
* The default poll type
|
||||
*/
|
||||
public abstract defaultPollType: PollType;
|
||||
|
||||
/**
|
||||
* The majority method currently in use
|
||||
*/
|
||||
@ -227,7 +232,7 @@ export abstract class PollService {
|
||||
onehundred_percent_base: this.defaultPercentBase,
|
||||
majority_method: this.defaultMajorityMethod,
|
||||
groups_id: this.defaultGroupIds,
|
||||
type: PollType.Analog
|
||||
type: this.defaultPollType
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ def get_config_variables():
|
||||
# Voting
|
||||
yield ConfigVariable(
|
||||
name="assignment_poll_method",
|
||||
default_value="votes",
|
||||
default_value=AssignmentPoll.POLLMETHOD_VOTES,
|
||||
input_type="choice",
|
||||
label="Default election method",
|
||||
choices=tuple(
|
||||
@ -25,9 +25,22 @@ def get_config_variables():
|
||||
subgroup="Ballot",
|
||||
)
|
||||
|
||||
yield ConfigVariable(
|
||||
name="assignment_poll_default_type",
|
||||
default_value=AssignmentPoll.TYPE_ANALOG,
|
||||
input_type="choice",
|
||||
label="Default type for assignment polls",
|
||||
choices=tuple(
|
||||
{"value": type[0], "display_name": type[1]} for type in AssignmentPoll.TYPES
|
||||
),
|
||||
weight=403,
|
||||
group="Elections",
|
||||
subgroup="Ballot",
|
||||
)
|
||||
|
||||
yield ConfigVariable(
|
||||
name="assignment_poll_default_100_percent_base",
|
||||
default_value="valid",
|
||||
default_value=AssignmentPoll.PERCENT_BASE_VALID,
|
||||
input_type="choice",
|
||||
label="Default 100 % base of an election result",
|
||||
choices=tuple(
|
||||
@ -51,7 +64,7 @@ def get_config_variables():
|
||||
|
||||
yield ConfigVariable(
|
||||
name="assignment_poll_default_majority_method",
|
||||
default_value="simple",
|
||||
default_value=AssignmentPoll.MAJORITY_SIMPLE,
|
||||
input_type="choice",
|
||||
choices=tuple(
|
||||
{"value": method[0], "display_name": method[1]}
|
||||
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 2.2.9 on 2020-05-13 09:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("assignments", "0012_assignment_vote_unique_together"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="assignmentpoll",
|
||||
name="type",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("analog", "analog"),
|
||||
("named", "nominal"),
|
||||
("pseudoanonymous", "non-nominal"),
|
||||
],
|
||||
max_length=64,
|
||||
),
|
||||
),
|
||||
]
|
@ -331,9 +331,22 @@ def get_config_variables():
|
||||
|
||||
# Voting and ballot papers
|
||||
|
||||
yield ConfigVariable(
|
||||
name="motion_poll_default_type",
|
||||
default_value=MotionPoll.TYPE_ANALOG,
|
||||
input_type="choice",
|
||||
label="Default type for motion polls",
|
||||
choices=tuple(
|
||||
{"value": type[0], "display_name": type[1]} for type in MotionPoll.TYPES
|
||||
),
|
||||
weight=367,
|
||||
group="Motions",
|
||||
subgroup="Voting and ballot papers",
|
||||
)
|
||||
|
||||
yield ConfigVariable(
|
||||
name="motion_poll_default_100_percent_base",
|
||||
default_value="YNA",
|
||||
default_value=MotionPoll.PERCENT_BASE_YNA,
|
||||
input_type="choice",
|
||||
label="Default 100 % base of a voting result",
|
||||
choices=tuple(
|
||||
@ -347,7 +360,7 @@ def get_config_variables():
|
||||
|
||||
yield ConfigVariable(
|
||||
name="motion_poll_default_majority_method",
|
||||
default_value="simple",
|
||||
default_value=MotionPoll.MAJORITY_SIMPLE,
|
||||
input_type="choice",
|
||||
choices=tuple(
|
||||
{"value": method[0], "display_name": method[1]}
|
||||
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 2.2.9 on 2020-05-13 09:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("motions", "0035_motion_vote_unique_together"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="motionpoll",
|
||||
name="type",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("analog", "analog"),
|
||||
("named", "nominal"),
|
||||
("pseudoanonymous", "non-nominal"),
|
||||
],
|
||||
max_length=64,
|
||||
),
|
||||
),
|
||||
]
|
@ -116,9 +116,9 @@ class BasePoll(models.Model):
|
||||
TYPE_NAMED = "named"
|
||||
TYPE_PSEUDOANONYMOUS = "pseudoanonymous"
|
||||
TYPES = (
|
||||
(TYPE_ANALOG, "Analog"),
|
||||
(TYPE_NAMED, "Named"),
|
||||
(TYPE_PSEUDOANONYMOUS, "Pseudoanonymous"),
|
||||
(TYPE_ANALOG, "analog"),
|
||||
(TYPE_NAMED, "nominal"),
|
||||
(TYPE_PSEUDOANONYMOUS, "non-nominal"),
|
||||
)
|
||||
type = models.CharField(max_length=64, blank=False, null=False, choices=TYPES)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user