From 7ef8c3e197f9ab58446702171cf15b1338cd0c75 Mon Sep 17 00:00:00 2001 From: cookietime--yay Date: Wed, 6 Mar 2019 19:40:02 +0100 Subject: [PATCH] Fix more path issues and add aliases file path to config. --- ticketfrei/config.py | 1 + ticketfrei/config.toml.example | 1 + ticketfrei/db.py | 2 +- ticketfrei/frontend.py | 4 ++-- ticketfrei/template/settings.tpl | 5 +++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ticketfrei/config.py b/ticketfrei/config.py index c99ca92..9c20c3c 100755 --- a/ticketfrei/config.py +++ b/ticketfrei/config.py @@ -4,6 +4,7 @@ import os ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) TEMPLATE_DIR = os.path.join(ROOT_DIR, 'template', '') STATIC_DIR = os.path.join(ROOT_DIR, 'static', '') +BOT_DIR = os.path.join(ROOT_DIR, 'bots') def load_env(): """ diff --git a/ticketfrei/config.toml.example b/ticketfrei/config.toml.example index ff54708..ee5282a 100644 --- a/ticketfrei/config.toml.example +++ b/ticketfrei/config.toml.example @@ -11,6 +11,7 @@ contact = "b3yond@riseup.net" [mail] mbox_user = "root" +aliases_path = "/etc/aliases" [database] db_path = "/var/ticketfrei/db.sqlite" diff --git a/ticketfrei/db.py b/ticketfrei/db.py index 61100ae..3b3acfb 100644 --- a/ticketfrei/db.py +++ b/ticketfrei/db.py @@ -243,7 +243,7 @@ u\d\d?""" (uid, "bastard")) else: uid = json['uid'] - with open("/etc/aliases", "a+") as f: + with open(config['mail']['aliases_path'], "a+") as f: f.write(city + ": " + config["mail"]["mbox_user"] + "\n") self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);", (uid, json['email'])) diff --git a/ticketfrei/frontend.py b/ticketfrei/frontend.py index b0a4d14..52ee5e1 100755 --- a/ticketfrei/frontend.py +++ b/ticketfrei/frontend.py @@ -95,8 +95,8 @@ def city_page(city, info=None): citydict = db.user_facing_properties(city) if citydict is not None: citydict['info'] = info - return bottle.template('template/city.tpl', **citydict) - return bottle.template('template/propaganda.tpl', + return bottle.template('city.tpl', **citydict) + return bottle.template('propaganda.tpl', **dict(info='There is no Ticketfrei bot in your city' ' yet. Create one yourself!')) diff --git a/ticketfrei/template/settings.tpl b/ticketfrei/template/settings.tpl index 2587491..995ac24 100644 --- a/ticketfrei/template/settings.tpl +++ b/ticketfrei/template/settings.tpl @@ -9,11 +9,12 @@ <% # import all the settings templates from bots/*/settings.tpl +from config import BOT_DIR import os -bots = os.listdir('bots') +bots = os.listdir(BOT_DIR) for bot in bots: - include('bots/' + bot + '/settings.tpl', csrf=csrf, city=city) + include(os.path.join(BOT_DIR, bot, 'settings.tpl'), csrf=csrf, city=city) end %>