def getNumberOfActiveRooms( **kwargs ): """ FINAL (not intented to be overriden) Returns number of rooms that are active (not logicaly deleted). """ name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName ) location = Location.parse(name) return location.factory.newRoom().getNumberOfActiveRooms(location=name)
def getNumberOfRooms( **kwargs ): """ FINAL (not intented to be overriden) Returns total number of rooms in database. """ name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName ) location = Location.parse(name) return location.factory.newRoom().getNumberOfRooms(location=name)
def getNumberOfReservableRooms( **kwargs ): """ FINAL (not intented to be overriden) Returns number of rooms which can be reserved. """ name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName ) location = Location.parse(name) return location.factory.newRoom().getNumberOfReservableRooms(location=name)
def _getAnswer( self ): res = [] if Location.parse( self._location ): for room in CrossLocationQueries.getRooms( location = self._location ): res.append((room.name, room.getFullName())) return res
def _getAnswer(self): res = [] minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() if minfo.getRoomBookingModuleActive(): if Location.parse(self._location): for room in CrossLocationQueries.getRooms(location=self._location, allFast=True): res.append((room.name, room.getFullName())) return res
def _getAnswer(self): res = {} minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() if minfo.getRoomBookingModuleActive(): if Location.parse(self._location): for room in CrossLocationQueries.getRooms(location=self._location): res[room.name] = room.name return sorted(res)
def approve(self, sendNotification=True): """ Approve the room blocking and reject colloding bookings """ self.active = True # If the blocking has not been saved yet, don't reject anything - will be done later in block.insert() if self.block.id is None: return # Create a fake reservation candidate to find bookings colliding with the blocking candResv = Location.parse(self.room.locationName).factory.newReservation() candResv.room = self.room candResv.startDT = datetime.datetime.combine(self.block.startDate, datetime.time()) candResv.endDT = datetime.datetime.combine(self.block.endDate, datetime.time(23, 59)) candResv.repeatability = RepeatabilityEnum.daily candResv.isConfirmed = None collisions = candResv.getCollisions() rejectionReason = "Conflict with blocking %s: %s" % (self.block.id, self.block.message) emailsToBeSent = [] for coll in collisions: collResv = coll.withReservation if collResv.isRejected: continue elif self.block.canOverride(collResv.createdByUser(), self.room): continue elif collResv.repeatability is None or ( collResv.startDT.date() >= self.block.startDate and collResv.endDT.date() <= self.block.endDate ): collResv.rejectionReason = rejectionReason collResv.reject() # Just sets isRejected = True collResv.update() emails = collResv.notifyAboutRejection() emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking rejected") info.append("Reason: '%s'" % collResv.rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) else: # repeatable -> only reject the specific days rejectDate = coll.startDT.date() collResv.excludeDay(rejectDate, unindex=True) collResv.update() emails = collResv.notifyAboutRejection(date=rejectDate, reason=rejectionReason) emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking occurence of the %s rejected" % rejectDate.strftime("%d %b %Y")) info.append("Reason: '%s'" % rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) if sendNotification: emailsToBeSent += RoomBlockingNotification.blockingRequestProcessed(self) for email in emailsToBeSent: GenericMailer.send(GenericNotification(email))
def _getAnswer(self): if not Location.parse(self._location): return {} res = {} for room in CrossLocationQueries.getRooms(location=self._location): res[room.name] = room.name return sorted(res)
def _getAnswer(self): res = {} minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() if minfo.getRoomBookingModuleActive(): if Location.parse(self._location): for room in CrossLocationQueries.getRooms( location=self._location): res[room.name] = room.name return sorted(res)
def _getAnswer( self ): if not Location.parse( self._location ): return {} res = {} for room in CrossLocationQueries.getRooms( location = self._location ): res[room.name] = room.name return sorted(res)
def _getAnswer(self): res = [] minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() if minfo.getRoomBookingModuleActive(): if Location.parse(self._location): for room in CrossLocationQueries.getRooms( location=self._location): res.append((room.name, room.getFullName())) return res
def approve(self, sendNotification=True): """ Approve the room blocking and reject colloding bookings """ self.active = True # If the blocking has not been saved yet, don't reject anything - will be done later in block.insert() if self.block.id is None: return # Create a fake reservation candidate to find bookings colliding with the blocking candResv = Location.parse(self.room.locationName).factory.newReservation() candResv.room = self.room candResv.startDT = datetime.datetime.combine(self.block.startDate, datetime.time()) candResv.endDT = datetime.datetime.combine(self.block.endDate, datetime.time(23, 59)) candResv.repeatability = RepeatabilityEnum.daily candResv.isConfirmed = None collisions = candResv.getCollisions() rejectionReason = "Conflict with blocking %s: %s" % (self.block.id, self.block.message) emailsToBeSent = [] for coll in collisions: collResv = coll.withReservation if collResv.isRejected: continue elif self.block.canOverride(collResv.createdByUser(), self.room): continue elif (collResv.repeatability is None or (collResv.startDT.date() >= self.block.startDate and collResv.endDT.date() <= self.block.endDate)): collResv.rejectionReason = rejectionReason collResv.reject() # Just sets isRejected = True collResv.update() emails = collResv.notifyAboutRejection() emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking rejected") info.append("Reason: '%s'" % collResv.rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) else: # repeatable -> only reject the specific days rejectDate = coll.startDT.date() collResv.excludeDay(rejectDate, unindex=True) collResv.update() emails = collResv.notifyAboutRejection(date=rejectDate, reason=rejectionReason) emailsToBeSent += emails # Add entry to the booking history info = [] info.append("Booking occurence of the %s rejected" % rejectDate.strftime("%d %b %Y")) info.append("Reason: '%s'" % rejectionReason) histEntry = ResvHistoryEntry(self.block.createdByUser, info, emails) collResv.getResvHistory().addHistoryEntry(histEntry) if sendNotification: emailsToBeSent += RoomBlockingNotification.blockingRequestProcessed(self) for email in emailsToBeSent: GenericMailer.send(GenericNotification(email))
def getTotalSurfaceAndCapacity( **kwargs ): """ FINAL (not intented to be overriden) Returns (total_surface, total_capacity) of all Active rooms. """ name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName ) location = Location.parse(name) roomEx = location.factory.newRoom() roomEx.isActive = True roomEx.isReservable = True rooms = CrossLocationQueries.getRooms( roomExample = roomEx, location = name ) totalSurface, totalCapacity = 0, 0 for r in rooms: if r.surfaceArea: totalSurface += r.surfaceArea if r.capacity: totalCapacity += r.capacity return ( totalSurface, totalCapacity )
def reservation(self, locList): Factory.getDALManager().connect() resvEx = ReservationBase() resvEx.startDT = self._fromDT resvEx.endDT = self._toDT locList = filter(lambda loc: Location.parse(loc) is not None, locList) if self._fromDT or self._toDT: daysParam = (day.date() for day in rrule.rrule(rrule.DAILY, dtstart=self._fromDT, until=self._toDT)) else: # slow! daysParam = None for loc in sorted(locList): resvs = CrossLocationQueries.getReservations(location=loc, resvExample=resvEx, days=daysParam) for obj in self._process(resvs, filter=self._resvFilter): yield obj Factory.getDALManager().disconnect()
def _checkParams( self ): self._location = Location.parse(self._param("location"))
def _checkParams( self ): self._location = Location.parse(self._param("location")) self._aspectId = self._param("aspectId")
def _checkParams(self): self._location = Location.parse(self._param("location"))
def _getGuid(self): if self.id == None or self.locationName == None: return None return RoomGUID(Location.parse(self.locationName), self.id)
def _getGuid( self ): if self.id == None or self.locationName == None: return None if Location.parse( self.locationName ): return RoomGUID( Location.parse( self.locationName ), self.id ) return None
## 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.rb_location import Location, MapAspect from MaKaC.plugins.RoomBooking.default.factory import Factory aspects = [ {'id': 0, 'name':'Meyrin', 'centerLatitude': 46.23456689405093, 'centerLongitude': 6.046686172485352, 'topLeftLatitude': '46.225660710473136', 'topLeftLongitude': '6.030035018920898', 'bottomRightLatitude': '46.2434716324829', 'bottomRightLongitude': '6.063294410705566', 'zoomLevel':15, 'defaultOnStartup': True}, {'id': 1, 'name':'PREVESSIN', 'centerLatitude': 46.259051447415175, 'centerLongitude': 6.057773351931246, 'topLeftLatitude': '46.2501492379416', 'topLeftLongitude': '6.041107177734375', 'bottomRightLatitude': '46.26795221179669', 'bottomRightLongitude': '6.074366569519043', 'zoomLevel':15, 'defaultOnStartup': False}, {'id': 2, 'name':'POINT 1', 'centerLatitude': 46.23573201283012, 'centerLongitude': 6.054509639707248, 'topLeftLatitude': '46.23350564968721', 'topLeftLongitude': '6.050344705581665', 'bottomRightLatitude': '46.23795828565159', 'bottomRightLongitude': '6.058659553527832', 'zoomLevel':17, 'defaultOnStartup': False}, {'id': 3, 'name':'POINT 2', 'centerLatitude': 46.25115822762375, 'centerLongitude': 6.020456314054172, 'topLeftLatitude': '46.24893249040227', 'topLeftLongitude': '6.016291379928589', 'bottomRightLatitude': '46.253383874525866', 'bottomRightLongitude': '6.024606227874756', 'zoomLevel':17, 'defaultOnStartup': False}, {'id': 4, 'name':'POINT 5', 'centerLatitude': 46.30958858268458, 'centerLongitude': 6.077267646724067, 'topLeftLatitude': '46.30736521774798', 'topLeftLongitude': '6.073100566864014', 'bottomRightLatitude': '46.31181185731005', 'bottomRightLongitude': '6.081415414810181', 'zoomLevel':17, 'defaultOnStartup': False}, {'id': 5, 'name':'POINT 6', 'centerLatitude': 46.29345231426436, 'centerLongitude': 6.1115119456917455, 'topLeftLatitude': '46.29122829396059', 'topLeftLongitude': '6.107347011566162', 'bottomRightLatitude': '46.295676244254715', 'bottomRightLongitude': '6.115661859512329', 'zoomLevel':17, 'defaultOnStartup': False}, {'id': 6, 'name':'POINT 8', 'centerLatitude': 46.24158691675184, 'centerLongitude': 6.097038745847385, 'topLeftLatitude': '46.2393607911537', 'topLeftLongitude': '6.092873811721802', 'bottomRightLatitude': '46.24381295202931', 'bottomRightLongitude': '6.101188659667969', 'zoomLevel':17, 'defaultOnStartup': False}, ] DBMgr.getInstance().startRequest() Factory.getDALManager().connect() location = Location.parse('CERN') for aspectData in aspects: aspect = MapAspect() aspect.updateFromDictionary(aspectData) location.addAspect(aspect) DBMgr.getInstance().endRequest()
'bottomRightLatitude': '46.295676244254715', 'bottomRightLongitude': '6.115661859512329', 'zoomLevel': 17, 'defaultOnStartup': False }, { 'id': 6, 'name': 'POINT 8', 'centerLatitude': 46.24158691675184, 'centerLongitude': 6.097038745847385, 'topLeftLatitude': '46.2393607911537', 'topLeftLongitude': '6.092873811721802', 'bottomRightLatitude': '46.24381295202931', 'bottomRightLongitude': '6.101188659667969', 'zoomLevel': 17, 'defaultOnStartup': False }, ] DBMgr.getInstance().startRequest() Factory.getDALManager().connect() location = Location.parse('CERN') for aspectData in aspects: aspect = MapAspect() aspect.updateFromDictionary(aspectData) location.addAspect(aspect) DBMgr.getInstance().endRequest()
def _checkParams(self): self._location = Location.parse(self._param("location")) self._aspectId = self._param("aspectId")