def update(self, event_id, service_id, data):
        data = self.validate(data, event_id, check_required=False)
        data_copy = data.copy()
        data_copy = self.fix_payload_post(event_id, data_copy)
        data = self._delete_fields(data)
        session = DataGetter.get_session(
            service_id)  # session before any updates are made
        obj = ServiceDAO.update(self,
                                event_id,
                                service_id,
                                data,
                                validate=False)  # session after update

        if 'state' in data:
            if data['state'] == 'pending' and session.state == 'draft':
                trigger_new_session_notifications(session.id,
                                                  event_id=event_id)

            if (data['state'] == 'accepted' and session.state != 'accepted') \
                or (data['state'] == 'rejected' and session.state != 'rejected') \
                or (data['state'] == 'confirmed' and session.state != 'confirmed'):
                trigger_session_state_change_notifications(obj,
                                                           event_id=event_id,
                                                           state=data['state'])

        if session.start_time != obj.start_time or session.end_time != obj.end_time:
            trigger_session_schedule_change_notifications(obj, event_id)

        for f in ['track', 'microlocation', 'speakers', 'session_type']:
            if f in data_copy:
                setattr(obj, f, data_copy[f])
        obj = save_db_model(obj, SessionModel.__name__, event_id)
        return obj
    def update(self, event_id, service_id, data):
        data = self.validate(data, event_id, check_required=False)
        data_copy = data.copy()
        data_copy = self.fix_payload_post(event_id, data_copy)
        data = self._delete_fields(data)
        session = DataGetter.get_session(service_id)  # session before any updates are made
        obj = ServiceDAO.update(self, event_id, service_id, data, validate=False)  # session after update

        if 'state' in data:
            if data['state'] == 'pending' and session.state == 'draft':
                trigger_new_session_notifications(session.id, event_id=event_id)

            if (data['state'] == 'accepted' and session.state != 'accepted') \
                or (data['state'] == 'rejected' and session.state != 'rejected') \
                or (data['state'] == 'confirmed' and session.state != 'confirmed'):
                trigger_session_state_change_notifications(obj, event_id=event_id, state=data['state'])

        if session.start_time != obj.start_time or session.end_time != obj.end_time:
            trigger_session_schedule_change_notifications(obj, event_id)

        for f in ['track', 'microlocation', 'speakers', 'session_type']:
            if f in data_copy:
                setattr(obj, f, data_copy[f])
        obj = save_db_model(obj, SessionModel.__name__, event_id)
        return obj
Ejemplo n.º 3
0
 def validate(self, data, event_id, check_required=True):
     form = DataGetter.get_custom_form_elements(event_id)
     model = None
     if form:
         model = model_custom_form(form.session_form, self.post_api_model)
     return ServiceDAO.validate(
         self, data, model=model, check_required=check_required)
Ejemplo n.º 4
0
 def update(self, event_id, service_id, data):
     data = self.validate(data, event_id, False)
     return ServiceDAO.update(self,
                              event_id,
                              service_id,
                              data,
                              validate=False)
 def validate(self, data, event_id, check_required=True):
     form = DataGetter.get_custom_form_elements(event_id)
     model = None
     if form:
         model = model_custom_form(form.session_form, self.post_api_model)
     return ServiceDAO.validate(
         self, data, model=model, check_required=check_required)
Ejemplo n.º 6
0
 def create(self, event_id, data, url):
     data = self.validate(data, event_id)
     payload = self.fix_payload_post(event_id, data)
     speakers = payload.pop('speakers', None)
     session, status_code, location = ServiceDAO.create(self, event_id, payload, url, validate=False)
     if speakers:
         session.speakers = speakers
         save_to_db(session)
     if not self.is_importing and session.state == 'pending':
         trigger_new_session_notifications(session.id, event_id=event_id)
     return session, status_code, location
 def create(self, event_id, data, url):
     data = self.validate(data, event_id)
     payload = self.fix_payload_post(event_id, data)
     speakers = payload.pop('speakers', None)
     session, status_code, location = ServiceDAO.create(self, event_id, payload, url, validate=False)
     if speakers:
         session.speakers = speakers
         save_to_db(session)
     if not self.is_importing and session.state == 'pending':
         trigger_new_session_notifications(session.id, event_id=event_id)
     return session, status_code, location
Ejemplo n.º 8
0
 def create(self, event_id, data, url):
     data = self.validate(data, event_id)
     return ServiceDAO.create(self, event_id, data, url, validate=False)
Ejemplo n.º 9
0
 def update(self, event_id, service_id, data):
     data = self.validate(data, event_id, False)
     return ServiceDAO.update(self, event_id, service_id, data, validate=False)
Ejemplo n.º 10
0
 def create(self, event_id, data, url):
     data = self.validate(data, event_id)
     return ServiceDAO.create(self, event_id, data, url, validate=False)