def _checkParams(self): try: self._target = self._conf = conference.ConferenceHolder().getById( self._params["conference"]) except: try: self._target = self._conf = conference.ConferenceHolder( ).getById(self._params["confId"]) except: raise ServiceError("ERR-E4", "Invalid conference id.") if self._conf == None: raise Exception("Conference id not specified.") try: self._target = self._contribution = self._conf.getContributionById( self._params["contribution"]) except: try: self._target = self._contribution = self._conf.getContributionById( self._params["contribId"]) except: raise ServiceError("ERR-C0", "Invalid contribution id.") if self._target == None: raise Exception("Contribution id not specified.") # create a parameter manager that checks the consistency of passed parameters self._pm = ParameterManager(self._params)
def _checkParams(self): try: self._target = self._conf = conference.ConferenceHolder().getById(self._params["conference"]) except Exception: try: self._target = self._conf = conference.ConferenceHolder().getById(self._params["confId"]) except Exception: raise ServiceError("ERR-E4", "Invalid conference id.") if self._target is None: Logger.get('rpc.conference').debug('self._target is null') raise Exception("Null target.")
def validateShortURL(tag, target): if tag.isdigit(): raise ValueError( _("Short URL tag is a number: '%s'. Please add at least one non-digit." ) % tag) if not re.match(r'^[a-zA-Z0-9/._-]+$', tag) or '//' in tag: raise ValueError( _("Short URL tag contains invalid chars: '%s'. Please select another one." ) % tag) if tag[0] == '/' or tag[-1] == '/': raise ValueError( _("Short URL tag may not begin/end with a slash: '%s'. Please select another one." ) % tag) mapper = ShortURLMapper() if mapper.hasKey(tag) and mapper.getById(tag) != target: raise ValueError( _("Short URL tag already used: '%s'. Please select another one." ) % tag) if conference.ConferenceHolder().hasKey(tag): # Reject existing event ids. It'd be EXTREMELY confusing and broken to allow such a shorturl raise ValueError( _("Short URL tag is an event id: '%s'. Please select another one." ) % tag) ep = endpoint_for_url(Config.getInstance().getShortEventURL() + tag) if not ep or ep[0] != 'event.shorturl': # URL does not match the shorturl rule or collides with an existing rule that does does not # know about shorturls. # This shouldn't happen anymore with the /e/ namespace but we keep the check just to be safe raise ValueError( _("Short URL tag conflicts with an URL used by Indico: '%s'. Please select another one." ) % tag)
def getObject(self): if self.__categId: if not conference.CategoryManager().hasKey(self.__categId): raise errors.NoReportError( _("There is no category with id '%s', or it has been deleted" ) % self.__categId) obj = conference.CategoryManager().getById(self.__categId) if self.__materialId is not None or self.__resId is not None: return None # obsolete - attachments don't use WebLocator return obj if not self.__confId: return None obj = conference.ConferenceHolder().getById(self.__confId) if obj is None: raise errors.NoReportError( "The event you are trying to access does not exist or has been deleted" ) if self.__notifTplId: obj = obj.getAbstractMgr().getNotificationTplById( self.__notifTplId) return obj if self.__trackId: obj = obj.getTrackById(self.__trackId) return obj if self.__abstractId: obj = obj.getAbstractMgr().getAbstractById(self.__abstractId) if obj == None: raise errors.NoReportError( "The abstract you are trying to access does not exist or has been deleted" ) if self.__resId: return obj.getAttachmentById(self.__resId) if not self.__materialId: return obj
def _initialiseDays(self): """ """ self._days = OOBTree() res = sets.Set() self._categIdx = {} self._icons = {} im = indexes.IndexesHolder() calIdx = im.getIndex("calendar") catIdx = im.getIndex("category") c1 = calIdx.getObjectsIn(self.getStartDate(), self.getEndDate()) icons = [] for categ in self.getCategoryList(): confIds = sets.Set(catIdx.getItems(categ.getId())) confIds.intersection_update(c1) for confId in confIds: if not self._categIdx.has_key(confId): self._categIdx[confId] = [] self._categIdx[confId].append(categ) res.union_update(confIds) icons = self.setIcons(categ) for icon in icons: l = list(sets.Set(catIdx.getItems(icon)) & c1) if len(l) > 0: self._icons[icon] = l ch = conference.ConferenceHolder() for confId in res: self._mapConferenceToDays(ch.getById(confId), self._categIdx[confId])
def getObject(self): if not self.__confId: return None obj = conference.ConferenceHolder().getById(self.__confId) if obj is None: raise errors.NoReportError( "The event you are trying to access does not exist or has been deleted" ) if self.__notifTplId: obj = obj.getAbstractMgr().getNotificationTplById( self.__notifTplId) return obj if self.__trackId: obj = obj.getTrackById(self.__trackId) return obj if self.__abstractId: obj = obj.getAbstractMgr().getAbstractById(self.__abstractId) if obj == None: raise errors.NoReportError( "The abstract you are trying to access does not exist or has been deleted" ) if self.__resId: return obj.getAttachmentById(self.__resId) if not self.__materialId: return obj
def getConferences(self): res = [] ch = conference.ConferenceHolder() for confId in self.getConferenceIds(): res.append(ch.getById(confId)) if res != []: res.sort(lambda x, y: cmp( x.calculateDayStartTime(self._day).time(), y.calculateDayStartTime(self._day).time())) return res
def main(): ch = conference.ConferenceHolder() dbm = DBMgr.getInstance() dbm.startRequest() rep = dbm.getDBConnection().root()['local_repositories']['main'] for c in ch.getList(): for ct in c.getContributionList(): for sc in ct.getSubContributionList(): for m in sc.getAllMaterialList(): for r in m.getResourceList(): if isinstance(r, LocalFile): moveFile(r, rep) dbm.endRequest()
def uid_to_obj(uid): m = UID_RE.match(uid) if not m: return m else: d = m.groupdict() obj = conference.ConferenceHolder().getById(d['event']) if 'session' in d: obj = obj.getSessionById(d['session']) if 'contrib' in d: obj = obj.getContributionById(d['contrib']) if 'subcont' in d: obj = obj.getSubContributionById(d['subcont']) return obj
def getToList(): toList = [] DBMgr.getInstance().startRequest() ch = conference.ConferenceHolder() c = ch.getById("0") toList = [] for contrib in c.getContributionList(): if not isinstance(contrib.getCurrentStatus(), conference.ContribStatusWithdrawn): for pa in contrib.getPrimaryAuthorList(): if pa.getEmail().strip() != "" and (not pa.getEmail() in toList): toList.append(pa.getEmail()) for spk in contrib.getSpeakerList(): if spk.getEmail().strip() != "" and (not spk.getEmail() in toList): toList.append(spk.getEmail()) DBMgr.getInstance().endRequest() return toList
def _getMaterial(locator): ch = conference.ConferenceHolder() if locator.has_key("confId") and locator.has_key("materialId"): c = ch.getById(locator["confId"]) # ---------- Conference ---------- if c is not None: # ---------- Session ---------- if locator.has_key("sessionId"): s = c.getSessionById(locator["sessionId"]) if s is not None: # ---------- Contribution ---------- if locator.has_key("contribId"): contrib = c.getContributionById( locator["contribId"]) if contrib is not None: # ---------- Subcontribution ---------- if locator.has_key("subContId"): subContrib = contrib.getSubContributionById( locator["subContId"]) if subContrib is not None: return CDSConvFileConverter._getMaterialObj( subContrib, locator["materialId"]) else: return CDSConvFileConverter._getMaterialObj( contrib, locator["materialId"]) else: return CDSConvFileConverter._getMaterialObj( s, locator["materialId"]) # ---------- Contribution ---------- elif locator.has_key("contribId"): contrib = c.getContributionById(locator["contribId"]) if contrib is not None: # ---------- Subcontribution ---------- if locator.has_key("subContId"): subContrib = contrib.getSubContributionById( locator["subContId"]) if subContrib is not None: return CDSConvFileConverter._getMaterialObj( subContrib, locator["materialId"]) else: return CDSConvFileConverter._getMaterialObj( contrib, locator["materialId"]) else: return CDSConvFileConverter._getMaterialObj( c, locator["materialId"]) return None
def _checkParams( self, params ): RHCategModifBase._checkParams( self, params ) confIdList = self._normaliseListParam(params.get("selectedConf", [])) self._confs = [] self._confirmation = params.has_key("confirm") if "cancel" in params: return ch = conference.ConferenceHolder() for confId in confIdList: self._confs.append( ch.getById( confId ) ) self._action = _ActionConferenceDeletion( self, self._target, self._confs, ) if params.has_key("reallocate"): self._srcCateg = self._target if self._confirmation: cm = conference.CategoryManager() self._srcCateg = cm.getById( params["srcCategId"] ) self._action = _ActionConferenceReallocation( self, self._srcCateg, self._confs, self._target )
def _generateList(self, date=None): if not date: date = timezoneUtils.nowutc() categDateIdx = indexes.IndexesHolder().getById('categoryDate') objDict = {} for obj in self._objects: if isinstance(obj.getObject(), conference.Conference): self.processEvent(date, obj.getObject(), obj, objDict) elif isinstance(obj.getObject(), conference.Category): events = categDateIdx.getObjectsIn(obj.getObject().getId(), date, date+obj.getAdvertisingDelta()) ## HACK: Remove when this version goes into production (See above) for eventId in events: try: conf = conference.ConferenceHolder().getById(eventId) self.processEvent(date, conf, obj, objDict) except: pass resultList = [] keys = objDict.keys() keys.sort(reverse=True) for weight in keys: sortedEvents = objDict[weight] sortedEvents.sort(key=operator.attrgetter('startDate')) for elem in sortedEvents: resultList.append(elem) if len(resultList) == self._maxEvents: break # sort again, so that the final result is an ordered list # that is suitable for display resultList.sort(key=operator.attrgetter('startDate')) Logger.get('upcoming_events').info("Regenerated upcoming event cache") return resultList
def _checkParams(self): ConfigUpcomingEventsBase._checkParams(self) self._objType = self._pm.extract("type", pType=str, allowEmpty=False) self._objId = self._pm.extract("id", pType=str, allowEmpty=False) if self._objType == 'event': try: self._obj = conference.ConferenceHolder().getById(self._objId) except: raise ServiceError("ERR-O0", "Event '%s' does not exist" % self._objId) elif self._objType == 'category': try: self._obj = conference.CategoryManager().getById(self._objId) except: raise ServiceError("ERR-O1", "Category '%s' does not exist" % self._objId) else: raise ServiceError("ERR-O2", "Unknown type!")
def getToList(): toList = [] DBMgr.getInstance().startRequest() ch = conference.ConferenceHolder() c = ch.getById("0") toList = [] i = 0 for contrib in c.getContributionList(): if contrib.getPaper() == None or contrib.getPaper().getResourceList() == []: if not isinstance(contrib.getCurrentStatus(), conference.ContribStatusWithdrawn): i += 1 for pa in contrib.getPrimaryAuthorList(): if pa.getEmail().strip() != "" and (not pa.getEmail() in toList): toList.append(pa.getEmail()) for spk in contrib.getSpeakerList(): if spk.getEmail().strip() != "" and (not spk.getEmail() in toList): toList.append(spk.getEmail()) DBMgr.getInstance().endRequest() print "Number of contribs without papers:%s"%i return toList
def setType(style, id): if style == 'nicecompact': type = '' elif style == 'standard' or style == 'tools/printable' or style == 'seminars' or style == 'nosession' or style == 'administrative' or style == 'standard2' or style == 'minutes': #chooses the 'type' based on 'style' of AGENDA type = 'meeting' elif style == 'event' or style == 'week' or style == 'lecture': type = 'simple_event' else: #if stylesheet in AGENDA db is blank type = 'meeting' if type != '': #this if statement is in because if type is equal to nicecompact or lecture then currently no factory is used #when a factory type is created to go with these, remove the if statement and unindent the code. #instantiate the registry wr = webFactoryRegistry.WebFactoryRegistry() ch = conference.ConferenceHolder() #fetch the conference which type is to be updated c = ch.getById(id) #get the web factory. Possible values: simple_event, meeting fact = wr.getFactoryById(type) #register the factory for the conference wr.registerFactory(c, fact)
def _getAnswer(self): im = indexes.IndexesHolder() ch = conference.ConferenceHolder() calIdx = im.getIndex("calendar") evtIds = calIdx.getObjectsIn(self._sDate, self._eDate) evtsByCateg = {} for evtId in evtIds: try: evt = ch.getById(evtId) categs = evt.getOwnerList() categname = categs[0].getName() if not evtsByCateg.has_key(categname): evtsByCateg[categname] = [] evtsByCateg[categname].append( (evt.getTitle().strip(), evt.getAdjustedStartDate().strftime('%d/%m/%Y %H:%M '), evt.getAdjustedEndDate().strftime('%d/%m/%Y %H:%M '), evt.getTimezone())) except Exception: continue return evtsByCateg
def getUpcomingEventList(self): # check if there's a valid cached copy first fromCache = self._cache.loadObject('events') if fromCache: # Cache hit! resultList = fromCache.getContents() else: resultList = map(self._processEventDisplay, self._generateList()) # cache the results cacheEntry = UECacheEntry(entryList = resultList) self._cache.cacheObject('events', cacheEntry) ## TODO: Remove this ## HACK: Until this version goes to production ## Since the old production version won't care about the ## Category/date index, it may happen that a previously indexed ## event is deleted using the old version, and thus not removed from ## the index. ## So, this filtering step is needed. To avoid furthger problems, ## all the events that were deleted are unindexed ## in the future, there can still happen that an event was deleted ## but the cache not regenerated - in this case, a verification should ## still be done, and the cache invalidated. filteredResultList = [] for result in resultList: confId = result[3] try: conference.ConferenceHolder().getById(confId) filteredResultList.append(result) except: pass return filteredResultList
def _process(self): if self._statusValue != "OK": return self._createResponse(self._statusValue, self._message) ih = indexes.IndexesHolder() calIdx = ih.getIndex("calendar") catIdx = ih.getIndex("category") ch = conference.ConferenceHolder() # A *preliminary* set of conference id's is created here # This set is constructed using indexes, without getting the Conference # objects from the DB. listOfSets = [] if self._startDateAt != None: listOfSets.append(calIdx.getObjectsStartingInDay( self._startDateAt)) if self._startDateFrom != None: listOfSets.append( calIdx.getObjectsStartingIn(self._startDateFrom, self._startDateTo)) if self._endDateAt != None: listOfSets.append(calIdx.getObjectsEndingInDay(self._endDateAt)) if self._endDateFrom != None: listOfSets.append( calIdx.getObjectsEndingIn(self._endDateFrom, self._endDateTo)) if self._date != None: listOfSets.append(calIdx.getObjectsIn(self._date, self._date)) if self._category != None: resultSet = Set() if type(self._category) is list: for i in self._category: resultSet.union_update(catIdx.getItems(i)) else: resultSet.union_update(catIdx.getItems(self._category)) listOfSets.append(resultSet) if self._id != None: resultSet = Set() if type(self._id) is list: listOfSets.append(Set(self._id)) else: listOfSets.append(Set([self._id])) prelimResult = listOfSets[0] for i in range(1, len(listOfSets)): prelimResult.intersection_update(listOfSets[i]) result = Set() XG = xmlGen.XMLGen() XG.openTag("response") XG.openTag("status") XG.writeTag("value", "OK") XG.writeTag("message", "Returning search results") XG.closeTag("status") XG.openTag("event-list") for i in prelimResult: try: try: c = ch.getById(i) except: continue if self._author != None and not self._checkAuthor( c, self._author): continue if self._room != None and not self._checkRoom(c, self._room): continue if self._startDateFrom != None: if c.getStartDate() < self._startDateFrom or \ c.getStartDate() > self._startDateTo: continue if self._startDateAt != None: if c.getStartDate() != self._startDateAt: continue if self._endDateFrom != None: if c.getEndDate() < self._endDateFrom or \ c.getEndDate() > self._endDateTo: continue if self._endDateAt != None: if c.getEndDate() != self._endDateAt: continue result.add(i) if self._format != "full": self._printConference(c, XG) else: XG.openTag("event") og = outputGenerator(self.getAW(), XG) og._confToXML(c, {}) XG.closeTag("event") except KeyError: continue XG.closeTag("event-list") XG.closeTag("response") self._req.content_type = "text/xml" return XG.getXml()
def getAgenda(): print "migrating..." log("start getAgenda") cc = agenda.cursor() #creates a new cursor to the database listcat = getAllSubCategories("171") strlistcat = "','".join(listcat) #cc.execute("select * from AGENDA where id='a052023'") #cc.execute("select * from AGENDA where fid in ('%s') and YEAR(cd)=2004 order by id"%strlistcat)#gets the AGENDAS #cc.execute("select * from AGENDA where fid in ('%s') and id>='' order by id"%strlistcat)#gets the AGENDAS #cc.execute("select * from AGENDA where fid = '296'")#gets the AGENDAS cc.execute( "select * from AGENDA where id > 'a015' and id < 'a02' order by id" ) #gets the AGENDAS #cc.execute("select * from AGENDA where id like 'a00%' and cd > '2000-12-01' ")#gets the AGENDAS #cc.execute("select * from AGENDA where id like 'a02%' and id >'a021094' order by id") #cc.execute("select * from AGENDA where id>='a045146' order by id") c = cc.fetchone() #gets the next AGENDA cate = agenda.cursor() #creates a cursor to get the LEVEL informaion #c[0]-title, c[1]-id, c[2]-stdate, c[3]-endate, c[4]-location, c[5]-nbsession, c[6]-chairman, c[7]-cem #c[8]-status, c[9]-an, c[10]-cd, c[11]-md, c[12]-stylesheet, c[13]-format, c[14]-confidentiality #c[15]-apassword, c[16]-repno, c[17]-fid, c[18]-acomments, c[19]-keywords, c[20]-visibility #c[21]-bld, c[22]-floor, c[23]-room, c[24]-stime, c[25]-etime #get CERN domain dh = domain.DomainHolder() CDom = None for dom in dh.getList(): if dom.getName().upper() == "CERN": CDom = dom if not CDom: CDom = domain.Domain() CDom.setName("CERN") CDom.setDescription("CERN domain") CDom.addFiltersFromStr("128.141;128.142;137.138;192.91;194.12;192.16") dh.add(CDom) db.DBMgr.getInstance().commit() error = False ch = conference.ConferenceHolder() while c != None: #db.DBMgr.getInstance().startRequest() try: log("add conference : %s" % c[1]) cate.execute( "select * from LEVEL where uid = \'" + c[17] + "\'") #gets the name of the Category the conf belongs in catWanted = conference.Category( ) #creates Category that the AGENDA should belong to level = cate.fetchone() #sets the category properties catWanted.setName(level[3]) catWanted.setDescription(level[6]) catWanted.setOrder(level[12]) catWanted.setVisibility(level[9]) catWanted.setId(level[0]) category = getCat( catWanted, level[1], level[7] ) #checks to see if this category already exists - if not creates it if category == None: #Conference is in a category to delete: don't add log("Conference %s not added, it's inside a 'to delete' category" % c[1]) db.DBMgr.getInstance().abort() c = cc.fetchone() continue user = getUser('CDS Agenda', '*****@*****.**', '', '') #creates a user representing creator try: cd = datetime(c[10].year, c[10].month, c[10].day) except: cd = datetime(1999, 1, 1) try: md = datetime(c[11].year, c[11].month, c[11].day) except: md = datetime(1999, 1, 1) try: conf = ch.getById(c[1]) except: pass conf = category.newConference( user, c[1], cd, md) #creates new Conference to map onto # update counter #year = c[1][1:3] #count = c[1][3:] #if count == "": # count = 0 #counterName = "CONFERENCE%s" % year #idxs = ch._getTree("counters") #if not idxs.has_key(counterName): # idxs[counterName] = Counter() #idxs[counterName].sync(int(count)) if c[8] == "close": conf.setClosed(True) conf.setTitle(c[0]) conf.setDescription(c[18]) if str(c[20]) == '0' or str(c[20]) == '': visibility = 999 else: visibility = int(c[20]) conf.setVisibility(visibility) startDate = datetime(c[2].year, c[2].month, c[2].day, int(c[24].seconds / 3600), int((c[24].seconds % 3600) / 60)) endDate = None if c[3] != None: endDate = datetime(c[3].year, c[3].month, c[3].day, int(c[25].seconds / 3600), int((c[25].seconds % 3600) / 60)) if not endDate or endDate <= startDate: endDate = datetime(c[2].year, c[2].month, c[2].day, int(c[24].seconds / 3600), int((c[24].seconds % 3600) / 60)) conf.setDates(startDate, endDate) if c[4] != "0--": loc = conference.CustomLocation() loc.setName(c[4]) conf.setLocation(loc) except (MaKaCError, AttributeError), e: log("Error : %s : conference not added" % e) c = cc.fetchone() #gets the next conference error = True if not error: pw = genPW() #generates random password if c[6] == None or c[6] == '\xa0': username = '' else: username = c[6] if c[7] == None: uemail = '' else: uemail = c[7] if uemail == '' or username.count( " " ) >= max_white_space_in_names: #if not full user details exist if username != '' or uemail != '': if username != '': chairtext = username else: chairtext = uemail if uemail != '': chairtext = "<a href=\"mailto:%s\">%s</a>" % ( uemail, chairtext) conf.setChairmanText(chairtext) else: chair = getUser(username, uemail, '', pw) #creates the chairman user conf.addChair(chair) setType(c[12], conf.getId()) #sets the format of the agenda if c[13] == 'olist': #facility to cope with this not in MaKaC pass #set the format of talks to ordered list (A,B,C etc) rather than times if c[23] != "0--": loc = conference.CustomRoom() loc.setName(c[23]) conf.setRoom(loc) cf = agenda.cursor() #gets the files associated with this conference cf.execute( "select * from FILE, FILE_EVENT where FILE.id = fileID and eventID = \'" + c[1] + "\'") f = cf.fetchone() #gets the first file form the list while f != None: list = conf.getMaterialList() type = f[2] found = 0 #if type in list get existing material for i in list: if i.getTitle() == type: found = 1 mat = i if found: getFiles(mat, f) #add resources to material else: #if not then create new material with name 'type' mat = conference.Material() mat.setTitle(type) conf.addMaterial(mat) getFiles(mat, f) #add resources to material f = cf.fetchone() #get next file/resource if c[12] == "nosession": #if there are no sessions look for contributions that go directly onto conference addToConf(c, conf) else: getSessions( c, conf) #gets the sessions belonging to this conference confId = conf.getId() # ACCESS CONTROL if c[14] == 'password': #if conference is password protected creates and access user conf.setAccessKey(c[15]) #set the access password conf.setProtection(1) #makes the conference restricted access #conf.grantAccess(colin)#grants access rights to me (for testing reasons) elif c[14] == 'cern-only': conf.requireDomain(CDom) log("added CERN domain") # MODIFICATION RIGHTS conf.setModifKey(c[9]) #add modification key log("Conference added : MaKaC ID : %s" % confId) # DEFAULT STYLE if c[12] in styles.keys(): displayMgr.ConfDisplayMgrRegistery().getDisplayMgr( conf).setDefaultStyle(styles[c[12]]) else: displayMgr.ConfDisplayMgrRegistery().getDisplayMgr( conf).setDefaultStyle("standard") c = cc.fetchone() #gets the next conference else: error = False db.DBMgr.getInstance().commit()
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 3 of the ## License, or (at your option) any later version. ## ## Indico is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Indico;if not, see <http://www.gnu.org/licenses/>. from indico.core.db import DBMgr from MaKaC import conference DBMgr.getInstance().startRequest() error = False ch = conference.ConferenceHolder() for conf in ch.getList(): conf._authorIdx=conference.AuthorIndex() for contrib in conf.getContributionList(): if not isinstance(contrib.getCurrentStatus(),conference.ContribStatusWithdrawn): for auth in contrib.getPrimaryAuthorList(): conf._authorIdx.index(auth) if not error: DBMgr.getInstance().endRequest() print "No error. The change are saved" else: print "There were errors. The changes was not saved"
def index(req, **args): ch = conference.ConferenceHolder() c = ch.getById("84") str = "%s" % c.getModificationDate() return "ok!! %s" % str
def getConference(self): return conference.ConferenceHolder().getById(self.__confId)
def getObject(self): """ """ if self.__resvID: from MaKaC.rb_location import CrossLocationQueries, Location obj = CrossLocationQueries.getReservations( resvID=self.__resvID, location=self.__location) return obj if self.__roomID: from MaKaC.rb_location import CrossLocationQueries, Location obj = CrossLocationQueries.getRooms(roomID=self.__roomID, location=self.__location) return obj if self.__categId: if not conference.CategoryManager().hasKey(self.__categId): raise errors.NoReportError( _("There is no category with id '%s', or it has been deleted" ) % self.__categId) obj = conference.CategoryManager().getById(self.__categId) if self.__materialId: obj = obj.getMaterialById(self.__materialId) if self.__resId: obj = obj.getResourceById(self.__resId) return obj if not self.__confId: return None obj = conference.ConferenceHolder().getById(self.__confId) if obj == None: raise errors.NoReportError( "The event you are trying to access does not exist or has been deleted" ) fr = materialFactories.ConfMFRegistry if self.__notifTplId: obj = obj.getAbstractMgr().getNotificationTplById( self.__notifTplId) return obj if self.__alarmId: obj = obj.getAlarmById(self.__alarmId) return obj if self.__trackId: obj = obj.getTrackById(self.__trackId) return obj if self.__menuLinkId: obj = obj.getDisplayMgr().getMenu().getLinkById(self.__menuLinkId) return obj if self.__contribTypeId: obj = obj.getContribTypeById(self.__contribTypeId) return obj if self.__abstractId: obj = obj.getAbstractMgr().getAbstractById(self.__abstractId) if obj == None: raise errors.NoReportError( "The abstract you are trying to access does not exist or has been deleted" ) if self.__resId: return obj.getAttachmentById(self.__resId) if self.__registrantId: obj = obj.getRegistrantById(self.__registrantId) if obj == None: raise errors.NoReportError( "The registrant you are trying to access does not exist or has been deleted" ) if self.__resId: return obj.getAttachmentById(self.__resId) if self.__sessionId: obj = obj.getSessionById(self.__sessionId) fr = materialFactories.SessionMFRegistry if obj == None: raise errors.NoReportError( "The session you are trying to access does not exist or has been deleted" ) if self.__slotId: obj = obj.getSlotById(self.__slotId) if self.__contribId: obj = obj.getContributionById(self.__contribId) fr = materialFactories.ContribMFRegistry if obj == None: raise errors.NoReportError( "The contribution you are trying to access does not exist or has been deleted" ) if self.__reviewId: #obj must be a Contribution obj = obj.getReviewManager().getReviewById(self.__reviewId) if obj == None: raise errors.NoReportError( "The review you are tring to access does not exist or has been deleted" ) if self.__subContribId and self.__contribId: obj = obj.getSubContributionById(self.__subContribId) fr = materialFactories.ContribMFRegistry if obj == None: raise errors.NoReportError( "The subcontribution you are trying to access does not exist or has been deleted" ) if not self.__materialId: return obj #first we check if it refers to a special type of material mat = None f = fr.getById(self.__materialId) if f: mat = f.get(obj) if not mat: mat = obj.getMaterialById(self.__materialId) if not self.__resId: return mat return mat.getResourceById(self.__resId)
def getObject(self): """ """ if self.__categId: if not conference.CategoryManager().hasKey(self.__categId): raise errors.NoReportError( _("There is no category with id '%s', or it has been deleted" ) % self.__categId) obj = conference.CategoryManager().getById(self.__categId) if self.__materialId is not None or self.__resId is not None: return None # obsolete - attachments don't use WebLocator return obj if not self.__confId: return None obj = conference.ConferenceHolder().getById(self.__confId) if obj is None: raise errors.NoReportError( "The event you are trying to access does not exist or has been deleted" ) if self.__notifTplId: obj = obj.getAbstractMgr().getNotificationTplById( self.__notifTplId) return obj if self.__trackId: obj = obj.getTrackById(self.__trackId) return obj if self.__contribTypeId: obj = obj.getContribTypeById(self.__contribTypeId) return obj if self.__abstractId: obj = obj.getAbstractMgr().getAbstractById(self.__abstractId) if obj == None: raise errors.NoReportError( "The abstract you are trying to access does not exist or has been deleted" ) if self.__resId: return obj.getAttachmentById(self.__resId) if self.__sessionId: obj = obj.getSessionById(self.__sessionId) if obj == None: raise errors.NoReportError( "The session you are trying to access does not exist or has been deleted" ) if self.__slotId: obj = obj.getSlotById(self.__slotId) if self.__contribId: obj = obj.getContributionById(self.__contribId) if obj == None: raise errors.NoReportError( _("The contribution you are trying to access does not exist or has been deleted" )) if self.__reviewId: #obj must be a Contribution obj = obj.getReviewManager().getReviewById(self.__reviewId) if obj == None: raise errors.NoReportError( "The review you are tring to access does not exist or has been deleted" ) if self.__subContribId and self.__contribId: obj = obj.getSubContributionById(self.__subContribId) if obj == None: raise errors.NoReportError( "The subcontribution you are trying to access does not exist or has been deleted" ) if not self.__materialId: return obj assert self.__materialId == 'reviewing' mat = reviewing_factory_get(obj) if mat is None or self.__resId is None: return mat return mat.getResourceById(self.__resId)