def execute_action(action, pid, bibref, uid, gather_list, userinfo='', comment=''): ''' Executes the action, setting the last user right according to uid @param action: the action to perform @type action: string @param pid: the Person ID to perform the action on @type pid: int @param bibref: the bibref pair to perform the action for @type bibref: string @param uid: the internal user ID of the currently logged in user @type uid: int @return: success of the process @rtype: boolean ''' pid = wash_integer_id(pid) if not action in ['confirm', 'assign', 'repeal', 'reset']: return False elif pid < 0: return False elif pid == -3: pid = dbapi.create_new_person(uid, uid_is_owner=False) elif not is_valid_bibref(bibref): return False user_level = _resolve_maximum_acces_rights(uid)[1] if action in ['confirm', 'assign']: dbapi.insert_user_log(userinfo, pid, 'assign', 'CMPUI_ticketcommit', bibref, comment) dbapi.confirm_papers_to_person((str(pid), ), [[bibref]], gather_list, user_level) elif action in ['repeal']: dbapi.insert_user_log(userinfo, pid, 'repeal', 'CMPUI_ticketcommit', bibref, comment) dbapi.reject_papers_from_person((str(pid), ), [[bibref]], gather_list, user_level) elif action in ['reset']: dbapi.insert_user_log(userinfo, pid, 'reset', 'CMPUI_ticketcommit', bibref, comment) dbapi.reset_papers_flag((str(pid), ), [[bibref]], gather_list) else: return False #This is the only point which modifies a person, so this can trigger the #deletion of a cached page dbapi.delete_cached_author_page(pid) return True
def execute_action(action, pid, bibref, uid, userinfo='', comment=''): ''' Executes the action, setting the last user right according to uid @param action: the action to perform @type action: string @param pid: the Person ID to perform the action on @type pid: int @param bibref: the bibref pair to perform the action for @type bibref: string @param uid: the internal user ID of the currently logged in user @type uid: int @return: success of the process @rtype: boolean ''' pid = wash_integer_id(pid) if not action in ['confirm', 'assign', 'repeal', 'reset']: return False elif pid < 0: return False elif pid == -3: pid = dbapi.create_new_person(uid, uid_is_owner=False) elif not is_valid_bibref(bibref): return False if userinfo.count('||'): uid = userinfo.split('||')[0] else: uid = '' user_level = _resolve_maximum_acces_rights(uid)[1] if action in ['confirm', 'assign']: dbapi.insert_user_log(userinfo, pid, 'assign', 'CMPUI_ticketcommit', bibref, comment, userid=uid) dbapi.confirm_papers_to_person(pid, [bibref], user_level) elif action in ['repeal']: dbapi.insert_user_log(userinfo, pid, 'repeal', 'CMPUI_ticketcommit', bibref, comment, userid=uid) dbapi.reject_papers_from_person(pid, [bibref], user_level) elif action in ['reset']: dbapi.insert_user_log(userinfo, pid, 'reset', 'CMPUI_ticketcommit', bibref, comment, userid=uid) dbapi.reset_papers_flag(pid, [bibref]) else: return False #This is the only point which modifies a person, so this can trigger the #deletion of a cached page webauthorapi.expire_all_cache_for_personid(pid) return True
def execute_action(action, pid, bibref, uid, userinfo='', comment=''): ''' Executes the action, setting the last user right according to uid @param action: the action to perform @type action: string @param pid: the Person ID to perform the action on @type pid: int @param bibref: the bibref pair to perform the action for @type bibref: string @param uid: the internal user ID of the currently logged in user @type uid: int @return: list of a tuple: [(status, message), ] or None if something went wrong @rtype: [(bool, str), ] ''' pid = wash_integer_id(pid) if not action in ['confirm', 'assign', 'repeal', 'reset']: return None elif pid == -3: pid = dbapi.create_new_person(uid, uid_is_owner=False) elif pid < 0: return None elif not is_valid_bibref(bibref): return None if userinfo.count('||'): uid = userinfo.split('||')[0] else: uid = '' user_level = _resolve_maximum_acces_rights(uid)[1] res = None if action in ['confirm', 'assign']: dbapi.insert_user_log(userinfo, pid, 'assign', 'CMPUI_ticketcommit', bibref, comment, userid=uid) res = dbapi.confirm_papers_to_person(pid, [bibref], user_level) elif action in ['repeal']: dbapi.insert_user_log(userinfo, pid, 'repeal', 'CMPUI_ticketcommit', bibref, comment, userid=uid) res = dbapi.reject_papers_from_person(pid, [bibref], user_level) elif action in ['reset']: dbapi.insert_user_log(userinfo, pid, 'reset', 'CMPUI_ticketcommit', bibref, comment, userid=uid) res = dbapi.reset_papers_flag(pid, [bibref]) #This is the only point which modifies a person, so this can trigger the #deletion of a cached page webauthorapi.expire_all_cache_for_personid(pid) return res