def serialize_collaboration(cal, fossil, now): event = ical.Event() url = str(fossil["url"]) event.set("uid", "*****@*****.**" % fossil["uniqueId"]) event.set("dtstamp", now) event.set("dtstart", getAdjustedDate(fossil["startDate"], None, "UTC")) event.set("dtend", getAdjustedDate(fossil["endDate"], None, "UTC")) event.set("url", url) event.set("categories", "VideoService - " + fossil["type"]) event.set( "summary", VideoExportUtilities.getCondensedPrefix(fossil["type"], fossil["status"]) + fossil["title"].decode("utf-8"), ) loc = fossil.get("location", "") if loc: loc = loc.decode("utf-8") if fossil.get("room", ""): loc += ": " + fossil["room"].decode("utf-8") event.set("location", loc) description = "Event URL: " + url audience = fossil.get("audience", None) if audience: description = "Audience: %s\n" % audience + description event.set("description", description) # If there is an alarm required, add a subcomponent to the Event if fossil.has_key("alarm"): event.add_component(serialize_collaboration_alarm(fossil, now)) cal.add_component(event)
def serialize_reservation(cal, fossil, now): event = ical.Event() event.set('uid', '*****@*****.**' % fossil['id']) event.set('dtstamp', now) event.set('dtstart', getAdjustedDate(fossil['startDT'], None, "UTC")) event.set( 'dtend', getAdjustedDate( datetime.datetime.combine(fossil['startDT'].date(), fossil['endDT'].timetz()), None, "UTC")) event.set('url', fossil['bookingUrl']) event.set('summary', fossil['reason']) event.set( 'location', fossil['location'].decode('utf-8') + ': ' + fossil['room']['fullName'].decode('utf-8')) event.set('description', fossil['reason'].decode('utf-8') + '\n\n' + fossil['bookingUrl']) rrule = None if fossil['repeatability'] is not None: rrule = serialize_repeatability( fossil['startDT'], fossil['endDT'], RepeatabilityEnum.shortname2rep[fossil['repeatability']]) if rrule: event.set('rrule', rrule) cal.add_component(event)
def serialize_event(cal, fossil, now, id_prefix="indico-event"): event = ical.Event() event.set('uid', '*****@*****.**' % (id_prefix, fossil['id'])) event.set('dtstamp', now) event.set('dtstart', getAdjustedDate(fossil['startDate'], None, "UTC")) event.set('dtend', getAdjustedDate(fossil['endDate'], None, "UTC")) event.set('url', fossil['url']) event.set('summary', fossil['title'].decode('utf-8')) loc = fossil['location'] or '' if loc: loc = loc.decode('utf-8') if fossil['room']: loc += ' ' + fossil['room'].decode('utf-8') event.set('location', loc) description = "" if fossil.has_key("speakers"): speakerList = [] for speaker in fossil["speakers"]: speakerList.append("%s (%s)"%(speaker["fullName"], speaker["affiliation"])) description += "Speakers: "+ (", ").join(speakerList) + "\n" if fossil['description']: desc_text = fossil.get('description', '').strip() if not desc_text: desc_text = '<p/>' description += "Description: " + html.fromstring(desc_text.decode('utf-8')).text_content() \ + '\nURL: ' + fossil['url'] else: description += "URL: " + fossil['url'] event.set('description', description) cal.add_component(event)
def serialize_event(cal, fossil, now, id_prefix="indico-event"): event = ical.Event() event.add('uid', '*****@*****.**' % (id_prefix, fossil['id'])) event.add('dtstamp', now) event.add('dtstart', getAdjustedDate(fossil['startDate'], None, "UTC")) event.add('dtend', getAdjustedDate(fossil['endDate'], None, "UTC")) event.add('url', fossil['url']) event.add('summary', to_unicode(fossil['title'])) loc = fossil['location'] or '' if loc: loc = to_unicode(loc) if fossil['roomFullname']: loc += ' ' + to_unicode(fossil['roomFullname']) event.add('location', loc) description = "" if fossil.get('speakers'): speakers = ('{} ({})'.format(speaker['fullName'], speaker['affiliation']) for speaker in fossil['speakers']) description += 'Speakers: {}\n'.format(', '.join(speakers)) if fossil['description']: desc_text = fossil['description'].strip() if not desc_text: desc_text = '<p/>' try: description += '{}\n\n{}'.format(html.fromstring(to_unicode(desc_text)).text_content().encode('utf-8'), fossil['url']) except ParserError: # this happens e.g. if desc_text contains only a html comment description += fossil['url'] else: description += fossil['url'] event.add('description', description) cal.add_component(event)
def serialize_event(cal, fossil, now, id_prefix="indico-event"): event = ical.Event() event.add('uid', '*****@*****.**' % (id_prefix, fossil['id'])) event.add('dtstamp', now) event.add('dtstart', getAdjustedDate(fossil['startDate'], None, "UTC")) event.add('dtend', getAdjustedDate(fossil['endDate'], None, "UTC")) event.add('url', fossil['url']) event.add('summary', fossil['title'].decode('utf-8')) loc = fossil['location'] or '' if loc: loc = loc.decode('utf-8') if fossil['room']: loc += ' ' + fossil['room'].decode('utf-8') event.add('location', loc) description = "" if fossil.get('speakers'): speakers = ('{} ({})'.format(speaker['fullName'], speaker['affiliation']) for speaker in fossil['speakers']) description += 'Speakers: {}\n'.format(', '.join(speakers)) if fossil['description']: desc_text = fossil['description'].strip() if not desc_text: desc_text = '<p/>' description += '{}\n\n{}'.format( html.fromstring( desc_text.decode('utf-8')).text_content().encode('utf-8'), fossil['url']) else: description += fossil['url'] event.add('description', description) cal.add_component(event)
def serialize_collaboration(cal, fossil, now): event = ical.Event() url = str(fossil['url']) event.set('uid', '*****@*****.**' % fossil['uniqueId']) event.set('dtstamp', now) event.set('dtstart', getAdjustedDate(fossil['startDate'], None, "UTC")) event.set('dtend', getAdjustedDate(fossil['endDate'], None, "UTC")) event.set('url', url) event.set('categories', "VideoService - " + fossil['type']) event.set('summary', VideoExportUtilities.getCondensedPrefix(fossil['type'], fossil['status']) + fossil['title'].decode('utf-8')) loc = fossil.get('location', '') if loc: loc = loc.decode('utf-8') if fossil.get('room',''): loc += ': ' + fossil['room'].decode('utf-8') event.set('location', loc) description = "Event URL: " + url audience = fossil.get("audience", None) if audience: description = "Audience: %s\n"% audience + description event.set('description', description) # If there is an alarm required, add a subcomponent to the Event if fossil.has_key('alarm'): event.add_component(serialize_collaboration_alarm(fossil, now)) cal.add_component(event)
def serialize_event(cal, fossil, now, id_prefix="indico-event"): event = ical.Event() event.set("uid", "*****@*****.**" % (id_prefix, fossil["id"])) event.set("dtstamp", now) event.set("dtstart", getAdjustedDate(fossil["startDate"], None, "UTC")) event.set("dtend", getAdjustedDate(fossil["endDate"], None, "UTC")) event.set("url", fossil["url"]) event.set("summary", fossil["title"].decode("utf-8")) loc = fossil["location"] or "" if loc: loc = loc.decode("utf-8") if fossil["room"]: loc += " " + fossil["room"].decode("utf-8") event.set("location", loc) description = "" if fossil.has_key("speakers"): speakerList = [] for speaker in fossil["speakers"]: speakerList.append("%s (%s)" % (speaker["fullName"], speaker["affiliation"])) description += "Speakers: " + (", ").join(speakerList) + "\n" if fossil["description"]: desc_text = fossil.get("description", "").strip() if not desc_text: desc_text = "<p/>" description += html.fromstring(desc_text.decode("utf-8")).text_content() + "\n\n" + fossil["url"] else: description += fossil["url"] event.set("description", description) cal.add_component(event)
def serialize_event(cal, fossil, now, id_prefix="indico-event"): event = ical.Event() event.set('uid', '*****@*****.**' % (id_prefix, fossil['id'])) event.set('dtstamp', now) event.set('dtstart', getAdjustedDate(fossil['startDate'], None, "UTC")) event.set('dtend', getAdjustedDate(fossil['endDate'], None, "UTC")) event.set('url', fossil['url']) event.set('summary', fossil['title'].decode('utf-8')) loc = fossil['location'] or '' if loc: loc = loc.decode('utf-8') if fossil['room']: loc += ' ' + fossil['room'].decode('utf-8') event.set('location', loc) description = "" if fossil.has_key("speakers"): speakerList = [] for speaker in fossil["speakers"]: speakerList.append("%s (%s)"%(speaker["fullName"], speaker["affiliation"])) description += "Speakers: "+ (", ").join(speakerList) + "\n" if fossil['description']: desc_text = fossil.get('description', '').strip() if not desc_text: desc_text = '<p/>' description += html.fromstring(desc_text.decode('utf-8')).text_content() + '\n\n'+ fossil['url'] else: description += fossil['url'] event.set('description', description) cal.add_component(event)
def formatTwoDates(date1, date2, tz = None, useToday = False, useTomorrow = False, dayFormat = None, capitalize = True, showWeek = False): """ Formats two dates, such as an event start and end date, taking into account if they happen the same day (given a timezone). -date1 and date2 have to be timezone-aware. -If no tz argument is provided, tz will be the timezone of date1. tz can be a string or a timezone "object" -dayFormat and showWeek are passed to formatDate function, so they behave the same way as in that function -capitalize: capitalize week days AND first letter of sentence if there is one Examples: 17/07/2009 from 08:00 to 18:00 (default args, 2 dates in same day) from 17/07/2009 at 08:00 to 19/07/2009 at 14:00 (default args, 2 dates in different day) Fri 17/07/2009 from 08:00 to 18:00 (showWeek = True, default args, 2 dates in same day) today from 10:00 to 11:00 (useToday = True, default args, 2 dates in same day and it happens to be today) """ if not tz: tz = date1.tzinfo date1 = getAdjustedDate(date1, tz = tz) date2 = getAdjustedDate(date2, tz = tz) sameDay = isSameDay(date1, date2, tz) date1text = '' date2text = '' if useToday: if isToday(date1, tz): date1text = "today" if isToday(date2, tz): date2text = "today" if useTomorrow: if isTomorrow(date1, tz): date1text = "isTomorrow" if isTomorrow(date2, tz): date2text = "isTomorrow" if not date1text: date1text = formatDate(date1.date(), showWeek, dayFormat) if capitalize: date1text = date1text.capitalize() if not date2text: date2text = formatDate(date2.date(), showWeek, dayFormat) if capitalize: date2text = date2text.capitalize() time1text = formatTime(date1.time()) time2text = formatTime(date2.time()) if sameDay: result = date1text + ' from ' + time1text + ' to ' + time2text else: if capitalize: fromText = 'From ' else: fromText = 'from ' result = fromText + date1text + ' at ' + time1text + ' to ' + date2text + ' at ' + time2text return result
def getVars( self ): vars = wcomponents.WTemplated.getVars( self ) plugins = self._tabPlugins singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins) CSBookingManager = self._conf.getCSBookingManager() bookingsS = {} for p in singleBookingPlugins: bookingList = CSBookingManager.getBookingList(filterByType = p.getName()) if len(bookingList) > 0: bookingsS[p.getName()] = DictPickler.pickle(bookingList[0]) bookingsM = DictPickler.pickle(CSBookingManager.getBookingList( sorted = True, notify = True, filterByType = [p.getName() for p in multipleBookingPlugins])) vars["Conference"] = self._conf vars["AllPlugins"] = plugins vars["SingleBookingPlugins"] = singleBookingPlugins vars["BookingsS"] = bookingsS vars["MultipleBookingPlugins"] = multipleBookingPlugins vars["BookingsM"] = bookingsM vars["Tab"] = self._activeTab vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(),self._conf)) from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(user = self._user) or RCCollaborationPluginAdmin.hasRights(user = self._user, plugins = self._tabPlugins) singleBookingForms = {} multipleBookingForms = {} JSCodes = {} canBeNotified = {} for plugin in singleBookingPlugins: pluginName = plugin.getName() templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm") singleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML() for plugin in multipleBookingPlugins: pluginName = plugin.getName() templateClass = CollaborationTools.getTemplateClass(pluginName, "WNewBookingForm") multipleBookingForms[pluginName] = templateClass(self._conf, pluginName, self._user).getHTML() for plugin in plugins: pluginName = plugin.getName() templateClass = CollaborationTools.getTemplateClass(pluginName, "WMain") JSCodes[pluginName] = templateClass(pluginName, self._conf).getHTML() bookingClass = CollaborationTools.getCSBookingClass(pluginName) canBeNotified[pluginName] = bookingClass._canBeNotifiedOfEventDateChanges vars["SingleBookingForms"] = singleBookingForms vars["MultipleBookingForms"] = multipleBookingForms vars["JSCodes"] = JSCodes vars["CanBeNotified"] = canBeNotified return vars
def getAdjustedReviewerDueDate(self): """ Returns a timezeone-aware Deadline for all the reviewers given the conference's timezone. """ if self.getReviewerDueDate() is None: return None else: return getAdjustedDate(self._reviewerDueDate, self.getConference())
def getAdjustedEditorDueDate(self): """ Returns a timezeone-aware Deadline for the editor given the conference's timezone. """ if self.getEditorDueDate() is None: return None else: return getAdjustedDate(self._editorDueDate, self.getConference())
def getAdjustedRefereeDueDate(self): """ Returns a timezeone-aware due date for the referee given the conference's timezone. """ if self.getRefereeDueDate() is None: return None else: return getAdjustedDate(self._refereeDueDate, self.getConference())
def getVars(self): vars = WCSPageTemplateBase.getVars(self) vars["EventTitle"] = self._conf.getTitle() vars["EventDescription"] = unescape_html(strip_ml_tags(self._conf.getDescription())).strip() defaultStartDate = self._conf.getAdjustedStartDate() - timedelta( 0, 0, 0, 0, self._EVOOptions["defaultMinutesBefore"].getValue() ) nowStartDate = getAdjustedDate( nowutc() - timedelta(0, 0, 0, 0, self._EVOOptions["allowedPastMinutes"].getValue() / 2), self._conf ) vars["DefaultStartDate"] = formatDateTime(max(defaultStartDate, nowStartDate)) defaultEndDate = self._conf.getAdjustedEndDate() + timedelta( 0, 0, 0, 0, self._EVOOptions["defaultMinutesAfter"].getValue() ) nowEndDate = nowStartDate + timedelta(0, 0, 0, 0, self._EVOOptions["extraMinutesAfter"].getValue()) vars["DefaultEndDate"] = formatDateTime(max(defaultEndDate, nowEndDate)) communities = self._EVOOptions["communityList"].getValue() # a dict communityId : communityName communityItems = communities.items() # a list of tuples (communityId, communityName) communityItems.sort(key=lambda t: t[1]) # we sort by the second member of the tuple (the name) vars["Communities"] = communityItems return vars
def getVars(self): vars = WCSPageTemplateBase.getVars(self) vars["EventTitle"] = self._conf.getTitle() vars["EventDescription"] = unescape_html( strip_ml_tags(self._conf.getDescription())).strip() defaultStartDate = self._conf.getAdjustedStartDate() - timedelta( 0, 0, 0, 0, self._EVOOptions["defaultMinutesBefore"].getValue()) nowStartDate = getAdjustedDate( nowutc() - timedelta(0, 0, 0, 0, self._EVOOptions["allowedPastMinutes"].getValue() / 2), self._conf) vars["DefaultStartDate"] = formatDateTime( max(defaultStartDate, nowStartDate)) defaultEndDate = self._conf.getAdjustedEndDate() + timedelta( 0, 0, 0, 0, self._EVOOptions["defaultMinutesAfter"].getValue()) nowEndDate = nowStartDate + timedelta( 0, 0, 0, 0, self._EVOOptions["extraMinutesAfter"].getValue()) vars["DefaultEndDate"] = formatDateTime(max(defaultEndDate, nowEndDate)) communities = self._EVOOptions["communityList"].getValue( ) # a dict communityId : communityName communityItems = communities.items( ) # a list of tuples (communityId, communityName) communityItems.sort(key=lambda t: t[ 1]) # we sort by the second member of the tuple (the name) vars["Communities"] = communityItems return vars
def serialize_reservation(cal, fossil, now): event = ical.Event() event.set('uid', '*****@*****.**' % fossil['id']) event.set('dtstamp', now) event.set('dtstart', getAdjustedDate(fossil['startDT'], None, "UTC")) event.set('dtend', getAdjustedDate(datetime.datetime.combine(fossil['startDT'].date(), fossil['endDT'].timetz()), None, "UTC")) event.set('url', fossil['bookingUrl']) event.set('summary', fossil['reason']) event.set('location', fossil['location'].decode('utf-8') + ': ' + fossil['room']['fullName'].decode('utf-8')) event.set('description', fossil['reason'].decode('utf-8') + '\n\n' + fossil['bookingUrl']) rrule = None if fossil['repeatability'] is not None: rrule = serialize_repeatability(fossil['startDT'], fossil['endDT'], RepeatabilityEnum.shortname2rep[fossil['repeatability']]) if rrule: event.set('rrule', rrule) cal.add_component(event)
def getVars(self): vars = WJSBase.getVars(self) vars["AllowedStartMinutes"] = self._EVOOptions["allowedPastMinutes"].getValue() vars["MinStartDate"] = formatDateTime(getMinStartDate(self._conf)) vars["MaxEndDate"] = formatDateTime(getMaxEndDate(self._conf)) vars["ExtraMinutesBefore"] = self._EVOOptions["extraMinutesBefore"].getValue() vars["ExtraMinutesAfter"] = self._EVOOptions["extraMinutesAfter"].getValue() vars["PossibleToCreateOrModify"] = getAdjustedDate(nowutc(), self._conf) < getMaxEndDate(self._conf) vars["GeneralSettingsURL"] = urlHandlers.UHConferenceModification.getURL(self._conf) return vars
def __init__(self, maxDate, previousTotal, newTotal, error=None, attainedDate=None): GenericNotification.__init__(self) self.setFromAddr("Indico Mailer <%s>" % Config.getInstance().getSupportEmail()) self.setContentType("text/html") self.setToList(MailTools.getAdminEmailList('Vidyo')) serverTimezone = info.HelperMaKaCInfo.getMaKaCInfoInstance( ).getTimezone() if error: self.setSubject( """[Vidyo] Old room cleaning failed: %s rooms deleted""" % str(previousTotal - newTotal)) self.setBody("""Dear Vidyo Manager,<br /> <br /> A cleanup of old Vidyo rooms in <a href="%s">%s</a> encountered the following error:%s<br /> "All rooms before %s (%s, server timezone) should have been deleted but only the date %s was reached.<br /> There were %s rooms before the operation and there are %s rooms left now.<br /> """ % (MailTools.getServerName(), MailTools.getServerName(), escape( str(error)), formatDateTime(getAdjustedDate(maxDate, tz=serverTimezone)), serverTimezone, formatDateTime(getAdjustedDate(attainedDate, tz=serverTimezone)), str(previousTotal), str(newTotal))) else: self.setSubject( """[Vidyo] Old room cleaning successful: %s rooms deleted""" % str(previousTotal - newTotal)) self.setBody("""Dear Vidyo Manager,<br /> <br /> A cleanup was successfully executed for old Vidyo rooms in <a href="%s">%s</a>.<br /> All rooms attached to events finishing before %s (%s, server timezone) were deleted in the Vidyo server.<br /> There were %s rooms before the operation and there are %s rooms left now.<br /> """ % (MailTools.getServerName(), MailTools.getServerName(), formatDateTime(getAdjustedDate(maxDate, tz=serverTimezone)), serverTimezone, str(previousTotal), str(newTotal)))
def serialize_reservation(cal, fossil, now): event = ical.Event() event.set("uid", "*****@*****.**" % fossil["id"]) event.set("dtstamp", now) event.set("dtstart", getAdjustedDate(fossil["startDT"], None, "UTC")) event.set( "dtend", getAdjustedDate(datetime.datetime.combine(fossil["startDT"].date(), fossil["endDT"].timetz()), None, "UTC"), ) event.set("url", fossil["bookingUrl"]) event.set("summary", fossil["reason"]) event.set("location", fossil["location"].decode("utf-8") + ": " + fossil["room"]["fullName"].decode("utf-8")) event.set("description", fossil["reason"].decode("utf-8") + "\n\n" + fossil["bookingUrl"]) rrule = None if fossil["repeatability"] is not None: rrule = serialize_repeatability( fossil["startDT"], fossil["endDT"], RepeatabilityEnum.shortname2rep[fossil["repeatability"]] ) if rrule: event.set("rrule", rrule) cal.add_component(event)
def bookingModificationDate(cls, booking, typeOfMail): if (typeOfMail == 'new'): return "" else: return """ <tr> <td style="vertical-align: top; white-space : nowrap;"> <strong>Modification date:</strong> </td> <td style="vertical-align: top;"> %s </td> </tr> """ % formatDateTime(getAdjustedDate(booking.getModificationDate(), booking.getConference()))
def __init__(self, maxDate, previousTotal, newTotal, error = None, attainedDate = None): GenericNotification.__init__(self) self.setFromAddr("Indico Mailer <%s>" % Config.getInstance().getSupportEmail()) self.setContentType("text/html") self.setToList(MailTools.getAdminEmailList('Vidyo')) serverTimezone = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone() if error: self.setSubject("""[Vidyo] Old room cleaning failed: %s rooms deleted""" % str(previousTotal - newTotal)) self.setBody("""Dear Vidyo Manager,<br /> <br /> A cleanup of old Vidyo rooms in <a href="%s">%s</a> encountered the following error:%s<br /> "All rooms before %s (%s, server timezone) should have been deleted but only the date %s was reached.<br /> There were %s rooms before the operation and there are %s rooms left now.<br /> """ % (MailTools.getServerName(), MailTools.getServerName(), escape(str(error)), formatDateTime(getAdjustedDate(maxDate, tz=serverTimezone)), serverTimezone, formatDateTime(getAdjustedDate(attainedDate, tz=serverTimezone)), str(previousTotal), str(newTotal))) else: self.setSubject("""[Vidyo] Old room cleaning successful: %s rooms deleted""" % str(previousTotal - newTotal)) self.setBody("""Dear Vidyo Manager,<br /> <br /> A cleanup was successfully executed for old Vidyo rooms in <a href="%s">%s</a>.<br /> All rooms attached to events finishing before %s (%s, server timezone) were deleted in the Vidyo server.<br /> There were %s rooms before the operation and there are %s rooms left now.<br /> """ % (MailTools.getServerName(), MailTools.getServerName(), formatDateTime(getAdjustedDate(maxDate, tz=serverTimezone)), serverTimezone, str(previousTotal), str(newTotal)))
def getVars(self): vars = WJSBase.getVars(self) vars["AllowedStartMinutes"] = self._EVOOptions[ "allowedPastMinutes"].getValue() vars["MinStartDate"] = formatDateTime(getMinStartDate(self._conf)) vars["MaxEndDate"] = formatDateTime(getMaxEndDate(self._conf)) vars["ExtraMinutesBefore"] = self._EVOOptions[ "extraMinutesBefore"].getValue() vars["ExtraMinutesAfter"] = self._EVOOptions[ "extraMinutesAfter"].getValue() vars["PossibleToCreateOrModify"] = getAdjustedDate( nowutc(), self._conf) < getMaxEndDate(self._conf) vars[ "GeneralSettingsURL"] = urlHandlers.UHConferenceModification.getURL( self._conf) return vars
class WConfModifChat(wcomponents.WTemplated): def __init__(self, conference, activeTab, tabNames, aw): self._conf = conference self._activeTab = activeTab self._tabNames = tabNames self._aw = aw self._user = aw.getUser() def getVars(self): vars = WTemplated.getVars(self) vars["Conference"] = self._conf try: chatrooms = list(DBHelpers.getChatroomList(self._conf)) vars["Chatrooms"] = fossilize(chatrooms) if len(vars['Chatrooms']) is 0: vars['Chatrooms'] = None except Exception, e: vars["Chatrooms"] = None chatrooms = {} links = {} for cr in chatrooms: crinfo = links[cr.getId()] = {} crinfo['custom'] = generateCustomLinks(cr) crinfo['logs'] = generateLogLink(cr, self._conf) vars['links'] = links vars['DefaultServer'] = PluginFieldsWrapper( 'InstantMessaging', 'XMPP').getOption('chatServerHost') vars["EventDate"] = formatDateTime( getAdjustedDate(nowutc(), self._conf)) vars["User"] = self._user vars["tz"] = DisplayTZ(self._aw, self._conf).getDisplayTZ() vars["MaterialUrl"] = RHMaterialsShow._uh().getURL( self._conf).__str__() vars["ShowLogsLink"] = XMPPLogsActivated() return vars
def collaborationToXML(cls, out, conf, tz): """ Generates the xml corresponding to the collaboration plugin system for an event. """ #collaboration XML out.openTag("collaboration") csbm = conf.getCSBookingManager() out.writeComment("Needed for timezone awareness") out.writeTag("todayReference", getAdjustedDate(nowutc(), None, tz).strftime("%Y-%m-%d")) out.writeTag("tomorrowReference", getAdjustedDate(nowutc() + timedelta(days = 1), None, tz).strftime("%Y-%m-%d")) pluginNames = csbm.getEventDisplayPlugins() bookingXmlGenerators = {} for pluginName in pluginNames: xmlGenerator = CollaborationTools.getXMLGenerator(pluginName) bookingXmlGenerators[pluginName] = xmlGenerator bookings = csbm.getBookingList(filterByType = pluginNames, notify = True, onlyPublic = True) bookings.sort(key = lambda b: b.getStartDate() or minDatetime()) ongoingBookings = [] scheduledBookings = [] for b in bookings: if b.canBeStarted(): ongoingBookings.append(b) if b.hasStartDate() and b.getAdjustedStartDate('UTC') > nowutc(): scheduledBookings.append(b) for b in ongoingBookings : bookingType = b.getType() out.openTag("booking") out.writeTag("id", b.getId()) out.writeTag("kind", "ongoing") out.writeTag("type", bookingType) out.writeTag("typeDisplayName", bookingXmlGenerators[bookingType].getDisplayName()) if b.hasStartDate(): out.writeTag("startDate", b.getAdjustedStartDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) out.writeTag("endDate",b.getAdjustedEndDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) bookingXmlGenerators[bookingType].getCustomBookingXML(b, tz, out) out.closeTag("booking") for b in scheduledBookings : bookingType = b.getType() out.openTag("booking") out.writeTag("id", b.getId()) out.writeTag("title", b._getTitle()) out.writeTag("kind", "scheduled") out.writeTag("type", bookingType) out.writeTag("typeDisplayName", bookingXmlGenerators[bookingType].getDisplayName()) if b.hasStartDate(): out.writeTag("startDate", b.getAdjustedStartDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) out.writeTag("endDate",b.getAdjustedEndDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) bookingXmlGenerators[bookingType].getCustomBookingXML(b, tz, out) out.closeTag("booking") out.closeTag("collaboration")
def assignAttributes(self, response_xml): verboseKeyNames = { "meet:meetingkey": "WebEx Meeting ID", "meet:agenda": _("Meeting description"), "meet:confName": _("Title"), "meet:hostWebExID": _("WebEx host account"), "meet:startDate": _("Start time"), "meet:duration": _("Duration"), "meet:meetingPassword": _("Meeting password"), } dom = xml.dom.minidom.parseString(response_xml) oldArguments = self.getCreateModifyArguments() changesFromWebEx = self._bookingChangesHistory latestChanges = [] start_date = makeTime( self.getAdjustedStartDate('UTC')).strftime("%m/%d/%Y %H:%M:%S") time_discrepancy = False for key in oldArguments: if not verboseKeyNames.has_key(key): continue if key == "meet:startDate" or key == "meet:duration": if key == "meet:startDate": if dom.getElementsByTagName(key)[0].firstChild.toxml( 'utf-8') != start_date: time_discrepancy = True if key == "meet:duration": if dom.getElementsByTagName(key)[0].firstChild.toxml( 'utf-8') != str(self._duration): time_discrepancy = True user_msg = _("Updated booking duration from ") + str( self._duration) + _(" minutes to ") + str( dom.getElementsByTagName(key) [0].firstChild.toxml('utf-8') + _(" minutes")) self._duration = int( dom.getElementsByTagName(key)[0].firstChild.toxml( 'utf-8')) continue try: if unescape( dom.getElementsByTagName(key) [0].firstChild.toxml('utf-8')) != unescape( str(oldArguments[key])) and key in verboseKeyNames: changesFromWebEx.append(verboseKeyNames[key] + ": " + dom.getElementsByTagName(key) [0].firstChild.toxml('utf-8')) latestChanges.append(verboseKeyNames[key] + ": " + dom.getElementsByTagName( key)[0].firstChild.toxml('utf-8')) if key == "meet:confName": self._bookingParams["meetingTitle"] = unescape( dom.getElementsByTagName(key)[0].firstChild.toxml( 'utf-8')) elif key == "meet:agenda": self._bookingParams["meetingDescription"] = unescape( dom.getElementsByTagName(key)[0].firstChild.toxml( 'utf-8')) except: Logger.get('WebEx').info("caught exception on: " + key) pass self._phoneNum = dom.getElementsByTagName( "serv:tollFreeNum")[0].firstChild.toxml('utf-8') self._phoneNumToll = dom.getElementsByTagName( "serv:tollNum")[0].firstChild.toxml('utf-8') # We calculate the time from WebEx first assuming it is in UTC. # If not, we then apply the offset to keep it simple calc_time = naive2local( datetime(*strptime( dom.getElementsByTagName("meet:startDate")[0].firstChild.toxml( 'utf-8'), "%m/%d/%Y %H:%M:%S")[0:7]), 'UTC') tz_id = dom.getElementsByTagName( "meet:timeZoneID")[0].firstChild.toxml('utf-8') # If the specified time zone is not UTC, contact WebEx # and find the offset from UTC we must account for if tz_id != 20: time_offset_mins = self.getWebExTimeZoneToUTC( tz_id, calc_time.strftime("%m/%d/%Y %H:%M:%S")) WE_time = calc_time + timedelta(minutes=-1 * int(time_offset_mins)) #Now that we have the REAL time, figure out if there REALLY is a time difference if time_discrepancy == True: if self._startDate != getAdjustedDate( WE_time, tz=self._conf.getTimezone()): self._startDate = getAdjustedDate( WE_time, tz=self._conf.getTimezone()) changesFromWebEx.append( _("Updated start time to match WebEx entry")) latestChanges.append( _("Updated start time to match WebEx entry")) if self._endDate != getAdjustedDate( WE_time, tz=self._conf.getTimezone()) + timedelta( minutes=int(self._duration)): self._endDate = getAdjustedDate( WE_time, tz=self._conf.getTimezone()) + timedelta( minutes=int(self._duration)) changesFromWebEx.append( _("Updated end time to match WebEx entry")) latestChanges.append( _("Updated start time to match WebEx entry")) self.checkCanStart() self._bookingChangesHistory = changesFromWebEx self._latestChanges = latestChanges
def getAdjustedSubmissionDate(self): """ Returns a timezone-aware submission date given the conference's timezone. """ return getAdjustedDate(self._submissionDate, self.getReviewManager().getConference())
def assignAttributes(self, response_xml): verboseKeyNames = { "meet:meetingkey": "WebEx Meeting ID", "meet:agenda": _("Meeting description"), "meet:confName": _("Title"), "meet:hostWebExID": _("WebEx host account"), "meet:startDate": _("Start time"), "meet:duration": _("Duration"), "meet:meetingPassword": _("Meeting password"), } dom = xml.dom.minidom.parseString( response_xml ) oldArguments = self.getCreateModifyArguments() changesFromWebEx = self._bookingChangesHistory latestChanges = [] start_date = makeTime( self.getAdjustedStartDate('UTC') ).strftime( "%m/%d/%Y %H:%M:%S" ) time_discrepancy = False for key in oldArguments: if not verboseKeyNames.has_key( key ): continue if key == "meet:startDate" or key == "meet:duration": if key == "meet:startDate": if dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8') != start_date: time_discrepancy = True if key == "meet:duration": if dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8') != str(self._duration): time_discrepancy = True user_msg = _("Updated booking duration from ") + str(self._duration) + _(" minutes to ") + str( dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8') + _(" minutes")) self._duration = int( dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8') ) continue try: if unescape(dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8')) != unescape(str(oldArguments[key])) and key in verboseKeyNames: changesFromWebEx.append(verboseKeyNames[key] + ": " + dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8')) latestChanges.append(verboseKeyNames[key] + ": " + dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8')) if key == "meet:confName": self._bookingParams["meetingTitle"] = unescape(dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8')) elif key == "meet:agenda": self._bookingParams["meetingDescription"] = unescape(dom.getElementsByTagName( key )[0].firstChild.toxml('utf-8')) except: Logger.get('WebEx').info( "caught exception on: " + key ) pass self._phoneNum = dom.getElementsByTagName( "serv:tollFreeNum" )[0].firstChild.toxml('utf-8') self._phoneNumToll = dom.getElementsByTagName( "serv:tollNum" )[0].firstChild.toxml('utf-8') # We calculate the time from WebEx first assuming it is in UTC. # If not, we then apply the offset to keep it simple calc_time = naive2local( datetime( *strptime( dom.getElementsByTagName( "meet:startDate" )[0].firstChild.toxml('utf-8'), "%m/%d/%Y %H:%M:%S" )[0:7]), 'UTC' ) tz_id = dom.getElementsByTagName( "meet:timeZoneID" )[0].firstChild.toxml('utf-8') # If the specified time zone is not UTC, contact WebEx # and find the offset from UTC we must account for if tz_id != 20: time_offset_mins = self.getWebExTimeZoneToUTC( tz_id, calc_time.strftime("%m/%d/%Y %H:%M:%S")) WE_time = calc_time + timedelta( minutes= -1*int( time_offset_mins ) ) #Now that we have the REAL time, figure out if there REALLY is a time difference if time_discrepancy == True: if self._startDate != getAdjustedDate(WE_time, tz=self._conf.getTimezone()): self._startDate = getAdjustedDate(WE_time, tz=self._conf.getTimezone()) changesFromWebEx.append(_("Updated start time to match WebEx entry")) latestChanges.append(_("Updated start time to match WebEx entry")) if self._endDate != getAdjustedDate(WE_time, tz=self._conf.getTimezone()) + timedelta( minutes=int( self._duration ) ): self._endDate = getAdjustedDate(WE_time, tz=self._conf.getTimezone()) + timedelta( minutes=int( self._duration ) ) changesFromWebEx.append(_("Updated end time to match WebEx entry")) latestChanges.append(_("Updated start time to match WebEx entry")) self.checkCanStart() self._bookingChangesHistory = changesFromWebEx self._latestChanges = latestChanges
def getAdjustedDefaultReviewerDueDate(self): if self.getDefaultReviewerDueDate() is None: return None else: return getAdjustedDate(self._defaultReviwerDueDate, self.getConference())
def getAdjustedCreationDate(self, tz='UTC'): return getAdjustedDate(self.getCreationDate(), tz=tz)
def getVars(self): vars = wcomponents.WTemplated.getVars(self) plugins = self._tabPlugins singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins) csBookingManager = Catalog.getIdx("cs_bookingmanager_conference").get(self._conf.getId()) bookingsS = {} for p in singleBookingPlugins: bookingList = csBookingManager.getBookingList(filterByType = p.getId()) if len(bookingList) > 0: bookingsS[p.getId()] = fossilize(bookingList[0]) #will use ICSBookingConfModifBaseFossil or inheriting fossil bookingsM = fossilize(csBookingManager.getBookingList( sorted = True, notify = True, filterByType = [p.getName() for p in multipleBookingPlugins])) #will use ICSBookingConfModifBaseFossil or inheriting fossil vars["Conference"] = self._conf vars["AllPlugins"] = plugins vars["SingleBookingPlugins"] = singleBookingPlugins vars["BookingsS"] = bookingsS vars["MultipleBookingPlugins"] = multipleBookingPlugins vars["BookingsM"] = bookingsM vars["Tab"] = self._activeTab vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(), self._conf)) from MaKaC.plugins.Collaboration.handlers import RCCollaborationAdmin, RCCollaborationPluginAdmin, RCVideoServicesUser vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(self._user) or RCCollaborationPluginAdmin.hasRights(self._user, plugins=self._tabPlugins) hasCreatePermissions = {} videoServSupport = {} isAllowedToSearch = {} for plugin in plugins: pname = plugin.getName() hasCreatePermissions[pname] = RCVideoServicesUser.hasRights(user=self._user, pluginName=pname) videoServSupport[pname] = plugin.getOption("contactSupport").getValue() \ if plugin.hasOption("contactSupport") else "" isAllowedToSearch[pname] = plugin.getOption("searchAllow").getValue() if plugin.hasOption("searchAllow") \ else False vars["HasCreatePermissions"] = hasCreatePermissions vars["VideoServiceSupport"] = videoServSupport vars["isAllowedToSearch"] = isAllowedToSearch singleBookingForms = {} multipleBookingForms = {} jsCodes = {} canBeNotified = {} for plugin in singleBookingPlugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm") singleBookingForms[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML() for plugin in multipleBookingPlugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm") newBookingFormHTML = templateClass(self._conf, plugin.getId(), self._user).getHTML() advancedTabClass = CollaborationTools.getTemplateClass(pluginId, "WAdvancedTab") if advancedTabClass: advancedTabClassHTML = advancedTabClass(self._conf, plugin.getId(), self._user).getHTML() else: advancedTabClassHTML = WConfModifCollaborationDefaultAdvancedTab(self._conf, plugin, self._user).getHTML() multipleBookingForms[pluginId] = (newBookingFormHTML, advancedTabClassHTML) for plugin in plugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WMain") jsCodes[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML() bookingClass = CollaborationTools.getCSBookingClass(pluginId) canBeNotified[pluginId] = bookingClass._canBeNotifiedOfEventDateChanges vars["SingleBookingForms"] = singleBookingForms vars["MultipleBookingForms"] = multipleBookingForms vars["JSCodes"] = jsCodes vars["CanBeNotified"] = canBeNotified return vars
def bookingCreationDate(cls, booking): return formatDateTime(getAdjustedDate(booking.getCreationDate(), booking.getConference()))
def bookingCreationDate(cls, booking): return formatDateTime( getAdjustedDate(booking.getCreationDate(), booking.getConference()))
def getVars(self): vars = wcomponents.WTemplated.getVars(self) plugins = self._tabPlugins singleBookingPlugins, multipleBookingPlugins = CollaborationTools.splitPluginsByAllowMultiple(plugins) csBookingManager = self._conf.getCSBookingManager() bookingsS = {} for p in singleBookingPlugins: bookingList = csBookingManager.getBookingList(filterByType = p.getId()) if len(bookingList) > 0: bookingsS[p.getId()] = fossilize(bookingList[0]) #will use ICSBookingConfModifBaseFossil or inheriting fossil bookingsM = fossilize(csBookingManager.getBookingList( sorted = True, notify = True, filterByType = [p.getName() for p in multipleBookingPlugins])) #will use ICSBookingConfModifBaseFossil or inheriting fossil vars["Conference"] = self._conf vars["AllPlugins"] = plugins vars["SingleBookingPlugins"] = singleBookingPlugins vars["BookingsS"] = bookingsS vars["MultipleBookingPlugins"] = multipleBookingPlugins vars["BookingsM"] = bookingsM vars["Tab"] = self._activeTab vars["EventDate"] = formatDateTime(getAdjustedDate(nowutc(), self._conf)) from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin, RCVideoServicesUser vars["UserIsAdmin"] = RCCollaborationAdmin.hasRights(user = self._user) or RCCollaborationPluginAdmin.hasRights(user = self._user, plugins = self._tabPlugins) hasCreatePermissions = {} videoServSupport = {} for plugin in plugins: pname = plugin.getName() hasCreatePermissions[pname] = RCVideoServicesUser.hasRights(user = self._user, pluginName = pname) videoServSupport[pname] = plugin.getOption("contactSupport").getValue() if plugin.hasOption("contactSupport") else "" vars["HasCreatePermissions"] = hasCreatePermissions vars["VideoServiceSupport"] = videoServSupport singleBookingForms = {} multipleBookingForms = {} jsCodes = {} canBeNotified = {} for plugin in singleBookingPlugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm") singleBookingForms[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML() for plugin in multipleBookingPlugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WNewBookingForm") newBookingFormHTML = templateClass(self._conf, plugin.getId(), self._user).getHTML() advancedTabClass = CollaborationTools.getTemplateClass(pluginId, "WAdvancedTab") if advancedTabClass: advancedTabClassHTML = advancedTabClass(self._conf, plugin.getId(), self._user).getHTML() else: advancedTabClassHTML = WConfModifCollaborationDefaultAdvancedTab(self._conf, plugin, self._user).getHTML() multipleBookingForms[pluginId] = (newBookingFormHTML, advancedTabClassHTML) for plugin in plugins: pluginId = plugin.getId() templateClass = CollaborationTools.getTemplateClass(pluginId, "WMain") jsCodes[pluginId] = templateClass(self._conf, plugin.getId(), self._user).getHTML() bookingClass = CollaborationTools.getCSBookingClass(pluginId) canBeNotified[pluginId] = bookingClass._canBeNotifiedOfEventDateChanges vars["SingleBookingForms"] = singleBookingForms vars["MultipleBookingForms"] = multipleBookingForms vars["JSCodes"] = jsCodes vars["CanBeNotified"] = canBeNotified return vars
def collaborationToXML(cls, out, conf, tz): """ Generates the xml corresponding to the collaboration plugin system for an event. """ #collaboration XML out.openTag("collaboration") csbm = Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()) out.writeComment("Needed for timezone awareness") out.writeTag("todayReference", getAdjustedDate(nowutc(), None, tz).strftime("%Y-%m-%d")) out.writeTag( "tomorrowReference", getAdjustedDate(nowutc() + timedelta(days=1), None, tz).strftime("%Y-%m-%d")) pluginNames = csbm.getEventDisplayPlugins() bookingXmlGenerators = {} for pluginName in pluginNames: xmlGenerator = CollaborationTools.getXMLGenerator(pluginName) bookingXmlGenerators[pluginName] = xmlGenerator bookings = csbm.getBookingList(filterByType=pluginNames, notify=True, onlyPublic=True) bookings.sort(key=lambda b: b.getStartDate() or minDatetime()) ongoingBookings = [] scheduledBookings = [] for b in bookings: if b.canBeStarted(): ongoingBookings.append(b) if b.hasStartDate() and b.getAdjustedStartDate('UTC') > nowutc(): scheduledBookings.append(b) for b in ongoingBookings: bookingType = b.getType() out.openTag("booking") out.writeTag("id", b.getId()) out.writeTag("kind", "ongoing") out.writeTag("type", bookingType) out.writeTag("typeDisplayName", bookingXmlGenerators[bookingType].getDisplayName()) if b.hasStartDate(): out.writeTag( "startDate", b.getAdjustedStartDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) out.writeTag( "endDate", b.getAdjustedEndDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) bookingXmlGenerators[bookingType].getCustomBookingXML(b, tz, out) out.closeTag("booking") for b in scheduledBookings: bookingType = b.getType() out.openTag("booking") out.writeTag("id", b.getId()) out.writeTag("title", b._getTitle()) out.writeTag("kind", "scheduled") out.writeTag("type", bookingType) out.writeTag("typeDisplayName", bookingXmlGenerators[bookingType].getDisplayName()) if b.hasStartDate(): out.writeTag( "startDate", b.getAdjustedStartDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) out.writeTag( "endDate", b.getAdjustedEndDate(tz).strftime("%Y-%m-%dT%H:%M:%S")) bookingXmlGenerators[bookingType].getCustomBookingXML(b, tz, out) out.closeTag("booking") out.closeTag("collaboration")