Skip to content

Commit

Permalink
presentation site link in backend #2096
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Nov 27, 2023
1 parent 6df54be commit 402ee5a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/database_versions.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 2 additions & 0 deletions install/3_data_web.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''),
Expand Down
14 changes: 14 additions & 0 deletions install/upgrade/7.18.0.sql
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions install/upgrade/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions openatlas/display/base_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 9 additions & 1 deletion openatlas/forms/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))
Expand Down
3 changes: 3 additions & 0 deletions openatlas/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
<div>
{{ g.settings.site_name }}
<a href="{{ url_for('index_changelog') }}">{{ config.VERSION }}</a>
{% if g.settings.frontend_website_url %}
- {{ _('frontend')|link(g.settings.frontend_website_url, external=True)|safe }}
{% endif %}
</div>
</nav>
{% with messages = get_flashed_messages(with_categories=true) %}
Expand Down
10 changes: 9 additions & 1 deletion openatlas/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 402ee5a

Please sign in to comment.