def service_handle_new_editable(editable, user): revision = editable.revisions[-1] data = { 'editable': EditableBasicSchema().dump(editable), 'revision': EditingRevisionSignedSchema().dump(revision), 'endpoints': _get_revision_endpoints(revision), 'user': ServiceUserSchema(context={'editable': editable}).dump(user), } try: path = '/event/{}/editable/{}/{}'.format( _get_event_identifier(editable.event), editable.type.name, editable.contribution_id, ) resp = requests.put(_build_url(editable.event, path), headers=_get_headers(editable.event), json=data) resp.raise_for_status() except requests.RequestException as exc: _log_service_error(exc, 'Calling listener for new editable failed') raise ServiceRequestFailed(exc)
def _process(self): editables = [e for e in self.editables if e.editor != session.user] for editable in editables: assign_editor(editable, session.user) return EditableBasicSchema(many=True).jsonify(editables)
def _process(self): editables = [e for e in self.editables if e.editor] for editable in editables: unassign_editor(editable) return EditableBasicSchema(many=True).jsonify(editables)