99
1010
1111class  Election (models .Model ):
12- 
1312    class  Meta :
1413        ordering  =  ["-date" ]
1514
@@ -20,15 +19,20 @@ def __str__(self):
2019    date  =  models .DateField ()
2120    nominations_open_at  =  models .DateTimeField (blank = True , null = True )
2221    nominations_close_at  =  models .DateTimeField (blank = True , null = True )
22+     description  =  MarkupField (
23+         escape_html = True , markup_type = "markdown" , blank = False , null = True 
24+     )
2325
2426    slug  =  models .SlugField (max_length = 255 , blank = True , null = True )
2527
2628    @property  
2729    def  nominations_open (self ):
2830        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+             )
3236
3337        return  False 
3438
@@ -57,7 +61,6 @@ def save(self, *args, **kwargs):
5761
5862
5963class  Nominee (models .Model ):
60- 
6164    class  Meta :
6265        unique_together  =  ("user" , "election" )
6366
@@ -86,15 +89,19 @@ def name(self):
8689
8790    @property  
8891    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+         )
9297
9398    @property  
9499    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+         )
98105
99106    @property  
100107    def  self_nomination (self ):
@@ -106,7 +113,10 @@ def display_name(self):
106113
107114    @property  
108115    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+         ):
110120            return  self .self_nomination .previous_board_service 
111121
112122        return  self .nominations .first ().previous_board_service 
@@ -143,7 +153,6 @@ def save(self, *args, **kwargs):
143153
144154
145155class  Nomination (models .Model ):
146- 
147156    def  __str__ (self ):
148157        return  f"{ self .name }   <{ self .email }  >" 
149158
@@ -173,12 +182,18 @@ def __str__(self):
173182    approved  =  models .BooleanField (null = False , default = False )
174183
175184    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+         ):
177190            return  True 
178191
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+         ):
182197            return  True 
183198
184199        return  False 
0 commit comments