Fix more path issues and add aliases file path to config.

refactoring
cookietime--yay 2019-03-06 19:40:02 +01:00
parent 768a4350bd
commit 7ef8c3e197
5 changed files with 8 additions and 5 deletions

View File

@ -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():
"""

View File

@ -11,6 +11,7 @@ contact = "b3yond@riseup.net"
[mail]
mbox_user = "root"
aliases_path = "/etc/aliases"
[database]
db_path = "/var/ticketfrei/db.sqlite"

View File

@ -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']))

View File

@ -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!'))

View File

@ -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
%>