本文整理汇总了Python中indico.modules.rb.models.reservations.Reservation.event_id方法的典型用法代码示例。如果您正苦于以下问题:Python Reservation.event_id方法的具体用法?Python Reservation.event_id怎么用?Python Reservation.event_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.rb.models.reservations.Reservation
的用法示例。
在下文中一共展示了Reservation.event_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_reservations
# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import event_id [as 别名]
def migrate_reservations(self):
print cformat("%{white!}migrating reservations")
i = 1
for rid, v in self.rb_root["Reservations"].iteritems():
room = Room.get(v.room.id)
if room is None:
print cformat(" %{red!}skipping resv for dead room {0.room.id}: {0.id} ({0._utcCreatedDT})").format(v)
continue
repeat_frequency, repeat_interval = RepeatMapping.convert_legacy_repeatability(v.repeatability)
booked_for_id = getattr(v, "bookedForId", None)
r = Reservation(
id=v.id,
created_dt=as_utc(v._utcCreatedDT),
start_dt=utc_to_local(v._utcStartDT),
end_dt=utc_to_local(v._utcEndDT),
booked_for_id=self.merged_avatars.get(booked_for_id, booked_for_id) or None,
booked_for_name=convert_to_unicode(v.bookedForName),
contact_email=convert_to_unicode(v.contactEmail),
contact_phone=convert_to_unicode(getattr(v, "contactPhone", None)),
created_by_id=self.merged_avatars.get(v.createdBy, v.createdBy) or None,
is_cancelled=v.isCancelled,
is_accepted=v.isConfirmed,
is_rejected=v.isRejected,
booking_reason=convert_to_unicode(v.reason),
rejection_reason=convert_to_unicode(getattr(v, "rejectionReason", None)),
repeat_frequency=repeat_frequency,
repeat_interval=repeat_interval,
uses_vc=getattr(v, "usesAVC", False),
needs_vc_assistance=getattr(v, "needsAVCSupport", False),
needs_assistance=getattr(v, "needsAssistance", False),
)
for eq_name in getattr(v, "useVC", []):
eq = room.location.get_equipment_by_name(eq_name)
if eq:
r.used_equipment.append(eq)
occurrence_rejection_reasons = {}
if getattr(v, "resvHistory", None):
for h in reversed(v.resvHistory._entries):
ts = as_utc(parse_dt_string(h._timestamp))
if len(h._info) == 2:
possible_rejection_date, possible_rejection_reason = h._info
m = re.match(
r"Booking occurrence of the (\d{1,2} \w{3} \d{4}) rejected", possible_rejection_reason
)
if m:
d = datetime.strptime(m.group(1), "%d %b %Y")
occurrence_rejection_reasons[d] = possible_rejection_reason[9:].strip("'")
el = ReservationEditLog(
timestamp=ts, user_name=h._responsibleUser, info=map(convert_to_unicode, h._info)
)
r.edit_logs.append(el)
notifications = getattr(v, "startEndNotification", []) or []
excluded_days = getattr(v, "_excludedDays", []) or []
ReservationOccurrence.create_series_for_reservation(r)
for occ in r.occurrences:
occ.notification_sent = occ.date in notifications
occ.is_rejected = r.is_rejected
occ.is_cancelled = r.is_cancelled or occ.date in excluded_days
occ.rejection_reason = (
convert_to_unicode(occurrence_rejection_reasons[occ.date])
if occ.date in occurrence_rejection_reasons
else None
)
event_id = getattr(v, "_ReservationBase__owner", None)
if hasattr(event_id, "_Impersistant__obj"): # Impersistant object
event_id = event_id._Impersistant__obj
if event_id is not None:
event = self.zodb_root["conferences"].get(event_id)
if event:
# For some stupid reason there are bookings in the database which have a completely unrelated parent
guids = getattr(event, "_Conference__roomBookingGuids", [])
if any(int(x.id) == v.id for x in guids if x.id is not None):
r.event_id = int(event_id)
else:
print cformat(" %{red}event {} does not contain booking {}").format(event_id, v.id)
print cformat("- [%{cyan}{}%{reset}/%{green!}{}%{reset}] %{grey!}{}%{reset} {}").format(
room.location_name, room.name, r.id, r.created_dt.date()
)
room.reservations.append(r)
db.session.add(room)
i = (i + 1) % 1000
if not i:
db.session.commit()
db.session.commit()