def update_person_canonical_name(person_id, canonical_name, userinfo=''):
    '''
    Updates a person's canonical name
    @param person_id: person id
    @param canonical_name: string 
    '''
    tu.update_personID_canonical_names(persons_list=[[person_id]], overwrite=True, suggested=canonical_name)
    tu.insert_user_log(userinfo, person_id, 'data_update', 'CMPUI_changecanonicalname', '', 'Canonical name manually updated.')
def log(userinfo, personid, action, tag, value, comment='', transactionid=0):
    '''
    Log an action performed by a user

    Examples (in the DB):
    1 2010-09-30 19:30  admin||10.0.0.1  1  assign  paper  1133:4442 'from 23'
    1 2010-09-30 19:30  admin||10.0.0.1  1  assign  paper  8147:4442
    2 2010-09-30 19:35  admin||10.0.0.1  1  reject  paper  72:4442

    @param userinfo: information about the user [UID|IP]
    @type userinfo: string
    @param personid: ID of the person this action is targeting
    @type personid: int
    @param action: intended action
    @type action: string
    @param tag: A tag to describe the data entered
    @type tag: string
    @param value: The value of the action described by the tag
    @type value: string
    @param comment: Optional comment to describe the transaction
    @type comment: string
    @param transactionid: May group bulk operations together
    @type transactionid: int

    @return: Returns the current transactionid
    @rtype: int
    '''
    userinfo = escape(str(userinfo))
    action = escape(str(action))
    tag = escape(str(tag))
    value = escape(str(value))
    comment = escape(str(comment))

    if not isinstance(personid, int):
        try:
            personid = int(personid)
        except (ValueError, TypeError):
            return - 1

    if not isinstance(transactionid, int):
        try:
            transactionid = int(transactionid)
        except (ValueError, TypeError):
            return - 1

    return tu.insert_user_log(userinfo, personid, action, tag,
                       value, comment, transactionid)
示例#3
0
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 = tu.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']:
        tu.insert_user_log(userinfo, pid, 'assign', 'CMPUI_ticketcommit',
                           bibref, comment)
        tu.confirm_papers_to_person([pid], [[bibref]], user_level)
    elif action in ['repeal']:
        tu.insert_user_log(userinfo, pid, 'repeal', 'CMPUI_ticketcommit',
                           bibref, comment)
        tu.reject_papers_from_person([pid], [[bibref]], user_level)
    elif action in ['reset']:
        tu.insert_user_log(userinfo, pid, 'reset', 'CMPUI_ticketcommit',
                           bibref, comment)
        tu.reset_papers_flag([pid], [[bibref]])
    else:
        return False
    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 = tu.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']:
        tu.insert_user_log(userinfo, pid, 'assign', 'CMPUI_ticketcommit', bibref, comment)
        tu.confirm_papers_to_person([pid], [[bibref]], user_level)
    elif action in ['repeal']:
        tu.insert_user_log(userinfo, pid, 'repeal', 'CMPUI_ticketcommit', bibref, comment)
        tu.reject_papers_from_person([pid], [[bibref]], user_level)
    elif action in ['reset']:
        tu.insert_user_log(userinfo, pid, 'reset', 'CMPUI_ticketcommit', bibref, comment)
        tu.reset_papers_flag([pid], [[bibref]])
    else:
        return False
    return True