예제 #1
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)
예제 #2
0
def test_send_seminar_confirmation_email(mock_send_email, base_app, db,
                                         es_clear):
    expected_recipient = "*****@*****.**"
    seminar = {"control_number": "1234"}
    expected_subject = "Your seminar (1234) has been successfully submitted!"
    host = get_inspirehep_url()
    expected_content = render_template(
        "mailing/seminars/confirmation_new.html",
        seminar_url=f"{host}/seminars/1234",
        seminar_edit_url=f"{host}/submissions/seminars/1234",
    )
    send_seminar_confirmation_email(expected_recipient, seminar)
    mock_send_email.assert_called_once_with(
        sender=current_app.config["SEMINARS_CONFIRMATION_EMAIL_ADDRESS"],
        recipient=expected_recipient,
        subject=expected_subject,
        body=expected_content,
    )