diff --git a/config/database_versions.py b/config/database_versions.py index a2be5a3bb..295112789 100644 --- a/config/database_versions.py +++ b/config/database_versions.py @@ -1,5 +1,6 @@ # Used for automatic database upgrades and database version checks DATABASE_VERSIONS = [ + '7.18.0', '7.17.0', '7.16.0', '7.15.0', diff --git a/install/3_data_web.sql b/install/3_data_web.sql index b2573a0d9..2976fa818 100644 --- a/install/3_data_web.sql +++ b/install/3_data_web.sql @@ -23,6 +23,8 @@ INSERT INTO web.settings (name, value) VALUES ('failed_login_tries', '3'), ('file_upload_max_size', '10'), ('file_upload_allowed_extension', 'gif jpeg jpg pdf png txt zip'), + ('frontend_website_url', ''), + ('frontend_resolver_url', ''), ('geonames_username', 'openatlas'), ('iiif', ''), ('iiif_path', ''), diff --git a/install/upgrade/7.18.0.sql b/install/upgrade/7.18.0.sql new file mode 100644 index 000000000..ec96c185b --- /dev/null +++ b/install/upgrade/7.18.0.sql @@ -0,0 +1,14 @@ +-- Upgrade 7.17.x to 7.18.0 +-- Be sure to backup the database and read the upgrade notes before executing. + +BEGIN; + +-- Raise database version +UPDATE web.settings SET value = '7.18.0' WHERE name = 'database_version'; + +-- #2096: Add presentation site link in backend +INSERT INTO web.settings (name, value) VALUES + ('frontend_website_url', ''), + ('frontend_resolver_url', ''); + +END; diff --git a/install/upgrade/upgrade.md b/install/upgrade/upgrade.md index 98b6de546..b62f8cf3f 100644 --- a/install/upgrade/upgrade.md +++ b/install/upgrade/upgrade.md @@ -18,8 +18,8 @@ then run the database upgrade script, then restart Apache: sudo python3 install/upgrade/database_upgrade.py sudo service apache2 restart -### 7.17.x to 7.17.4 -A code base update (e.g. with git pull) and a webserver restart is sufficient. +### 7.17.x to 7.18 +7.18.0.sql is needed but will be taken care of by the database upgrade script. ### 7.16.x to 7.17.0 7.17.0.sql is needed but will be taken care of by the database upgrade script. diff --git a/openatlas/display/base_display.py b/openatlas/display/base_display.py index fd831d857..33413b1b5 100644 --- a/openatlas/display/base_display.py +++ b/openatlas/display/base_display.py @@ -130,10 +130,19 @@ def add_buttons(self) -> None: self.add_button_network() self.buttons.append( render_template('util/api_links.html', entity=self.entity)) + self.add_button_frontend() self.add_button_others() if self.structure and len(self.structure['siblings']) > 1: self.add_button_sibling_pager() + def add_button_frontend(self) -> None: + if url := g.settings['frontend_resolver_url']: + self.buttons.append( + link( + _('view in frontend'), + url + str(self.entity.id), + external=True)) + def add_button_copy(self) -> None: self.buttons.append( button( diff --git a/openatlas/forms/setting.py b/openatlas/forms/setting.py index 412f7a797..66c63f755 100644 --- a/openatlas/forms/setting.py +++ b/openatlas/forms/setting.py @@ -2,7 +2,7 @@ from flask_wtf import FlaskForm from wtforms import ( BooleanField, IntegerField, SelectField, StringField, FieldList) -from wtforms.validators import Email, InputRequired +from wtforms.validators import Email, InputRequired, Optional, URL from openatlas import app from openatlas.forms.field import SubmitField, RemovableListField @@ -97,6 +97,14 @@ class MapForm(FlaskForm): save = SubmitField(_('save')) +class FrontendForm(FlaskForm): + frontend_website_url = ( + StringField(_('website URL'), [Optional(), URL()])) + frontend_resolver_url = ( + StringField(_('resolver URL'), [Optional(), URL()])) + save = SubmitField(_('save')) + + class ApiForm(FlaskForm): api_public = BooleanField('public') save = SubmitField(_('save')) diff --git a/openatlas/templates/layout.html b/openatlas/templates/layout.html index d8a534558..8112e68fd 100644 --- a/openatlas/templates/layout.html +++ b/openatlas/templates/layout.html @@ -175,6 +175,9 @@
{{ g.settings.site_name }} {{ config.VERSION }} + {% if g.settings.frontend_website_url %} + - {{ _('frontend')|link(g.settings.frontend_website_url, external=True)|safe }} + {% endif %}
{% with messages = get_flashed_messages(with_categories=true) %} diff --git a/openatlas/views/admin.py b/openatlas/views/admin.py index 2562ce60c..714d6afb7 100644 --- a/openatlas/views/admin.py +++ b/openatlas/views/admin.py @@ -30,7 +30,7 @@ from openatlas.forms.field import SubmitField from openatlas.forms.setting import ( ApiForm, ContentForm, FilesForm, GeneralForm, LogForm, MailForm, MapForm, - ModulesForm, SimilarForm, TestMailForm, IiifForm) + ModulesForm, SimilarForm, TestMailForm, IiifForm, FrontendForm) from openatlas.forms.util import get_form_settings, set_form_settings from openatlas.models.content import get_content, update_content from openatlas.models.entity import Entity @@ -185,6 +185,14 @@ def admin_index( 'content', tables['content'].display(), buttons=[manual('admin/content')]) + tabs['frontend'] = Tab( + 'frontend', + display_info(get_form_settings(FrontendForm())), + buttons=[ + manual('admin/map'), + button( + _('edit'), + url_for('admin_settings', category='frontend'))]) if is_authorized('contributor'): tabs['data'] = Tab( 'data',