Skip to content

Commit

Permalink
Allow configuring qwc config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Aug 1, 2024
1 parent 4df20cd commit 1582c7d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ requests==2.32.0
SQLAlchemy==2.0.29
Werkzeug==3.0.3
email_validator==2.1.0.post1
qwc-services-core==1.3.29
qwc-services-core==1.3.30
python-i18n==0.3.9
deepmerge==1.1.0
4 changes: 4 additions & 0 deletions schemas/qwc-admin-gui.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"description": "DB connection URL",
"type": "string"
},
"qwc_config_schema": {
"description": "The name of the DB schema which stores the qwc config. Default: qwc_config",
"type": "string"
},
"config_generator_service_url": {
"description": "Config generator URL",
"type": "string"
Expand Down
5 changes: 4 additions & 1 deletion src/access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def __init__(self, handler, logger):

def is_admin(self, identity):
db_engine = self.handler().db_engine()
self.config_models = ConfigModels(db_engine, self.handler().conn_str())
self.config_models = ConfigModels(
db_engine, self.handler().conn_str(),
qwc_config_schema=self.handler().qwc_config_schema()
)

# Extract user infos from identity
if isinstance(identity, dict):
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def setup_models(self):
self.config = config_handler.config()

db_engine = config_handler.db_engine()
self.config_models = ConfigModels(db_engine, config_handler.conn_str())
self.config_models = ConfigModels(
db_engine, config_handler.conn_str(),
qwc_config_schema=config_handler.qwc_config_schema()
)

self.Group = self.config_models.model('groups')
self.Permission = self.config_models.model('permissions')
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/alkis/controllers/alkis_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def __init__(self, app, handler):
self.handler = handler
config_handler = handler()
db_engine = config_handler.db_engine()
self.config_models = ConfigModels(db_engine, config_handler.conn_str(), ["alkis"])
self.config_models = ConfigModels(
db_engine, config_handler.conn_str(), ["alkis"],
qwc_config_schema=config_handler.qwc_config_schema()
)
self.resources = self.config_models.model('resources')
self.alkis = self.config_models.model('alkis')

Expand Down
5 changes: 4 additions & 1 deletion src/plugins/themes/controllers/templates_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def __init__(self, app, handler, featureInfoconfig):
self.ows_prefix = urlparse(current_handler.config().get("ows_prefix", "")).path.rstrip("/") + "/"
self.default_qgis_server_url = current_handler.config().get("default_qgis_server_url")
db_engine = current_handler.db_engine()
self.config_models = ConfigModels(db_engine, current_handler.conn_str())
self.config_models = ConfigModels(
db_engine, current_handler.conn_str(),
qwc_config_schema=current_handler.qwc_config_schema()
)
self.resources = self.config_models.model('resources')

app.add_url_rule(
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/themes/controllers/themes_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def __init__(self, app, handler, themesconfig):

config_handler = handler()
db_engine = config_handler.db_engine()
self.config_models = ConfigModels(db_engine, config_handler.conn_str())
self.config_models = ConfigModels(
db_engine, config_handler.conn_str(),
qwc_config_schema=current_handler.qwc_config_schema()
)
self.resources = self.config_models.model('resources')

def index(self):
Expand Down
3 changes: 3 additions & 0 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def conn_str(self):
return self._config.get(
'db_url', 'postgresql:///?service=qwc_configdb')

def qwc_config_schema(self):
return self._config.get('qwc_config_schema', 'qwc_config')


def handler():
tenant = tenant_handler.tenant()
Expand Down

0 comments on commit 1582c7d

Please sign in to comment.