9
9
10
10
11
11
class Election (models .Model ):
12
-
13
12
class Meta :
14
13
ordering = ["-date" ]
15
14
@@ -20,15 +19,20 @@ def __str__(self):
20
19
date = models .DateField ()
21
20
nominations_open_at = models .DateTimeField (blank = True , null = True )
22
21
nominations_close_at = models .DateTimeField (blank = True , null = True )
22
+ description = MarkupField (
23
+ escape_html = True , markup_type = "markdown" , blank = False , null = True
24
+ )
23
25
24
26
slug = models .SlugField (max_length = 255 , blank = True , null = True )
25
27
26
28
@property
27
29
def nominations_open (self ):
28
30
if self .nominations_open_at and self .nominations_close_at :
29
- return self .nominations_open_at < datetime .datetime .now (
30
- datetime .timezone .utc
31
- ) < self .nominations_close_at
31
+ return (
32
+ self .nominations_open_at
33
+ < datetime .datetime .now (datetime .timezone .utc )
34
+ < self .nominations_close_at
35
+ )
32
36
33
37
return False
34
38
@@ -57,7 +61,6 @@ def save(self, *args, **kwargs):
57
61
58
62
59
63
class Nominee (models .Model ):
60
-
61
64
class Meta :
62
65
unique_together = ("user" , "election" )
63
66
@@ -86,15 +89,19 @@ def name(self):
86
89
87
90
@property
88
91
def nominations_received (self ):
89
- return self .nominations .filter (accepted = True , approved = True ).exclude (
90
- nominator = self .user
91
- ).all ()
92
+ return (
93
+ self .nominations .filter (accepted = True , approved = True )
94
+ .exclude (nominator = self .user )
95
+ .all ()
96
+ )
92
97
93
98
@property
94
99
def nominations_pending (self ):
95
- return self .nominations .exclude (accepted = False , approved = False ).exclude (
96
- nominator = self .user
97
- ).all ()
100
+ return (
101
+ self .nominations .exclude (accepted = False , approved = False )
102
+ .exclude (nominator = self .user )
103
+ .all ()
104
+ )
98
105
99
106
@property
100
107
def self_nomination (self ):
@@ -106,7 +113,10 @@ def display_name(self):
106
113
107
114
@property
108
115
def display_previous_board_service (self ):
109
- if self .self_nomination is not None and self .self_nomination .previous_board_service :
116
+ if (
117
+ self .self_nomination is not None
118
+ and self .self_nomination .previous_board_service
119
+ ):
110
120
return self .self_nomination .previous_board_service
111
121
112
122
return self .nominations .first ().previous_board_service
@@ -143,7 +153,6 @@ def save(self, *args, **kwargs):
143
153
144
154
145
155
class Nomination (models .Model ):
146
-
147
156
def __str__ (self ):
148
157
return f"{ self .name } <{ self .email } >"
149
158
@@ -173,12 +182,18 @@ def __str__(self):
173
182
approved = models .BooleanField (null = False , default = False )
174
183
175
184
def editable (self , user = None ):
176
- if self .nominee and user == self .nominee .user and self .election .nominations_open :
185
+ if (
186
+ self .nominee
187
+ and user == self .nominee .user
188
+ and self .election .nominations_open
189
+ ):
177
190
return True
178
191
179
- if user == self .nominator and not (
180
- self .accepted or self .approved
181
- ) and self .election .nominations_open :
192
+ if (
193
+ user == self .nominator
194
+ and not (self .accepted or self .approved )
195
+ and self .election .nominations_open
196
+ ):
182
197
return True
183
198
184
199
return False
0 commit comments