Esempio n. 1
0
def org(
        name=settings.SUPER_USER_ORG,
        timezone=settings.SUPER_USER_ORG_TIMEZONE,
        email=settings.SUPER_USER_EMAIL):

    # create the org and super user
    org = Org.query.filter_by(name=name).first()
    if not org:
        log.info('Creating org: "{}"'.format(name))
        org = Org(name=name, timezone=timezone)
    else:
        log.warning('Updating org: "{}"'.format(name))
        org.timezone = timezone
        org.name = name
        org.slug = slug(unicode(name))

    # create the super user and add to the org.
    u = User.query.filter_by(email=email).first()
    if not u:
        log.info('Creating super user: "******"'.format(email))
        u = User(name=settings.SUPER_USER,
                 email=settings.SUPER_USER_EMAIL,
                 password=settings.SUPER_USER_PASSWORD,
                 admin=True,
                 super_user=True)
        u.apikey = settings.SUPER_USER_APIKEY

    else:
        log.warning('Updating super user: "******"'.format(email))
        u.apikey = settings.SUPER_USER_APIKEY
        u.email = settings.SUPER_USER_EMAIL
        u.password = settings.SUPER_USER_PASSWORD
        u.admin = True
        u.super_user = True
    org.users.append(u)
    db.session.add(org)
    db.session.commit()
    tags(org)
    sous_chefs(org)
    recipes(org)
    return org
Esempio n. 2
0
def org(name=settings.SUPER_USER_ORG,
        timezone=settings.SUPER_USER_ORG_TIMEZONE,
        email=settings.SUPER_USER_EMAIL):

    # create the org and super user
    org = Org.query.filter_by(name=name).first()
    if not org:
        log.info('Creating org: "{}"'.format(name))
        org = Org(name=name, timezone=timezone)
    else:
        log.warning('Updating org: "{}"'.format(name))
        org.timezone = timezone
        org.name = name
        org.slug = slug(unicode(name))

    # create the super user and add to the org.
    u = User.query.filter_by(email=email).first()
    if not u:
        log.info('Creating super user: "******"'.format(email))
        u = User(name=settings.SUPER_USER,
                 email=settings.SUPER_USER_EMAIL,
                 password=settings.SUPER_USER_PASSWORD,
                 admin=True,
                 super_user=True)
        u.apikey = settings.SUPER_USER_APIKEY

    else:
        log.warning('Updating super user: "******"'.format(email))
        u.apikey = settings.SUPER_USER_APIKEY
        u.email = settings.SUPER_USER_EMAIL
        u.password = settings.SUPER_USER_PASSWORD
        u.admin = True
        u.super_user = True
    org.users.append(u)
    db.session.add(org)
    db.session.commit()
    tags(org)
    sous_chefs(org)
    recipes(org)
    return org