예제 #1
0
파일: users.py 프로젝트: sigma/pysigbot
    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
예제 #2
0
파일: admin.py 프로젝트: sigma/pysigbot
    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))