"""
cala: The court allocation application

Copyright (C) 2017 Daniel J. Lauk <daniel.lauk@gmail.com>

cala is open sourced under the terms of the MIT license.
For details see LICENSE.md.
"""

import os
import sys
import tempfile

from flask import Flask, session, redirect, url_for, escape, request, abort, make_response

app = Flask(__name__)
app.config.from_object(__name__)
app.config.update(dict(
    DATABASE=os.path.join(tempfile.gettempdir(), 'cala.sqlite'),
    PASSWORD_SALT='development salt',
    SECRET_KEY='development key',
    FIRST_DAY_OF_WEEK=1,   # 1 = Monday ... 7 = Sunday
    LAST_DAY_OF_WEEK=5,    # 1 = Monday ... 7 = Sunday
    MIN_PASSWORD_LENGTH=6,
    MIN_PASSWORD_CLASSES=3,
    SHORT_NOTICE_START='08:00',  # short notice games can be booked past this time
    MAX_FREE_GAMES_PER_WEEK=1,
    BOOKING_POINTS_PER_WEEK=3,
    BOOKING_POINTS_WINDOW=(5, 3)   # (number of games, number of weeks)
))
app.config.from_envvar('CALA_SETTINGS', silent=True)


import cala.views
import cala.database
cala.database.init_db()
