def get(self, pid_value): try: record = SeminarsRecord.get_record_by_pid_value(pid_value) except PIDDoesNotExistError: abort(404) serialized_record = seminar_serializer_v1.dump(record) return jsonify({"data": serialized_record})
def post(self): """Adds new conference record""" data = self.load_data_from_request() data["acquisition_source"] = self.get_acquisition_source() record = SeminarsRecord.create(data) db.session.commit() if not is_superuser_or_cataloger_logged_in(): self.create_ticket(record, "rt/new_seminar.html") send_seminar_confirmation_email(current_user.email, record) return (jsonify({"pid_value": record["control_number"]}), 201)
def test_indexer_deletes_record_from_es(inspire_app, datadir): def assert_record_is_deleted_from_es(): current_search.flush_and_refresh("records-seminars") expected_records_count = 0 record_lit_es = SeminarsSearch().get_record(str( record.id)).execute().hits assert expected_records_count == len(record_lit_es) data = orjson.loads((datadir / "1.json").read_text()) record = SeminarsRecord.create(data) db.session.commit() record.delete() db.session.commit() retry_until_pass(assert_record_is_deleted_from_es)
def put(self, pid_value): try: record = SeminarsRecord.get_record_by_pid_value(pid_value) if not can_user_edit_record(record): return ( jsonify({"message": "You are not allowed to edit this seminar"}), 403, ) except PIDDoesNotExistError: abort(404) data = self.load_data_from_request() updated_record_data = self.get_updated_record_data(data, record) record.update(updated_record_data) db.session.commit() if not is_superuser_or_cataloger_logged_in(): self.create_ticket(record, "rt/update_seminar.html") return jsonify({"pid_value": record["control_number"]})