/
constants.py
99 lines (74 loc) · 2.58 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
# Standard Library
import inspect
def _user_attributes(cls):
defaults = dir(type(str('defaults'), (object,), {})) # gives all inbuilt attrs
return [
item[0] for item in inspect.getmembers(cls) if item[0] not in defaults]
def choices(cls):
"""
Decorator to set `CHOICES` and other attributes
"""
_choices = []
for attr in _user_attributes(cls):
val = getattr(cls, attr)
setattr(cls, attr[1:], val[0])
_choices.append((val[0], val[1]))
setattr(cls, 'CHOICES', tuple(_choices))
return cls
@choices
class ConferenceStatus:
_ACCEPTING_CFP = [1, "Accepting Proposals"]
_CLOSED_CFP = [2, "Proposal submission closed"]
_ACCEPTING_VOTES = [3, "Accepting Votes"]
_SCHEDULE_PUBLISHED = [4, "Schedule Published"]
@choices
class ProposalStatus:
_DRAFT = [1, "Draft"]
_PUBLIC = [2, "Public"]
_CANCELLED = [3, "Cancelled"]
@choices
class ProposalReviewStatus:
_YET_TO_BE_REVIEWED = [1, "Yet to be reviewed"]
_SELECTED = [2, "Selected"]
_REJECTED = [3, "Rejected"]
_ON_HOLD = [4, "On hold"]
_WAIT_LISTED = [5, "Wait-listed"]
@choices
class ProposalTargetAudience:
_BEGINNER = [1, "Beginner"]
_INTERMEDIATE = [2, "Intermediate"]
_ADVANCED = [3, "Advanced"]
@choices
class ProposalUserVoteRole:
_PUBLIC = [1, "Public"]
_REVIEWER = [2, "Reviewer"]
@choices
class ProposalReviewVote:
_MUST_HAVE = [2, "Must have"]
_GOOD = [1, "Good"]
_NOT_BAD = [0, "Not Bad"]
_NOT_ALLOWED = [-1, "Shouldn't be allowed"]
# FIXME: `ProposalReviewerComment` should be Boolean
@choices
class ProposalReviewerComment:
_COMMENTED = ['True', 'Yes']
_NOT_COMMENTED = ['False', 'No']
@choices
class ProposalVotesFilter:
_NO_VOTES = [0, "No votes"]
_MIN_ONE_VOTE = [1, "Minimum 1 vote"]
_SORT_BY_SUM = [2, "Sort by total votes"]
_SORT_BY_REVIEWER = [3, "Sort by your votes"]
class ConferenceSettingConstants:
ALLOW_PUBLIC_VOTING_ON_PROPOSALS = {
"name": "allow_public_voting_on_proposals",
"value": True,
"description": "Allow public to vote on proposals"}
DISPLAY_PROPOSALS_IN_PUBLIC = {"name": "display_proposals_in_public",
"value": True,
"description": "Display proposals in public"}
ALLOW_PLUS_ZERO_REVIEWER_VOTE = {"name": "allow_plus_zero_reviewer_vote",
"value": True,
"description": "Allow +0 vote in reviewer votes"}