예제 #1
0
    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})
예제 #2
0
    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)
예제 #3
0
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)
예제 #4
0
    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"]})