예제 #1
0
 def _attachment_unique_id(self, attachment, add_prefix=True):
     if attachment.legacy_mapping:
         unique_id = 'm{}.{}'.format(attachment.legacy_mapping.material_id, attachment.legacy_mapping.resource_id)
     else:
         unique_id = 'a{}'.format(attachment.id)
     unique_id = '{}{}'.format(uniqueId(attachment.folder.object), unique_id)
     return 'INDICO.{}'.format(unique_id) if add_prefix else unique_id
예제 #2
0
파일: output.py 프로젝트: OmeGak/indico
 def _attachment_unique_id(self, attachment, add_prefix=True):
     if attachment.legacy_mapping:
         unique_id = 'm{}.{}'.format(attachment.legacy_mapping.material_id, attachment.legacy_mapping.resource_id)
     else:
         unique_id = 'a{}'.format(attachment.id)
     unique_id = '{}{}'.format(uniqueId(attachment.folder.object), unique_id)
     return 'INDICO.{}'.format(unique_id) if add_prefix else unique_id
예제 #3
0
파일: output.py 프로젝트: imfht/flaskapps
 def _attachment_unique_id(self, attachment, add_prefix=True):
     if attachment.legacy_mapping:
         unique_id = f'm{attachment.legacy_mapping.material_id}.{attachment.legacy_mapping.resource_id}'
     else:
         unique_id = f'a{attachment.id}'
     unique_id = '{}{}'.format(uniqueId(attachment.folder.object),
                               unique_id)
     return f'INDICO.{unique_id}' if add_prefix else unique_id
예제 #4
0
파일: output.py 프로젝트: OmeGak/indico
 def noteToXMLMarc21(self, note, out=None):
     if not out:
         out = self._XMLGen
     out.openTag('datafield', [['tag', '856'], ['ind1', '4'], ['ind2', ' ']])
     out.writeTag('subfield', url_for('event_notes.view', note, _external=True), [['code', 'u']])
     out.writeTag('subfield', u'{} - Minutes'.format(note.object.title), [['code', 'y']])
     out.writeTag('subfield', 'INDICO.{}'.format(uniqueId(note)), [['code', '3']])
     out.writeTag('subfield', 'resource', [['code', 'x']])
     out.closeTag('datafield')
예제 #5
0
 def noteToXMLMarc21(self, note, out=None):
     if not out:
         out = self._XMLGen
     out.openTag('datafield', [['tag', '856'], ['ind1', '4'], ['ind2', ' ']])
     out.writeTag('subfield', url_for('event_notes.view', note, _external=True), [['code', 'u']])
     out.writeTag('subfield', u'{} - Minutes'.format(note.object.title), [['code', 'y']])
     out.writeTag('subfield', 'INDICO.{}'.format(uniqueId(note)), [['code', '3']])
     out.writeTag('subfield', 'resource', [['code', 'x']])
     out.closeTag('datafield')
예제 #6
0
    def _add(self, obj, actions):
        """
        Adds a provided object to the temporary index.
        Actions: ['moved','deleted',..]
        """

        cm_set = ContextManager.get('indico.ext.livesync:actions').setdefault(
            obj, set([]))

        # the context may not be initialized
        if cm_set != None:
            cm_set |= set(actions)
        uid = uniqueId(obj)
        if uid is not None and uid != '':
            ContextManager.get('indico.ext.livesync:ids').setdefault(obj, uid)
예제 #7
0
    def _add(self, obj, actions):
        """
        Adds a provided object to the temporary index.
        Actions: ['moved','deleted',..]
        """

        cm_set = ContextManager.get('indico.ext.livesync:actions').setdefault(
            obj, set([]))

        # the context may not be initialized
        if cm_set != None:
            cm_set |= set(actions)
        uid = uniqueId(obj)
        if uid is not None and uid != '':
            ContextManager.get('indico.ext.livesync:ids').setdefault(
                obj, uid)
예제 #8
0
파일: output.py 프로젝트: OmeGak/indico
    def _subcontrib_to_marc_xml_21(self, subcontrib, includeMaterial=1, out=None):
        if not out:
            out = self._XMLGen

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",[["tag","035"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(subcontrib)), [["code", "a"]])
        out.closeTag("datafield")
    #
        out.openTag("datafield",[["tag","035"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", uniqueId(subcontrib), [["code", "a"]])
        out.writeTag("subfield","Indico",[["code","9"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","245"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", subcontrib.title, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","300"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", subcontrib.duration, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","111"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", uniqueId(subcontrib.event_new), [["code", "g"]])
        out.closeTag("datafield")

        self._generate_references(subcontrib, out)
        self._generate_category_path(subcontrib.event_new, out)
        self._generate_contrib_location_and_time(subcontrib.contribution, out)
    #
        out.openTag("datafield",[["tag","520"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", subcontrib.description, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","611"],["ind1","2"],["ind2","4"]])
        out.writeTag("subfield", subcontrib.event_new.title, [["code", "a"]])
        out.closeTag("datafield")
    #
        out.openTag("datafield",[["tag","650"],["ind1","1"],["ind2","7"]])
        out.writeTag("subfield","SzGeCERN",[["code","2"]])
        if subcontrib.contribution.track:
            out.writeTag("subfield", subcontrib.contribution.track.title, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_contrib_people(contrib=subcontrib.contribution, out=out, subcontrib=subcontrib)

        if includeMaterial:
            self.materialToXMLMarc21(subcontrib, out=out)

        if subcontrib.note:
            self.noteToXMLMarc21(subcontrib.note, out=out)

        out.openTag("datafield",[["tag","962"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(subcontrib.event_new)), [["code", "b"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","970"],["ind1"," "],["ind2"," "]])
        confcont = 'INDICO.{}'.format(uniqueId(subcontrib))
        out.writeTag("subfield",confcont,[["code","a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","980"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", self._getRecordCollection(subcontrib), [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(url_for('contributions.display_contribution', subcontrib.contribution,
                                          _external=True), 'Contribution details', out)

        self._generate_link_field(url_for('event.conferenceDisplay', subcontrib.event_new, _external=True),
                                  'Event details', out)

        self._generateAccessList(subcontrib.contribution, out, objId=uniqueId(subcontrib))
예제 #9
0
파일: output.py 프로젝트: OmeGak/indico
    def _contrib_to_marc_xml_21(self, contrib, include_material=1, out=None):
        if not out:
            out = self._XMLGen

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield", [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", "INDICO.%s" % uniqueId(contrib), [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(contrib), [["code", "a"]])
        out.writeTag("subfield", "Indico", [["code", "9"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "245"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.title, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "300"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.duration, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "111"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(contrib.event_new), [["code", "g"]])
        out.closeTag("datafield")

        # TODO: Adapt modification date once in the model
        out.openTag("datafield", [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", datetime.now().strftime('%Y-%m-%dT'), [["code", "c"]])
        out.closeTag("datafield")

        self._generate_category_path(contrib.event_new, out)

        self._generate_contrib_location_and_time(contrib, out)

        out.openTag("datafield", [["tag", "520"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.description, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "611"], ["ind1", "2"], ["ind2", "4"]])
        out.writeTag("subfield", contrib.event_new.title, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_references(contrib, out)

        out.openTag("datafield", [["tag", "653"], ["ind1", "1"], ["ind2", " "]])
        for keyword in contrib.keywords:
            out.writeTag("subfield", keyword, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","650"],["ind1","1"],["ind2","7"]])
        out.writeTag("subfield","SzGeCERN",[["code","2"]])
        if contrib.track:
            out.writeTag("subfield", contrib.track.title, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_contrib_people(contrib=contrib, out=out)

        if include_material:
            self.materialToXMLMarc21(contrib, out=out)

        if contrib.note:
            self.noteToXMLMarc21(contrib.note, out=out)

        out.openTag("datafield",[["tag","962"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(contrib.event_new)), [["code", "b"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","970"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(contrib)), [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","980"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", self._getRecordCollection(contrib), [["code","a"]])
        out.closeTag("datafield")

        self._generate_link_field(url_for('contributions.display_contribution', contrib, _external=True),
                                  'Contribution details', out)

        self._generate_link_field(url_for('event.conferenceDisplay', contrib.event_new, _external=True),
                                  'Event details', out)

        self._generateAccessList(contrib, out, objId=uniqueId(contrib))
예제 #10
0
파일: output.py 프로젝트: OmeGak/indico
    def _event_to_xml_marc_21(self, event, includeSession=1, includeContribution=1, includeMaterial=1, out=None):
        if not out:
            out = self._XMLGen

        out.openTag("datafield",[["tag","245"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        out.closeTag("datafield")

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",[["tag","111"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        event_location_info = []
        if event.venue_name:
            event_location_info.append(event.venue_name)
        if event.address:
            event_location_info.append(event.address)
        event_room = event.get_room_name(full=False)
        if event_room:
            event_location_info.append(event_room)
        out.writeTag("subfield", ', '.join(event_location_info), [["code", "c"]])

        sd = event.start_dt
        ed = event.end_dt
        out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(sd.year, string.zfill(sd.month,2), string.zfill(sd.day,2), string.zfill(sd.hour,2), string.zfill(sd.minute,2)),[["code","9"]])
        out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(ed.year, string.zfill(ed.month,2), string.zfill(ed.day,2), string.zfill(ed.hour,2), string.zfill(ed.minute,2)),[["code","z"]])

        out.writeTag("subfield", uniqueId(event), [["code", "g"]])
        out.closeTag("datafield")

        self._generate_category_path(event, out)

        ####################################
        # Fermi timezone awareness         #
        ####################################
        #if conf.getStartDate() is not None:
        #    out.openTag("datafield",[["tag","518"],["ind1"," "],["ind2"," "]])
        #    out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(conf.getStartDate().year, string.zfill(conf.getStartDate().month,2), string.zfill(conf.getStartDate().day,2), string.zfill(conf.getStartDate().hour,2), string.zfill(conf.getStartDate().minute,2)),[["code","d"]])
        #    out.closeTag("datafield")
        #sd = conf.getAdjustedStartDate(tz)
        sd = event.start_dt
        if sd is not None:
            out.openTag("datafield",[["tag","518"],["ind1"," "],["ind2"," "]])
            out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(sd.year, string.zfill(sd.month,2), string.zfill(sd.day,2), string.zfill(sd.hour,2), string.zfill(sd.minute,2)),[["code","d"]])
            out.closeTag("datafield")
        ####################################
        # Fermi timezone awareness(end)    #
        ####################################

        out.openTag("datafield",[["tag","520"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.description, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_references(event, out)

        out.openTag("datafield",[["tag","653"],["ind1","1"],["ind2"," "]])
        for keyword in event.keywords:
            out.writeTag("subfield",keyword,[["code","a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","650"],["ind1","2"],["ind2","7"]])
        out.writeTag("subfield", event.type.capitalize(), [["code", "a"]])
        out.closeTag("datafield")
        #### t o d o

        #out.openTag("datafield",[["tag","650"],["ind1","3"],["ind2","7"]])
        #out.writeTag("subfield",,[["code","a"]])
        #out.closeTag("datafield")


        # tag 700 chair name
        for chair in event.person_links:
            out.openTag("datafield",[["tag","906"],["ind1"," "],["ind2"," "]])
            full_name = chair.get_full_name(last_name_first=True, last_name_upper=False, abbrev_first_name=False)
            out.writeTag("subfield", full_name, [["code", "p"]])
            out.writeTag("subfield", chair.affiliation, [["code", "u"]])
            out.closeTag("datafield")


        #out.openTag("datafield",[["tag","856"],["ind1","4"],["ind2"," "]])
        if includeMaterial:
            self.materialToXMLMarc21(event, out=out)
        #out.closeTag("datafield")

        if event.note:
            self.noteToXMLMarc21(event.note, out=out)

        #if respEmail != "":
        #    out.openTag("datafield",[["tag","859"],["ind1"," "],["ind2"," "]])
        #   out.writeTag("subfield",respEmail,[["code","f"]])
        #   out.closeTag("datafield")
        # tag 859 email
        for chair in event.person_links:
            out.openTag("datafield", [["tag", "859"], ["ind1", " "], ["ind2", " "]])
            out.writeTag("subfield", chair.person.email, [["code", "f"]])
            out.closeTag("datafield")

        edate = event.as_legacy.getCreationDate()
        creaDate = datetime( edate.year, edate.month, edate.day )

        out.openTag("datafield",[["tag","961"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield","%d-%s-%sT"%(creaDate.year, string.zfill(creaDate.month,2), string.zfill(creaDate.day,2)),[["code","x"]])
        out.closeTag("datafield")

        edate = event.as_legacy.getModificationDate()
        modifDate = datetime( edate.year, edate.month, edate.day )

        out.openTag("datafield",[["tag","961"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield","%d-%s-%sT"%(modifDate.year, string.zfill(modifDate.month,2), string.zfill(modifDate.day,2)),[["code","c"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","980"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", self._getRecordCollection(event), [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","970"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", "INDICO." + str(uniqueId(event)), [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(url_for('event.conferenceDisplay', confId=event.id, _external=True), 'Event details',
                                  out)

        self._generateAccessList(event, out, objId=uniqueId(event))
예제 #11
0
파일: output.py 프로젝트: stomanin/indico
    def _subcontrib_to_marc_xml_21(self,
                                   subcontrib,
                                   includeMaterial=1,
                                   out=None):
        if not out:
            out = self._XMLGen

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",
                    [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(subcontrib)),
                     [["code", "a"]])
        out.closeTag("datafield")
        #
        out.openTag("datafield",
                    [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(subcontrib), [["code", "a"]])
        out.writeTag("subfield", "Indico", [["code", "9"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "245"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", subcontrib.title, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "300"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", subcontrib.duration, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "111"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(subcontrib.event_new),
                     [["code", "g"]])
        out.closeTag("datafield")

        self._generate_references(subcontrib, out)

        for path in subcontrib.event_new.as_legacy.getCategoriesPath():
            out.openTag("datafield",
                        [["tag", "650"], ["ind1", " "], ["ind2", "7"]])
            out.writeTag("subfield", ":".join(path), [["code", "a"]])
            out.closeTag("datafield")

        self._generate_contrib_location_and_time(subcontrib.contribution, out)
        #
        out.openTag("datafield",
                    [["tag", "520"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", subcontrib.description, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "611"], ["ind1", "2"], ["ind2", "4"]])
        out.writeTag("subfield", subcontrib.event_new.title, [["code", "a"]])
        out.closeTag("datafield")
        #
        out.openTag("datafield",
                    [["tag", "650"], ["ind1", "1"], ["ind2", "7"]])
        out.writeTag("subfield", "SzGeCERN", [["code", "2"]])
        if subcontrib.contribution.track:
            out.writeTag("subfield", subcontrib.contribution.track.title,
                         [["code", "a"]])
        out.closeTag("datafield")

        self._generate_contrib_people(contrib=subcontrib.contribution,
                                      out=out,
                                      subcontrib=subcontrib)

        if includeMaterial:
            self.materialToXMLMarc21(subcontrib, out=out)

        if subcontrib.note:
            self.noteToXMLMarc21(subcontrib.note, out=out)

        out.openTag("datafield",
                    [["tag", "962"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield",
                     'INDICO.{}'.format(uniqueId(subcontrib.event_new)),
                     [["code", "b"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "970"], ["ind1", " "], ["ind2", " "]])
        confcont = 'INDICO.{}'.format(uniqueId(subcontrib))
        out.writeTag("subfield", confcont, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "980"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", self._getRecordCollection(subcontrib),
                     [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(
            url_for('contributions.display_contribution',
                    subcontrib.contribution,
                    _external=True), 'Contribution details', out)

        self._generate_link_field(
            url_for('event.conferenceDisplay',
                    subcontrib.event_new,
                    _external=True), 'Event details', out)

        self._generateAccessList(subcontrib.contribution,
                                 out,
                                 objId=uniqueId(subcontrib))
예제 #12
0
파일: output.py 프로젝트: stomanin/indico
    def _contrib_to_marc_xml_21(self, contrib, include_material=1, out=None):
        if not out:
            out = self._XMLGen

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",
                    [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", "INDICO.%s" % uniqueId(contrib),
                     [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "035"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(contrib), [["code", "a"]])
        out.writeTag("subfield", "Indico", [["code", "9"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "245"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.title, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "300"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.duration, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "111"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", uniqueId(contrib.event_new), [["code", "g"]])
        out.closeTag("datafield")

        # TODO: Adapt modification date once in the model
        out.openTag("datafield",
                    [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield",
                     datetime.now().strftime('%Y-%m-%dT'), [["code", "c"]])
        out.closeTag("datafield")

        for path in contrib.event_new.as_legacy.getCategoriesPath():
            out.openTag("datafield",
                        [["tag", "650"], ["ind1", " "], ["ind2", "7"]])
            out.writeTag("subfield", ":".join(path), [["code", "a"]])
            out.closeTag("datafield")

        self._generate_contrib_location_and_time(contrib, out)

        out.openTag("datafield",
                    [["tag", "520"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", contrib.description, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "611"], ["ind1", "2"], ["ind2", "4"]])
        out.writeTag("subfield", contrib.event_new.title, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_references(contrib, out)

        out.openTag("datafield",
                    [["tag", "653"], ["ind1", "1"], ["ind2", " "]])
        for keyword in contrib.keywords:
            out.writeTag("subfield", keyword, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "650"], ["ind1", "1"], ["ind2", "7"]])
        out.writeTag("subfield", "SzGeCERN", [["code", "2"]])
        if contrib.track:
            out.writeTag("subfield", contrib.track.title, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_contrib_people(contrib=contrib, out=out)

        if include_material:
            self.materialToXMLMarc21(contrib, out=out)

        if contrib.note:
            self.noteToXMLMarc21(contrib.note, out=out)

        out.openTag("datafield",
                    [["tag", "962"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield",
                     'INDICO.{}'.format(uniqueId(contrib.event_new)),
                     [["code", "b"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "970"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", 'INDICO.{}'.format(uniqueId(contrib)),
                     [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "980"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", self._getRecordCollection(contrib),
                     [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(
            url_for('contributions.display_contribution',
                    contrib,
                    _external=True), 'Contribution details', out)

        self._generate_link_field(
            url_for('event.conferenceDisplay',
                    contrib.event_new,
                    _external=True), 'Event details', out)

        self._generateAccessList(contrib, out, objId=uniqueId(contrib))
예제 #13
0
파일: output.py 프로젝트: stomanin/indico
    def _event_to_xml_marc_21(self,
                              event,
                              includeSession=1,
                              includeContribution=1,
                              includeMaterial=1,
                              out=None):
        if not out:
            out = self._XMLGen

        out.openTag("datafield",
                    [["tag", "245"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        out.closeTag("datafield")

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",
                    [["tag", "111"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        event_location_info = []
        if event.venue_name:
            event_location_info.append(event.venue_name)
        if event.address:
            event_location_info.append(event.address)
        event_room = event.get_room_name(full=False)
        if event_room:
            event_location_info.append(event_room)
        out.writeTag("subfield", ', '.join(event_location_info),
                     [["code", "c"]])

        sd = event.start_dt
        ed = event.end_dt
        out.writeTag(
            "subfield", "%d-%s-%sT%s:%s:00Z" %
            (sd.year, string.zfill(sd.month, 2), string.zfill(sd.day, 2),
             string.zfill(sd.hour, 2), string.zfill(sd.minute, 2)),
            [["code", "9"]])
        out.writeTag(
            "subfield", "%d-%s-%sT%s:%s:00Z" %
            (ed.year, string.zfill(ed.month, 2), string.zfill(ed.day, 2),
             string.zfill(ed.hour, 2), string.zfill(ed.minute, 2)),
            [["code", "z"]])

        out.writeTag("subfield", uniqueId(event), [["code", "g"]])
        out.closeTag("datafield")

        for path in event.as_legacy.getCategoriesPath():
            out.openTag("datafield",
                        [["tag", "650"], ["ind1", " "], ["ind2", "7"]])
            out.writeTag("subfield", ":".join(path), [["code", "a"]])
            out.closeTag("datafield")

        ####################################
        # Fermi timezone awareness         #
        ####################################
        #if conf.getStartDate() is not None:
        #    out.openTag("datafield",[["tag","518"],["ind1"," "],["ind2"," "]])
        #    out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(conf.getStartDate().year, string.zfill(conf.getStartDate().month,2), string.zfill(conf.getStartDate().day,2), string.zfill(conf.getStartDate().hour,2), string.zfill(conf.getStartDate().minute,2)),[["code","d"]])
        #    out.closeTag("datafield")
        #sd = conf.getAdjustedStartDate(tz)
        sd = event.start_dt
        if sd is not None:
            out.openTag("datafield",
                        [["tag", "518"], ["ind1", " "], ["ind2", " "]])
            out.writeTag(
                "subfield", "%d-%s-%sT%s:%s:00Z" %
                (sd.year, string.zfill(sd.month, 2), string.zfill(sd.day, 2),
                 string.zfill(sd.hour, 2), string.zfill(sd.minute, 2)),
                [["code", "d"]])
            out.closeTag("datafield")
        ####################################
        # Fermi timezone awareness(end)    #
        ####################################

        out.openTag("datafield",
                    [["tag", "520"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", event.description, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_references(event, out)

        out.openTag("datafield",
                    [["tag", "653"], ["ind1", "1"], ["ind2", " "]])
        # TODO: Fetch keywords from new models (once implemented)
        keywords = event.as_legacy.getKeywords()
        keywords = keywords.replace("\r\n", "\n")
        for keyword in keywords.split("\n"):
            out.writeTag("subfield", keyword, [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "650"], ["ind1", "2"], ["ind2", "7"]])
        out.writeTag("subfield", event.type.capitalize(), [["code", "a"]])
        out.closeTag("datafield")
        #### t o d o

        #out.openTag("datafield",[["tag","650"],["ind1","3"],["ind2","7"]])
        #out.writeTag("subfield",,[["code","a"]])
        #out.closeTag("datafield")

        # tag 700 chair name
        for chair in event.person_links:
            out.openTag("datafield",
                        [["tag", "906"], ["ind1", " "], ["ind2", " "]])
            full_name = chair.get_full_name(last_name_first=True,
                                            last_name_upper=False,
                                            abbrev_first_name=False)
            out.writeTag("subfield", full_name, [["code", "p"]])
            out.writeTag("subfield", chair.affiliation, [["code", "u"]])
            out.closeTag("datafield")

        #out.openTag("datafield",[["tag","856"],["ind1","4"],["ind2"," "]])
        if includeMaterial:
            self.materialToXMLMarc21(event, out=out)
        #out.closeTag("datafield")

        if event.note:
            self.noteToXMLMarc21(event.note, out=out)

        #if respEmail != "":
        #    out.openTag("datafield",[["tag","859"],["ind1"," "],["ind2"," "]])
        #   out.writeTag("subfield",respEmail,[["code","f"]])
        #   out.closeTag("datafield")
        # tag 859 email
        for chair in event.person_links:
            out.openTag("datafield",
                        [["tag", "859"], ["ind1", " "], ["ind2", " "]])
            out.writeTag("subfield", chair.person.email, [["code", "f"]])
            out.closeTag("datafield")

        edate = event.as_legacy.getCreationDate()
        creaDate = datetime(edate.year, edate.month, edate.day)

        out.openTag("datafield",
                    [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag(
            "subfield",
            "%d-%s-%sT" % (creaDate.year, string.zfill(creaDate.month, 2),
                           string.zfill(creaDate.day, 2)), [["code", "x"]])
        out.closeTag("datafield")

        edate = event.as_legacy.getModificationDate()
        modifDate = datetime(edate.year, edate.month, edate.day)

        out.openTag("datafield",
                    [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag(
            "subfield",
            "%d-%s-%sT" % (modifDate.year, string.zfill(modifDate.month, 2),
                           string.zfill(modifDate.day, 2)), [["code", "c"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "980"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", self._getRecordCollection(event),
                     [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",
                    [["tag", "970"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", "INDICO." + str(uniqueId(event)),
                     [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(
            url_for('event.conferenceDisplay', confId=event.id,
                    _external=True), 'Event details', out)

        self._generateAccessList(event, out, objId=uniqueId(event))
예제 #14
0
    def _event_to_xml_marc_21(self, event, includeSession=1, includeContribution=1, includeMaterial=1, out=None):
        if not out:
            out = self._XMLGen

        out.openTag("datafield",[["tag","245"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        out.closeTag("datafield")

        out.writeTag("leader", "00000nmm  2200000uu 4500")
        out.openTag("datafield",[["tag","111"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.title, [["code", "a"]])
        event_location_info = []
        if event.venue_name:
            event_location_info.append(event.venue_name)
        if event.address:
            event_location_info.append(event.address)
        event_room = event.get_room_name(full=False)
        if event_room:
            event_location_info.append(event_room)
        out.writeTag("subfield", ', '.join(event_location_info), [["code", "c"]])

        sd = event.start_dt
        ed = event.end_dt
        out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(sd.year, string.zfill(sd.month,2), string.zfill(sd.day,2), string.zfill(sd.hour,2), string.zfill(sd.minute,2)),[["code","9"]])
        out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(ed.year, string.zfill(ed.month,2), string.zfill(ed.day,2), string.zfill(ed.hour,2), string.zfill(ed.minute,2)),[["code","z"]])

        out.writeTag("subfield", uniqueId(event), [["code", "g"]])
        out.closeTag("datafield")

        self._generate_category_path(event, out)

        sd = event.start_dt
        if sd is not None:
            out.openTag("datafield",[["tag","518"],["ind1"," "],["ind2"," "]])
            out.writeTag("subfield","%d-%s-%sT%s:%s:00Z" %(sd.year, string.zfill(sd.month,2), string.zfill(sd.day,2), string.zfill(sd.hour,2), string.zfill(sd.minute,2)),[["code","d"]])
            out.closeTag("datafield")

        out.openTag("datafield",[["tag","520"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", event.description, [["code", "a"]])
        out.closeTag("datafield")

        self._generate_references(event, out)

        out.openTag("datafield",[["tag","653"],["ind1","1"],["ind2"," "]])
        for keyword in event.keywords:
            out.writeTag("subfield",keyword,[["code","a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","650"],["ind1","2"],["ind2","7"]])
        out.writeTag("subfield", event.type.capitalize(), [["code", "a"]])
        out.closeTag("datafield")
        #### t o d o

        #out.openTag("datafield",[["tag","650"],["ind1","3"],["ind2","7"]])
        #out.writeTag("subfield",,[["code","a"]])
        #out.closeTag("datafield")


        # tag 700 chair name
        for chair in event.person_links:
            out.openTag("datafield",[["tag","906"],["ind1"," "],["ind2"," "]])
            full_name = chair.get_full_name(last_name_first=True, last_name_upper=False, abbrev_first_name=False)
            out.writeTag("subfield", full_name, [["code", "p"]])
            out.writeTag("subfield", chair.affiliation, [["code", "u"]])
            out.closeTag("datafield")


        #out.openTag("datafield",[["tag","856"],["ind1","4"],["ind2"," "]])
        if includeMaterial:
            self.materialToXMLMarc21(event, out=out)
        #out.closeTag("datafield")

        if event.note and not event.note.is_deleted:
            self.noteToXMLMarc21(event.note, out=out)

        #if respEmail != "":
        #    out.openTag("datafield",[["tag","859"],["ind1"," "],["ind2"," "]])
        #   out.writeTag("subfield",respEmail,[["code","f"]])
        #   out.closeTag("datafield")
        # tag 859 email
        for chair in event.person_links:
            out.openTag("datafield", [["tag", "859"], ["ind1", " "], ["ind2", " "]])
            out.writeTag("subfield", chair.person.email, [["code", "f"]])
            out.closeTag("datafield")

        out.openTag("datafield", [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", event.created_dt.strftime('%Y-%m-%dT'), [["code", "x"]])
        out.closeTag("datafield")

        out.openTag("datafield", [["tag", "961"], ["ind1", " "], ["ind2", " "]])
        out.writeTag("subfield", datetime.now().strftime('%Y-%m-%dT'), [["code", "c"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","980"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", self._getRecordCollection(event), [["code", "a"]])
        out.closeTag("datafield")

        out.openTag("datafield",[["tag","970"],["ind1"," "],["ind2"," "]])
        out.writeTag("subfield", "INDICO." + str(uniqueId(event)), [["code", "a"]])
        out.closeTag("datafield")

        self._generate_link_field(event.external_url, 'Event details', out)

        self._generateAccessList(event, out, objId=uniqueId(event))