Esempio n. 1
0
def is_open_or_close():
    c = Config.query().get()
    if not c:
        c = Config()
        c.is_open = False
        c.put()
        return False
    return c.is_open
Esempio n. 2
0
def set_auth_secret(secret):
    """
    Sets the auth secret.
    """
    from models import Config
    secret_config = Config()
    secret_config.key = "auth_secret"
    secret_config.value = secret
    secret_config.put()
    return secret_config
Esempio n. 3
0
def save_config():
    try:
        data = json.loads(request.data)
        name = data['name']
        value = data['value']
        config = Config(
            name=name,
            value=value
        )
        config.put()
    except CapabilityDisabledError:
        logging.error(u'App Engine Datastore is currently in read-only mode.')
        abort(500)
    except BadValueError:
        abort(400)
    except TypeError:
        abort(400)
    except Exception as e:
        logging.error(e.args[0])
        abort(500)

    return Response(json.dumps(config.to_dict()), mimetype='application/json');
Esempio n. 4
0
def sendMailResult():
    # TODO: test this
    message = mail.EmailMessage(sender="MercatoLibero <*****@*****.**>",
                                subject="Risultati")
    users = User.query().fetch()
    to = ""
    for user in users:
        to += user.email + ";"
    message.to = to
    calls_open = Call.query(Call.status == "OPEN").fetch()
    status = Config.query().get()
    if not status:
        status = Config()
    status.is_open = True
    status.put()
    if len(calls_open) > 0:
        path = os.path.join(os.path.dirname(__file__), 'templates', 'mail_results.html')
        params = dict(open=[e.to_dict() for e in calls_open])
        res = template.render(path, params)
        for o in calls_open:
            o.status = "CLOSED"
            o.put()
        message.html = res
        message.send()
Esempio n. 5
0
 def get(self):
     status = Config.query().get()
     if not status:
         status = Config()
     status.is_open = False
     status.put()
Esempio n. 6
0
def set_open_or_closed(v):
    c = Config.query().get()
    if not c:
        c = Config()
    c.is_open = v
    c.put()
Esempio n. 7
0
import os
import logging
from models import Config
from utils import Storage

__all__ = [ 'config', 'settings', ]

logging.info('module config reloaded')

settings = Storage()

config = Config.get_by_key_name('default')

if not config:
	config = Config(key_name = 'default')
	config.put()

if not config.app_root:
	settings.app_root = ''
else:
	settings.app_root = '/' + config.app_root.strip('/ ')

settings.home_page = settings.app_root + '/'