コード例 #1
0
def perform_request_bibcatalog(request_type, recid, uid):
    """Handle request to BibCatalog (RT).

    """
    response = {}

    if request_type == 'getTickets':
        # Insert the ticket data in the response, if possible
        if uid:
            bibcat_resp = bibcatalog_system.check_system(uid)
            if bibcat_resp == "":
                tickets_found = bibcatalog_system.ticket_search(uid, status=['new', 'open'], recordid=recid)
                t_url_str = '' #put ticket urls here, formatted for HTML display
                for t_id in tickets_found:
                    #t_url = bibcatalog_system.ticket_get_attribute(uid, t_id, 'url_display')
                    ticket_info = bibcatalog_system.ticket_get_info(uid, t_id, ['url_display','url_close'])
                    t_url = ticket_info['url_display']
                    t_close_url = ticket_info['url_close']
                    #format..
                    t_url_str += "#"+str(t_id)+'<a href="'+t_url+'">[read]</a> <a href="'+t_close_url+'">[close]</a><br/>'
                #put ticket header and tickets links in the box
                t_url_str = "<strong>Tickets</strong><br/>"+t_url_str+"<br/>"+'<a href="new_ticket?recid='+str(recid)+'>[new ticket]<a>'
                response['tickets'] = t_url_str
                #add a new ticket link
            else:
                #put something in the tickets container, for debug
                response['tickets'] = "<!--"+bibcat_resp+"-->"
        response['resultCode'] = 31

    return response
コード例 #2
0
    def tmpl_your_tickets(self, uid, ln=CFG_SITE_LANG, start=1):
        """ make a pretty html body of tickets that belong to the user given as param """
        ln = wash_language(ln)
        _ = gettext_set_language(ln)
        # errors? tell what happened and get out
        bibcat_probs = bibcatalog_system.check_system(uid)
        if bibcat_probs:
            return _("Error") + " " + bibcat_probs

        tickets = bibcatalog_system.ticket_search(uid, owner=uid)  # get ticket id's
        lines = ""  # put result here
        iter = 1

        lines += _("You have ") + str(len(tickets)) + " " + _("tickets") + ".<br/>"

        # make a prev link if needed
        if start > 1:
            newstart = start - self.SHOW_MAX_TICKETS
            if newstart < 1:
                newstart = 1
            lines += '<a href="/yourtickets/display?start=' + str(newstart) + '">' + _("Previous") + "</a>"
        lines += """<table border="1">"""
        lastshown = len(tickets)  # what was the number of the last shown ticket?
        for ticket in tickets:
            # get info and show only for those that within the show range
            if (iter >= start) and (iter < start + self.SHOW_MAX_TICKETS):
                ticket_info = bibcatalog_system.ticket_get_info(uid, ticket)
                subject = ticket_info["subject"]
                status = ticket_info["status"]
                text = ""
                if ticket_info.has_key("text"):
                    text = ticket_info["text"]
                display = '<a href="' + ticket_info["url_display"] + '">' + _("show") + "</a>"
                close = '<a href="' + ticket_info["url_close"] + '">' + _("close") + "</a>"
                lines += (
                    "<tr><td>"
                    + str(ticket)
                    + "</td><td>"
                    + subject
                    + " "
                    + text
                    + "</td><td>"
                    + status
                    + "</td><td>"
                    + display
                    + "</td><td>"
                    + close
                    + "</td></tr>\n"
                )
                lastshown = iter
            iter = iter + 1
        lines += "</table>"

        # make next link if needed
        if len(tickets) > lastshown:
            newstart = lastshown + 1
            lines += '<a href="/yourtickets/display?start=' + str(newstart) + '">' + _("Next") + "</a>"
        return lines
コード例 #3
0
    def tmpl_your_tickets(self, uid, ln=CFG_SITE_LANG, start=1):
        """ make a pretty html body of tickets that belong to the user given as param """
        ln = wash_language(ln)
        _ = gettext_set_language(ln)
        if bibcatalog_system is None:
            return _("Error: No BibCatalog system configured.")
        #errors? tell what happened and get out
        bibcat_probs = bibcatalog_system.check_system(uid)
        if bibcat_probs:
            return _("Error") + " " + bibcat_probs

        tickets = bibcatalog_system.ticket_search(uid,
                                                  owner=uid)  #get ticket id's
        lines = ""  #put result here
        i = 1

        lines += (_("You have %i tickets.") % len(tickets)) + "<br/>"

        #make a prev link if needed
        if (start > 1):
            newstart = start - self.SHOW_MAX_TICKETS
            if (newstart < 1):
                newstart = 1
            lines += '<a href="/yourtickets/display?start=' + str(
                newstart) + '">' + _("Previous") + '</a>'
        lines += """<table border="1">"""
        lastshown = len(
            tickets)  #what was the number of the last shown ticket?
        for ticket in tickets:
            #get info and show only for those that within the show range
            if (i >= start) and (i < start + self.SHOW_MAX_TICKETS):
                ticket_info = bibcatalog_system.ticket_get_info(uid, ticket)
                subject = ticket_info['subject']
                status = ticket_info['status']
                text = ""
                if ticket_info.has_key('text'):
                    text = ticket_info['text']
                display = '<a href="' + ticket_info['url_display'] + '">' + _(
                    "show") + '</a>'
                close = '<a href="' + ticket_info['url_close'] + '">' + _(
                    "close") + '</a>'
                lines += "<tr><td>" + str(
                    ticket
                ) + "</td><td>" + subject + " " + text + "</td><td>" + status + "</td><td>" + display + "</td><td>" + close + "</td></tr>\n"
                lastshown = i
            i = i + 1
        lines += "</table>"

        #make next link if needed
        if (len(tickets) > lastshown):
            newstart = lastshown + 1
            lines += '<a href="/yourtickets/display?start=' + str(
                newstart) + '">' + _("Next") + '</a>'
        return lines
コード例 #4
0
    def tmpl_your_tickets(self, uid, ln=CFG_SITE_LANG, start=1):
        """ make a pretty html body of tickets that belong to the user given as param """
        ln = wash_language(ln)
        _ = gettext_set_language(ln)
        if bibcatalog_system is None:
            return _("Error: No BibCatalog system configured.")
        #errors? tell what happened and get out
        bibcat_probs = bibcatalog_system.check_system(uid)
        if bibcat_probs:
            return _("Error")+" "+bibcat_probs

        tickets = bibcatalog_system.ticket_search(uid, owner=uid) #get ticket id's
        lines = "" #put result here
        i = 1

        lines += (_("You have %i tickets.") % len(tickets)) + "<br/>"

        #make a prev link if needed
        if (start > 1):
            newstart = start - self.SHOW_MAX_TICKETS
            if (newstart < 1):
                newstart = 1
            lines += '<a href="/yourtickets/display?start='+str(newstart)+'">'+_("Previous")+'</a>'
        lines += """<table border="1">"""
        lastshown = len(tickets) #what was the number of the last shown ticket?
        for ticket in tickets:
            #get info and show only for those that within the show range
            if (i >= start) and (i < start+self.SHOW_MAX_TICKETS):
                ticket_info = bibcatalog_system.ticket_get_info(uid, ticket)
                subject = ticket_info['subject']
                status = ticket_info['status']
                text = ""
                if ticket_info.has_key('text'):
                    text = ticket_info['text']
                display = '<a href="'+ticket_info['url_display']+'">'+_("show")+'</a>'
                close = '<a href="'+ticket_info['url_close']+'">'+_("close")+'</a>'
                lines += "<tr><td>"+str(ticket)+"</td><td>"+subject+" "+text+"</td><td>"+status+"</td><td>"+display+"</td><td>"+close+"</td></tr>\n"
                lastshown = i
            i = i+1
        lines += "</table>"

        #make next link if needed
        if (len(tickets) > lastshown):
            newstart = lastshown+1
            lines += '<a href="/yourtickets/display?start='+str(newstart)+'">'+_("Next")+'</a>'
        return lines