Skip to content

Commit

Permalink
WQ_BASE_URL config to facilitate use in build
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Dec 2, 2020
1 parent 8087ade commit adb07be
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion rest/context_processors.py
Expand Up @@ -11,7 +11,11 @@ def version(request):


def get_base_url():
return reverse('wq:config-list').replace('/config/', '')
base_url = reverse('wq:config-list').replace('/config/', '')
if base_url != router.get_base_url():
# FIXME: raise ImproperlyConfigured in 2.0?
pass
return base_url


def get_wq_path(request):
Expand Down
7 changes: 5 additions & 2 deletions rest/renderers.py
Expand Up @@ -15,7 +15,7 @@ def load_app_template(template_name):
'<title>{{title}}</title>',
template
)
if '{{title}}' in template:
if '{{' in template:
return template, True
else:
return template, False
Expand All @@ -35,7 +35,10 @@ def render_app(template_name, data, request):

template, has_title = APP_TEMPLATES[template_name]
if has_title:
return template.replace('{{title}}', get_title(data, request))
from wq.db.rest import router
return (template
.replace('{{title}}', get_title(data, request))
.replace('{{base_url}}', router.get_base_url()))
else:
return template

Expand Down
13 changes: 12 additions & 1 deletion rest/routers.py
Expand Up @@ -279,6 +279,9 @@ class ViewSet(viewset):

return ViewSet

def get_base_url(self):
return getattr(settings, 'WQ_BASE_URL', '')

_base_config = None

@property
Expand Down Expand Up @@ -318,7 +321,15 @@ def base_config(self):

pages[info['name']] = info

self._base_config = {'pages': pages}
base_url = self.get_base_url()
self._base_config = {
'pages': pages,
'router': {'base_url': base_url},
'store': {
'service': base_url,
'defaults': {'format': 'json'},
},
}
if settings.DEBUG:
self._base_config['debug'] = True
self._base_config.update(self._extra_config)
Expand Down

0 comments on commit adb07be

Please sign in to comment.