def exists(self): """ Does the ticket already exist in the RT system? @return results: Evaluates to True if it exists, False if not. """ results = BIBCATALOG_SYSTEM.ticket_search(None, recordid=self.recid, queue=self.queue, subject=self.subject) return results
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 %(x_num)i tickets.", x_num=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 'text' in ticket_info: 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
def index(): """Editor index page.""" from invenio.legacy.bibedit.utils import get_record_templates from invenio.legacy.bibedit.engine import (get_available_kbs, get_available_fields_templates) # Add script data. record_templates = get_record_templates() record_templates.sort() tag_names = get_name_tags_all() protected_fields = ['001'] protected_fields.extend(cfg['CFG_BIBEDIT_PROTECTED_FIELDS'].split(',')) cern_site = 'false' if CFG_CERN_SITE: cern_site = 'true' data = { 'gRECORD_TEMPLATES': record_templates, 'gTAG_NAMES': tag_names, 'gPROTECTED_FIELDS': protected_fields, 'gINTERNAL_DOI_PROTECTION_LEVEL': CFG_BIBEDIT_INTERNAL_DOI_PROTECTION_LEVEL, 'gSITE_URL': CFG_SITE_URL, 'gSITE_RECORD': CFG_SITE_RECORD, 'gCERN_SITE': cern_site, 'gINSPIRE_SITE': CFG_INSPIRE_SITE, 'gHASH_CHECK_INTERVAL': cfg['CFG_BIBEDIT_JS_HASH_CHECK_INTERVAL'], 'gCHECK_SCROLL_INTERVAL': cfg['CFG_BIBEDIT_JS_CHECK_SCROLL_INTERVAL'], 'gSTATUS_ERROR_TIME': cfg['CFG_BIBEDIT_JS_STATUS_ERROR_TIME'], 'gSTATUS_INFO_TIME': cfg['CFG_BIBEDIT_JS_STATUS_INFO_TIME'], 'gCLONED_RECORD_COLOR': '"' + cfg['CFG_BIBEDIT_JS_CLONED_RECORD_COLOR'] + '"', 'gCLONED_RECORD_COLOR_FADE_DURATION': cfg['CFG_BIBEDIT_JS_CLONED_RECORD_COLOR_FADE_DURATION'], 'gNEW_ADD_FIELD_FORM_COLOR': '"' + cfg['CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR'] + '"', 'gNEW_ADD_FIELD_FORM_COLOR_FADE_DURATION': cfg['CFG_BIBEDIT_JS_NEW_ADD_FIELD_FORM_COLOR_FADE_DURATION'], 'gNEW_CONTENT_COLOR': '"' + cfg['CFG_BIBEDIT_JS_NEW_CONTENT_COLOR'] + '"', 'gNEW_CONTENT_COLOR_FADE_DURATION': cfg['CFG_BIBEDIT_JS_NEW_CONTENT_COLOR_FADE_DURATION'], 'gNEW_CONTENT_HIGHLIGHT_DELAY': cfg['CFG_BIBEDIT_JS_NEW_CONTENT_HIGHLIGHT_DELAY'], 'gTICKET_REFRESH_DELAY': cfg['CFG_BIBEDIT_JS_TICKET_REFRESH_DELAY'], 'gRESULT_CODES': cfg['CFG_BIBEDIT_AJAX_RESULT_CODES'], 'gAUTOSUGGEST_TAGS': cfg['CFG_BIBEDIT_AUTOSUGGEST_TAGS'], 'gAUTOCOMPLETE_TAGS': cfg['CFG_BIBEDIT_AUTOCOMPLETE_TAGS_KBS'].keys(), 'gKEYWORD_TAG': '"' + cfg['CFG_BIBEDIT_KEYWORD_TAG'] + '"', 'gREQUESTS_UNTIL_SAVE': cfg['CFG_BIBEDIT_REQUESTS_UNTIL_SAVE'], 'gAVAILABLE_KBS': get_available_kbs(), 'gDOILookupField': '"' + cfg['CFG_BIBEDIT_DOI_LOOKUP_FIELD'] + '"', 'gDisplayReferenceTags': cfg['CFG_BIBEDIT_DISPLAY_REFERENCE_TAGS'], 'gDisplayAuthorTags': cfg['CFG_BIBEDIT_DISPLAY_AUTHOR_TAGS'], 'gExcludeCuratorTags': cfg['CFG_BIBEDIT_EXCLUDE_CURATOR_TAGS'], 'gSHOW_HP_REMOVED_FIELDS': CFG_BIBEDIT_SHOW_HOLDING_PEN_REMOVED_FIELDS, 'gBIBCATALOG_SYSTEM_RT_URL': repr(CFG_BIBCATALOG_SYSTEM_RT_URL), 'gAutoComplete': json.dumps(CFG_BIBEDIT_AUTOCOMPLETE) } fieldTemplates = get_available_fields_templates() def convert(data): """Return JS friendly strings.""" if isinstance(data, unicode): return str(data) else: return json.dumps(data) for key in data: data[key] = convert(data[key]) try: BIBCATALOG_SYSTEM.ticket_search(0) can_search_for_ticket = True except NotImplementedError: can_search_for_ticket = False ctx = { "data": data, "fieldTemplates": json.dumps(fieldTemplates), "can_search_for_ticket": can_search_for_ticket } return render_template('editor/index.html', **ctx)