Commit 7edb4672 by Damien Moulard

add comments to explain routing system

parent 9bc66657
Pipeline #1462 passed with stage
in 1 minute 28 seconds
...@@ -68,6 +68,10 @@ function goto(page) { ...@@ -68,6 +68,10 @@ function goto(page) {
/** /**
* Define which html content to load from server depending on the window location * Define which html content to load from server depending on the window location
*
* WARNING: For the routing system to work,
* public urls (those the users will see & navigate to) must be different than the server urls used to fetch resources
* (ex: public url: /members_space/mes-info ; server url: /members_space/my_info)
*/ */
function update_dom() { function update_dom() {
$(".nav_item").removeClass('active'); $(".nav_item").removeClass('active');
......
...@@ -5,11 +5,11 @@ from . import views ...@@ -5,11 +5,11 @@ from . import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.index), url(r'^$', views.index),
url(r'^homepage$', views.home), url(r'^homepage$', views.home), # These endpoints must be different than in-app url
url(r'^my_info$', views.my_info), url(r'^my_info$', views.my_info),
url(r'^my_shifts$', views.my_shifts), url(r'^my_shifts$', views.my_shifts),
url(r'^shifts_exchange$', views.shifts_exchange), url(r'^shifts_exchange$', views.shifts_exchange),
url(r'^no_content$', views.no_content), url(r'^no_content$', views.no_content),
url(r'^get_shifts_history$', views.get_shifts_history), url(r'^get_shifts_history$', views.get_shifts_history),
url('/*$', views.index), url('/*$', views.index), # Urls unknown from the server will redirect to index
] ]
...@@ -138,6 +138,12 @@ def index(request, exception=None): ...@@ -138,6 +138,12 @@ def index(request, exception=None):
return _get_response_according_to_credentials(request, credentials, context, template) return _get_response_according_to_credentials(request, credentials, context, template)
def home(request): def home(request):
"""
Endpoint the front-end will call to load the "home" page.
Consequently, the front-end url should be unknown from the server so the user is redirected to the index,
then the front-end index will call this endpoint to load the home page
"""
template = loader.get_template('members_space/home.html') template = loader.get_template('members_space/home.html')
context = { context = {
'title': 'Espace Membres', 'title': 'Espace Membres',
...@@ -151,6 +157,7 @@ def home(request): ...@@ -151,6 +157,7 @@ def home(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def my_info(request): def my_info(request):
""" Endpoint the front-end will call to load the "My info" page. """
template = loader.get_template('members_space/my_info.html') template = loader.get_template('members_space/my_info.html')
context = { context = {
'title': 'Mes Infos', 'title': 'Mes Infos',
...@@ -158,6 +165,7 @@ def my_info(request): ...@@ -158,6 +165,7 @@ def my_info(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def my_shifts(request): def my_shifts(request):
""" Endpoint the front-end will call to load the "My shifts" page. """
template = loader.get_template('members_space/my_shifts.html') template = loader.get_template('members_space/my_shifts.html')
context = { context = {
'title': 'Mes Services', 'title': 'Mes Services',
...@@ -165,6 +173,7 @@ def my_shifts(request): ...@@ -165,6 +173,7 @@ def my_shifts(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def shifts_exchange(request): def shifts_exchange(request):
""" Endpoint the front-end will call to load the "Shifts exchange" page. """
template = loader.get_template('members_space/shifts_exchange.html') template = loader.get_template('members_space/shifts_exchange.html')
context = { context = {
'title': 'Échange de Services', 'title': 'Échange de Services',
...@@ -172,6 +181,7 @@ def shifts_exchange(request): ...@@ -172,6 +181,7 @@ def shifts_exchange(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def no_content(request): def no_content(request):
""" Endpoint the front-end will call to load the "No content" page. """
template = loader.get_template('members_space/no_content.html') template = loader.get_template('members_space/no_content.html')
context = { context = {
'title': 'Contenu non trouvé', 'title': 'Contenu non trouvé',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment