Beispiel #1
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = RasPi()
        model.uuid = '11:22:33:44:55:66'
        model.description = "Testing Pi"
        model.url = "http://www.facebook.com"
        model.orientation = 0
        model.browser = True
        model.lastseen = datetime.now()
        DBSession.add(model)

        tag = Tags()
        tag.uuid = '11:22:33:44:55:66'
        tag.tag = 'test'
        DBSession.add(tag)

        User = UserModel()
        User.email = '*****@*****.**'
        User.AccessLevel = 2
        DBSession.add(User)

    DBSession.flush()
def make_an_admin(request):
    email = request.matchdict['email']
    '''First, make sure there aren't already admins in the system'''
    res = DBSession.query(UserModel).filter(UserModel.AccessLevel == 2).first()
    if res != None:
        msg = "User already an admin: {user}".format(user=res.email)
        return False
    user = DBSession.query(UserModel).filter(UserModel.email == email).first()
    if user == None:
        user = UserModel()
        user.email = email
        DBSession.add(user)
    user.AccessLevel = 2
    DBSession.flush()
    return True
def make_an_admin(request):
    email=request.matchdict['email']

    '''First, make sure there aren't already admins in the system'''
    res=DBSession.query(UserModel).filter(UserModel.AccessLevel==2).first()
    if res != None:
        msg="User already an admin: {user}".format(user=res.email)
        return False
    user=DBSession.query(UserModel).filter(UserModel.email==email).first()
    if user == None:
        user=UserModel()
        user.email=email
        DBSession.add(user)
    user.AccessLevel=2
    DBSession.flush()    
    return True
Beispiel #4
0
def login_complete_view(request):
  context = request.context
  result = {
    'provider_type': context.provider_type,
    'provider_name': context.provider_name,
    'profile': context.profile,
    'credentials': context.credentials,
  }
  email = context.profile['verifiedEmail']
  try:
    User = DBSession.query(UserModel).filter(UserModel.email==email).one()
  except NoResultFound, e:
    User = UserModel()
    User.email = email
    User.AccessLevel = 1
    DBSession.add(User)
    DBSession.flush()
Beispiel #5
0
def login_complete_view(request):
    context = request.context
    result = {
        'provider_type': context.provider_type,
        'provider_name': context.provider_name,
        'profile': context.profile,
        'credentials': context.credentials,
    }
    email = context.profile['verifiedEmail']
    try:
        User = DBSession.query(UserModel).filter(
            UserModel.email == email).one()
    except NoResultFound, e:
        User = UserModel()
        User.email = email
        User.AccessLevel = 1
        DBSession.add(User)
        DBSession.flush()