Closed akorosov closed 4 years ago
Tests should be updated accordingly to check that only root url is working, not '/adas' like it is now.
It is better to add geomtery to urls here as well. To make it self sufficient.
It is actually better not to add geometry.
Django URLs to views should be defined only in the apps where the views are defined. So get_geometry_geojson is defined in geospaas.base_viewer.views, therefore the only place where a URL for it is defined is also in geospaas.base_viewer.urls.
The reason is that we also define url namespace which is used in templates. So in geospaas.base_viewer.urls we define app_name='base_viewer' and path(..., name='geometry_geojson'). Then it can be accessed from template using namespace: {% url 'base_viewer:geometry_geojson' %}
.
In the tests and web-apps, however, paths both to geospaas.base_viewer and geospaas_adas_viewer should be given. And the order plays important role! Because both geospaas.base_viewer.urls and geospaas_adas_viewer.urls have empty path ('').
In this case:
urlpatterns = [
path('', include('geospaas_adas_viewer.urls')),
path('', include('geospaas.base_viewer.urls')),
]
AdasIndexView is used on root URL (host:port/) and get_geometry_geojson will be used on host:port/geometry.
If the order is swapped, then AdasIndexView will not be used, but the IndexView will be used istead.
@aperrin66 , that is also good to remember for configuration of URLs in deployment.
This looks much cleaner indeed
If
url(r'', ...
is specififed in urls.py then any URL after / will be accepted: '/adas', '/geometry', '/css', etc. That causes problems when adas viewer is on the root url. It should bepath('',
orre_path(r'^$',
(sinceurl
is soon deprecated).