Ejemplo n.º 1
0
 def _sendEventRequest(self, key, eventType, avatar, conference):
     try:
         logger = self.getLogger()
         plugin = PluginsHolder().getPluginType('calendaring').getPlugin('outlook')
         if not isUserPluginEnabled(avatar.getId()):
             logger.info("Outlook plugin disabled for user: {}".format(avatar.getId()))
             return {'status_code': 200}
         if eventType in ['added', 'updated']:
             logger.debug("Performing '{}' for: {}".format(eventType, avatar.getId()))
             url = urlHandlers.UHConferenceDisplay.getURL(conference)
             location = strip_control_chars(conference.getRoom().getName()) if conference.getRoom() else ''
             description = strip_control_chars(conference.getDescription())
             self.payload = {'userEmail': avatar.getEmail(),
                             'uniqueID': plugin.getOption('prefix').getValue() + key,
                             'subject': strip_control_chars(conference.getTitle()),
                             'location': location,
                             'body': '<a href="{}">{}</a><br><br>{}'.format(url, url, description),
                             'status': plugin.getOption('status').getValue(),
                             'startDate': format_datetime(conference.getStartDate(),
                                                          format=plugin.getOption('datetimeFormat').getValue(),
                                                          timezone=pytz.utc),
                             'endDate': format_datetime(conference.getEndDate(),
                                                        format=plugin.getOption('datetimeFormat').getValue(),
                                                        timezone=pytz.utc),
                             'isThereReminder': plugin.getOption('reminder').getValue(),
                             'reminderTimeInMinutes': plugin.getOption('reminder_minutes').getValue()}
             operation = plugin.getOption('addToCalendarOperationName').getValue() if eventType == 'added' else plugin.getOption('updateCalendarOperationName').getValue()
         elif eventType == 'removed':
             logger.debug("Removing calendar entry for: {}".format(avatar.getId()))
             self.payload = {'userEmail': avatar.getEmail(),
                             'uniqueID': plugin.getOption('prefix').getValue() + key}
             operation = plugin.getOption('removeFromCalendarOperationName').getValue()
         else:
             return None
         headers = {'content-type': 'application/x-www-form-urlencoded'}
         return requests.post(urlpath.tslash(plugin.getOption('url').getValue()) + operation,
                              auth=(plugin.getOption('login').getValue(), plugin.getOption('password').getValue()),
                              data=self.payload, headers=headers, timeout=plugin.getOption('timeout').getValue())
     except requests.exceptions.Timeout:
         logger.exception('Timeout')
     except requests.exceptions.RequestException:
         logger.exception('RequestException: Connection problem')
     except Exception, e:
         logger.exception('Outlook EventException: {}'.format(e))
Ejemplo n.º 2
0
 def _sendEventRequest(self, key, eventType, avatar, conference):
     try:
         logger = self.getLogger()
         plugin = PluginsHolder().getPluginType('calendaring').getPlugin('outlook')
         if not isUserPluginEnabled(avatar.getId()):
             logger.info("outlook plugin disabled for user: %s" % avatar.getId())
             return 200
         if eventType in ['added', 'updated']:
             logger.debug("performing '%s' for: %s" % (eventType, avatar.getId()))
             url = urlHandlers.UHConferenceDisplay.getURL(conference)
             payload = {'userEmail': avatar.getEmail(),
                        'uniqueID': plugin.getOption('prefix').getValue() + key,
                        'subject': conference.getTitle(),
                        'location': conference.getRoom().getName() if conference.getRoom() else '',
                        'body': '<a href="%s">%s</a>' % (url, url) + '<br><br>' + conference.getDescription(),
                        'status': plugin.getOption('status').getValue(),
                        'startDate': format_datetime(conference.getStartDate(), format=plugin.getOption('datetimeFormat').getValue()),
                        'endDate': format_datetime(conference.getEndDate(), format=plugin.getOption('datetimeFormat').getValue()),
                        'isThereReminder': plugin.getOption('reminder').getValue(),
                        'reminderTimeInMinutes': plugin.getOption('reminder_minutes').getValue(),
                        }
             operation = plugin.getOption('addToCalendarOperationName').getValue() if eventType == 'added' else plugin.getOption('updateCalendarOperationName').getValue()
         elif eventType == 'removed':
             logger.debug("removing calendar entry for: %s" % avatar.getId())
             payload = {'userEmail': avatar.getEmail(),
                        'uniqueID': plugin.getOption('prefix').getValue() + key,
                        }
             operation = plugin.getOption('removeFromCalendarOperationName').getValue()
         else:
             return None
         headers = {'content-type': 'application/x-www-form-urlencoded'}
         r = requests.post(urlpath.tslash(plugin.getOption('url').getValue()) + operation,
                           auth=(plugin.getOption('login').getValue(), plugin.getOption('password').getValue()),
                           data=payload, headers=headers, timeout=plugin.getOption('timeout').getValue())
         return r.status_code
     except requests.exceptions.Timeout:
         logger.exception('Timeout')
     except requests.exceptions.RequestException:
         logger.exception('RequestException: Connection problem')
     except Exception, e:
         logger.exception('Outlook EventException: %s' % e)
Ejemplo n.º 3
0
Archivo: pages.py Proyecto: Ictp/indico
 def userPreferences(self, obj, userId):
     vars = {}
     vars['userId'] = userId
     vars['outlookPluginEnabled'] = isUserPluginEnabled(userId)
     return WPluginUserPreferences.forModule(calendaring).getHTML(vars)
Ejemplo n.º 4
0
 def userPreferences(self, obj, userId):
     vars = {}
     vars['userId'] = userId
     vars['outlookPluginEnabled'] = isUserPluginEnabled(userId)
     return WPluginUserPreferences.forModule(calendaring).getHTML(vars)