예제 #1
0
 def _process(self, url):
     if editing_settings.get(self.event, 'service_url'):
         raise BadRequest('Service URL already set')
     url = url.rstrip('/')
     info = check_service_url(url)
     if info['error'] is not None:
         abort(422, messages={'url': [info['error']]})
     if not editing_settings.get(self.event, 'service_event_identifier'):
         editing_settings.set(self.event, 'service_event_identifier',
                              make_event_identifier(self.event))
     editing_settings.set_multi(self.event, {
         'service_url': url,
         'service_token': unicode(uuid4()),
     })
     # we need to commit the token so the service can already use it when processing
     # the enabled event in case it wants to set up tags etc
     db.session.commit()
     try:
         service_handle_enabled(self.event)
     except ServiceRequestFailed as exc:
         editing_settings.delete(self.event, 'service_url', 'service_token')
         db.session.commit()
         raise ServiceUnavailable(
             _('Could not register event with service: {}').format(exc))
     except Exception:
         editing_settings.delete(self.event, 'service_url', 'service_token')
         db.session.commit()
         raise
     return '', 204
예제 #2
0
 def _process(self, url):
     url = url.rstrip('/')
     return jsonify(check_service_url(url))