예제 #1
0
def had_privilege(request, page_id, privilege_val):
    user = get_userinfo(request)
    user_page = UserPage.load(user_id=int(user.id), page_id=page_id)
    if not user_page:
        return False
    if user_page.value % privilege_val == 0:
        return True
    return False
예제 #2
0
def get_page_all_list(user_id):
    new_pages = []
    pages = Page.query()
    for p in pages:
        if not p:
            continue
        user_page = UserPage.load(user_id=int(user_id), page_id=p.page_id)
        if user_page:
            p.user_page_id = user_page.user_page_id
            p.value = user_page.value
            new_pages.append(p)
        else :
            p.user_page_id = 0
            p.value = 0
            new_pages.append(p)            
    return new_pages
예제 #3
0
 def replace_function(*args, **kwargs):  #被替换执行的函数,主要工作就在这里完成
     request = args[0]  #这里要求参数传进来,第一个必须是request对象
     user = user_roles.get_userinfo(request)
     user_page = UserPage.load(user_id=int(user.id), page_id=page_id)
     if not user_page:
         response = HttpResponseRedirect("/privilege_error/")
         return response
     value = user_page.value
     if value == 1:
         response = HttpResponseRedirect("/privilege_error/")
         return response
     if operator_id and operator_id == 1 and value % 2 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 2 and value % 3 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 3 and value % 5 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 4 and value % 7 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 5 and value % 11 == 0:
         return input_function(*args, **kwargs)
     else:
         response = HttpResponseRedirect("/privilege_error/")
         return response
예제 #4
0
 def replace_function(*args, **kwargs): #被替换执行的函数,主要工作就在这里完成
     request = args[0]#这里要求参数传进来,第一个必须是request对象
     user = user_roles.get_userinfo(request)
     user_page = UserPage.load(user_id=int(user.id), page_id=page_id)
     if not user_page:
         response = HttpResponseRedirect("/privilege_error/")
         return response
     value = user_page.value
     if value == 1:
         response = HttpResponseRedirect("/privilege_error/")
         return response
     if operator_id and operator_id == 1 and value % 2 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 2 and value % 3 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 3 and value % 5 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 4 and value % 7 == 0:
         return input_function(*args, **kwargs)
     if operator_id and operator_id == 5 and value % 11 == 0:
         return input_function(*args, **kwargs)
     else:
         response = HttpResponseRedirect("/privilege_error/")
         return response
예제 #5
0
def delete_userpage(user_page_id):
    user_page = UserPage.load(user_page_id = user_page_id)
    user_page.delete('user_page_id')
예제 #6
0
def delete_userpage(user_page_id):
    user_page = UserPage.load(user_page_id=user_page_id)
    user_page.delete('user_page_id')