File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
templates/views/elections Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 1+ # Documentation
2+
3+ Primary elekto documentation is in [ the Elekto Docs repo] ( https://github.com/elekto-io/docs ) and not here. This directory contains some design documents from the early work on Elekto.
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ def __init__(self, key):
6363
6464 if not os .path .exists (self .path ):
6565 F .abort (404 )
66+ else :
67+ self .build ()
6668
6769 @staticmethod
6870 def all ():
@@ -133,6 +135,9 @@ def results(self):
133135
134136 def voters (self ):
135137 return utils .parse_yaml (os .path .join (self .path , Election .VOT ))
138+
139+ def showfields (self ):
140+ return dict .fromkeys (self .election ['show_candidate_fields' ], '' )
136141
137142 def candidates (self ):
138143 """
@@ -164,5 +169,11 @@ def candidate(self, cid):
164169 candidate ['key' ] = cid
165170 candidate ['description' ] = utils .parse_md (
166171 utils .extract_candidate_description (md ), False )
167-
172+ # return only the candidate optional fields that are listed in show_candidate_fields
173+ # unfilled fields are returned as '' so the label still displays
174+ candidate ['fields' ] = self .showfields ()
175+ for info in candidate ['info' ]:
176+ field = list (info .keys ())[0 ]
177+ if field in candidate ['fields' ]:
178+ candidate ['fields' ][field ] = info [field ]
168179 return candidate
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ <h1 class="banner-title space-lr">
2121 < p class ="banner-subtitle space-lr ">
2222 < small class ="badge badge-green " style ="text-transform: none; "> {{ candidate['ID'] }}</ small > | < span > Running for {{ election['name'] }}</ span >
2323 </ p >
24+ {% for fieldname, info in candidate['fields'].items() %}
25+ < p class ="banner-subtitle space-lr ">
26+ < small class ="badge badge-green " style ="text-transform: none; "> {{ fieldname }}</ small > | < span > {{ info }}</ span >
27+ </ p >
28+ {% endfor %}
2429 </ div >
2530 < div class ="space--md pb-1rem ">
2631 < div class ="description space-lr ">
You can’t perform that action at this time.
0 commit comments