Exemplo n.º 1
0
def delete_transaction_from_request_ticket(pid, tid, action, bibref):
    '''
    Deletes a transaction from a ticket. If ticket empty, deletes it.
    @param pid: pid
    @param tid: ticket id
    @param action: action
    @param bibref: bibref
    '''
    rt = get_person_request_ticket(pid, tid)
    if len(rt) > 0:
#        rt_num = rt[0][1]
        rt = rt[0][0]
    else:
        return
    for t in list(rt):
        if str(t[0]) == str(action) and str(t[1]) == str(bibref):
            rt.remove(t)

    action_present = False
    for t in rt:
        if str(t[0]) in ['confirm', 'repeal']:
            action_present = True

    if not action_present:
        delete_request_ticket(pid, tid)
        return

    tu.update_request_ticket(pid, rt, tid)
Exemplo n.º 2
0
def create_request_ticket(userinfo, ticket):
    '''
    Creates a request ticket
    @param usernfo: dictionary of info about user
    @param ticket: dictionary ticket
    '''
    # write ticket to DB
    # send eMail to RT
    udata = []
    mailcontent = []
    m = mailcontent.append
    m("A user sent a change request through the web interface.")
    m("User Information:")

    for k, v in userinfo.iteritems():
        if v:
            m("    %s: %s" % (k, v))

    m("\nLinks to all issued Person-based requests:\n")

    for i in userinfo:
        udata.append([i, userinfo[i]])

    tic = {}
    for t in ticket:
        if not t['action'] in ['confirm', 'assign', 'repeal', 'reset']:
            return False
        elif t['pid'] < 0:
            return False
        elif not is_valid_bibref(t['bibref']):
            return False
        if t['action'] == 'reset':
            #we ignore reset tickets
            continue
        else:
            if t['pid'] not in tic:
                tic[t['pid']] = []
        if t['action'] == 'assign':
            t['action'] = 'confirm'

        tic[t['pid']].append([t['action'], t['bibref']])

    for pid in tic:
        data = []
        for i in udata:
            data.append(i)
        data.append(['date', ctime()])
        for i in tic[pid]:
            data.append(i)
        tu.update_request_ticket(pid, data)
        pidlink = get_person_redirect_link(pid)

        m("%s/person/%s?open_claim=True#tabTickets" % (CFG_SITE_URL, pidlink))

    m("\nPlease remember that you have to be logged in "
      "in order to see the ticket of a person.\n")

    if ticket and tic and mailcontent:
        sender = CFG_BIBAUTHORID_AUTHOR_TICKET_ADMIN_EMAIL

        if bconfig.TICKET_SENDING_FROM_USER_EMAIL and userinfo['email']:
            sender = userinfo['email']

        send_email(sender,
                   CFG_BIBAUTHORID_AUTHOR_TICKET_ADMIN_EMAIL,
                   subject="[Author] Change Request",
                   content="\n".join(mailcontent))

    return True