Exemplo n.º 1
0
    def __init__(self, email):
        self.email = email

        user = gusers.User(email)
        user_role = db.GqlQuery("SELECT * FROM DbUserRole WHERE account = :1", user).get()
        if user_role is None:
            user_role = DbUserRole(role=DbUserRole._USER_ROLE, account=user)
            user_role.put()
        self.db_role = user_role
Exemplo n.º 2
0
    def get(self):
        user = users.GetCurrentUser()

        u = db.GqlQuery("SELECT * FROM DbUserRole WHERE account = :1", user).get()
        if u is not None:
            u.role = DbUserRole._ADMIN_ROLE
            u.put()
        else:
            u = DbUserRole(role=DbUserRole._ADMIN_ROLE,
                           account=user)
            u.put()

        self.response.out.write("""Hello, %s. You're now defined as '%s'""" %
                                (user.nickname(), u.role))