Skip to content
Snippets Groups Projects
Verified Commit 5599cff9 authored by magicfelix's avatar magicfelix
Browse files

Add mulitple election support

parent d251803a
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ cfg_file = open("config.json", "r") ...@@ -21,7 +21,7 @@ cfg_file = open("config.json", "r")
cfg = loads(cfg_file.read()) cfg = loads(cfg_file.read())
cfg_file.close() cfg_file.close()
data_file = open("data-magicPrognos.json", "r") data_file = open("data-magicPrognos-" + cfg["election_id"] + ".json", "r")
data = loads(data_file.read()) data = loads(data_file.read())
data_file.close() data_file.close()
...@@ -56,7 +56,7 @@ def vote(): ...@@ -56,7 +56,7 @@ def vote():
system("clear") system("clear")
def saveToFile(): def saveToFile():
data_file = open("data-magicPrognos.json", "w") data_file = open("data-magicPrognos-" + cfg["election_id"] + ".json", "w")
data_file.write(dumps(data)) data_file.write(dumps(data))
data_file.close() data_file.close()
......
from json import dumps from json import dumps
conf = { conf = {
"election_id": "1",
"title": "Example election", "title": "Example election",
"min": 1, "min": 1,
"max": 1, "max": 1,
"stats_url": "https://prognos.example.org", "stats_url": "https://prognos.example.org",
"publish_cmd": "scp data-magicPrognos.json prognos@example.org:/path/to/magicPrognos-Web" "publish_cmd": "scp data-magicPrognos-x.json prognos@example.org:/path/to/magicPrognos-Web"
} }
for key in conf: for key in conf:
...@@ -23,6 +24,6 @@ cfg_file = open("config.json", "w") ...@@ -23,6 +24,6 @@ cfg_file = open("config.json", "w")
cfg_file.write(dumps(conf)) cfg_file.write(dumps(conf))
cfg_file.close() cfg_file.close()
data_file = open("data-magicPrognos.json", "w") data_file = open("data-magicPrognos-" + conf["election_id"] + ".json", "w")
data_file.write(dumps({"title": conf["title"], "parties": parties, "votes": {}})) data_file.write(dumps({"title": conf["title"], "parties": parties, "votes": {}}))
data_file.close() data_file.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment