Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ris base url to config endpoint #7937

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/TI-71.other
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ris_base_url to config endpoint. [jch]
7 changes: 7 additions & 0 deletions docs/public/dev-manual/api/api_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
API Changelog
=============

2024.8.0 (unreleased)
---------------------

Other Changes
^^^^^^^^^^^^^
- Add ris_base_url to config endpoint.

2024.7.0 (2024-04-23)
---------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/public/dev-manual/api/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ GEVER-Mandanten abgefragt werden.
"portal_url": "https://dev.onegovgever.ch/portal",
"private_folder_url": "http://localhost:8080/fd/private/john.doe",
"recently_touched_limit": 10,
"ris_base_url": "http://localhost:3000",
"root_url": "http://localhost:8080/fd",
"sharing_configuration": {
"black_list_prefix": "^$",
Expand Down Expand Up @@ -158,6 +159,10 @@ bumblebee_notifications_url

Websocket URL, um Änderungen über Vorschaubilder zu erhalten

ris_base_url

RIS Base URL, für die Navigation ins RIS um Anträge zu erstellen

features
Optional aktivierbare Features:

Expand Down
11 changes: 11 additions & 0 deletions opengever/api/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from opengever.base.model import create_session
from opengever.ogds.base.utils import get_current_admin_unit
from opengever.private import enable_opengever_private
from opengever.ris.interfaces import IRisSettings
from opengever.testing import IntegrationTestCase
from opengever.testing.readonly import ZODBStorageInReadonlyMode
from pkg_resources import get_distribution
Expand Down Expand Up @@ -130,6 +131,16 @@ def test_config_contains_recently_touched_limit(self, browser):
self.assertEqual(browser.status_code, 200)
self.assertEqual(browser.json.get(u'recently_touched_limit'), 10)

@browsing
def test_config_contains_ris_base_url(self, browser):
api.portal.set_registry_record('base_url', u'http://localhost:3000', IRisSettings)

self.login(self.regular_user, browser)

browser.open(self.config_url, headers=self.api_headers)
self.assertEqual(browser.status_code, 200)
self.assertEqual(browser.json.get(u'ris_base_url'), u'http://localhost:3000')

@browsing
def test_config_contains_cas_url(self, browser):
# Install CAS plugin
Expand Down
8 changes: 8 additions & 0 deletions opengever/base/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from opengever.oneoffixx.interfaces import IOneoffixxSettings
from opengever.readonly import is_in_readonly_mode
from opengever.repository.interfaces import IRepositoryFolderRecords
from opengever.ris.interfaces import IRisSettings
from opengever.sharing.interfaces import ISharingConfiguration
from opengever.task.interfaces import ITaskSettings
from opengever.tasktemplates.interfaces import ITaskTemplateSettings
Expand Down Expand Up @@ -78,6 +79,7 @@ def get_config(self):
config['apps_url'] = os.environ.get('APPS_ENDPOINT_URL')
config['application_type'] = self.get_application_type()
config['bumblebee_notifications_url'] = bumblebee.get_service_v3().get_notifications_url()
config['ris_base_url'] = self.get_ris_base_url()
config['is_readonly'] = is_in_readonly_mode()
return config

Expand All @@ -99,6 +101,12 @@ def get_application_type(self):
return 'teamraum'
return 'gever'

def get_ris_base_url(self):
ris_base_url = api.portal.get_registry_record(name='base_url', interface=IRisSettings)
if ris_base_url:
return ris_base_url.rstrip("/")
return ''

def get_user_settings(self):
setting = UserSettings.query.filter_by(userid=api.user.get_current().id).one_or_none()
return serialize_setting(setting)
Expand Down
5 changes: 5 additions & 0 deletions opengever/base/tests/test_configuration_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from contextlib import contextmanager
from opengever.base.interfaces import IGeverSettings
from opengever.kub.interfaces import IKuBSettings
from opengever.ris.interfaces import IRisSettings
from opengever.testing import IntegrationTestCase
from pkg_resources import get_distribution
from plone import api
Expand All @@ -13,6 +14,7 @@ class TestConfigurationAdapter(IntegrationTestCase):
def setUp(self):
super(TestConfigurationAdapter, self).setUp()
os.environ['BUMBLEBEE_PUBLIC_URL'] = 'http://bumblebee.local/'
api.portal.set_registry_record('base_url', u'http://localhost:3000', IRisSettings)

def test_configuration(self):
expected_configuration = OrderedDict([
Expand Down Expand Up @@ -116,6 +118,7 @@ def test_configuration(self):
('apps_url', None),
('application_type', 'gever'),
('bumblebee_notifications_url', 'http://bumblebee.local/YnVtYmxlYmVl/api/notifications'),
('ris_base_url', 'http://localhost:3000'),
('is_readonly', False),
])

Expand All @@ -135,6 +138,7 @@ def test_configuration_for_anonymous(self):
('apps_url', None),
('application_type', 'gever'),
('bumblebee_notifications_url', 'http://bumblebee.local/YnVtYmxlYmVl/api/notifications'),
('ris_base_url', 'http://localhost:3000'),
('is_readonly', False),
])
configuration = IGeverSettings(self.portal).get_config()
Expand Down Expand Up @@ -172,6 +176,7 @@ def custom_apps_url(url):
('apps_url', 'http://example.com/api/apps'),
('application_type', 'gever'),
('bumblebee_notifications_url', 'http://bumblebee.local/YnVtYmxlYmVl/api/notifications'),
('ris_base_url', 'http://localhost:3000'),
('is_readonly', False),
])

Expand Down