diff --git a/docs/README.md b/docs/README.md index e69de29..ea9021b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Documentation + +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. diff --git a/elekto/models/meta.py b/elekto/models/meta.py index 442f80c..ae2c85a 100644 --- a/elekto/models/meta.py +++ b/elekto/models/meta.py @@ -63,6 +63,8 @@ def __init__(self, key): if not os.path.exists(self.path): F.abort(404) + else: + self.build() @staticmethod def all(): @@ -133,6 +135,9 @@ def results(self): def voters(self): return utils.parse_yaml(os.path.join(self.path, Election.VOT)) + + def showfields(self): + return dict.fromkeys(self.election['show_candidate_fields'], '') def candidates(self): """ @@ -164,5 +169,11 @@ def candidate(self, cid): candidate['key'] = cid candidate['description'] = utils.parse_md( utils.extract_candidate_description(md), False) - + # return only the candidate optional fields that are listed in show_candidate_fields + # unfilled fields are returned as '' so the label still displays + candidate['fields'] = self.showfields() + for info in candidate['info']: + field = list(info.keys())[0] + if field in candidate['fields']: + candidate['fields'][field] = info[field] return candidate diff --git a/elekto/templates/views/elections/candidate.html b/elekto/templates/views/elections/candidate.html index 2237160..f2763db 100644 --- a/elekto/templates/views/elections/candidate.html +++ b/elekto/templates/views/elections/candidate.html @@ -21,6 +21,11 @@