@frontend.route('/objects/<int:object_id>/publications/', methods=['POST'])
@object_permissions_required(Permissions.WRITE)
def post_object_publication(object_id):
    check_current_user_is_not_readonly()
    publication_form = ObjectPublicationForm()
    if publication_form.validate_on_submit():
        doi = publication_form.doi.data
        title = publication_form.title.data
        object_name = publication_form.object_name.data
        if (title is not None):
            title = title.strip()
        if (not title):
            title = None
        if (object_name is not None):
            object_name = object_name.strip()
        if (not object_name):
            object_name = None
        existing_publication = ([publication for publication in logic.publications.get_publications_for_object(object_id) if (publication.doi == doi)] or [None])[0]
        if ((existing_publication is not None) and (existing_publication.title == title) and (existing_publication.object_name == object_name)):
            flask.flash(_('This object has already been linked to this publication.'), 'info')
        else:
            logic.publications.link_publication_to_object(user_id=flask_login.current_user.id, object_id=object_id, doi=doi, title=title, object_name=object_name)
            if (existing_publication is None):
                flask.flash(_('Successfully linked this object to a publication.'), 'success')
            else:
                flask.flash(_('Successfully updated the information for this publication.'), 'success')
    else:
        flask.flash(_('Please enter a valid DOI for the publication you want to link this object to.'), 'error')
    return flask.redirect(flask.url_for('.object', object_id=object_id))
@frontend.route('/objects/<int:object_id>/publications/', methods=['POST'])
@object_permissions_required(Permissions.WRITE)
def post_object_publication(object_id):
    check_current_user_is_not_readonly()
    publication_form = ObjectPublicationForm()
    if publication_form.validate_on_submit():
        doi = publication_form.doi.data
        title = publication_form.title.data
        object_name = publication_form.object_name.data
        if (title is not None):
            title = title.strip()
        if (not title):
            title = None
        if (object_name is not None):
            object_name = object_name.strip()
        if (not object_name):
            object_name = None
        existing_publication = ([publication for publication in logic.publications.get_publications_for_object(object_id) if (publication.doi == doi)] or [None])[0]
        if ((existing_publication is not None) and (existing_publication.title == title) and (existing_publication.object_name == object_name)):
            flask.flash(_('This object has already been linked to this publication.'), 'info')
        else:
            logic.publications.link_publication_to_object(user_id=flask_login.current_user.id, object_id=object_id, doi=doi, title=title, object_name=object_name)
            if (existing_publication is None):
                flask.flash(_('Successfully linked this object to a publication.'), 'success')
            else:
                flask.flash(_('Successfully updated the information for this publication.'), 'success')
    else:
        flask.flash(_('Please enter a valid DOI for the publication you want to link this object to.'), 'error')
    return flask.redirect(flask.url_for('.object', object_id=object_id))