Added basic authentication support using django.contrib.auth and requiring login using the django.contrib.auth.decorators.login_required decorator.
This commit is contained in:
parent
fe1273813c
commit
ff40cf8edb
|
|
@ -0,0 +1,6 @@
|
|||
<h2>Login</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<h2>Register</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
|
|
@ -14,6 +14,7 @@ from .models import *
|
|||
from .forms import *
|
||||
import json
|
||||
from datetime import datetime
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
def get_timetable(r, trips, stop_sequences):
|
||||
"""
|
||||
|
|
@ -48,7 +49,7 @@ def get_timetable(r, trips, stop_sequences):
|
|||
timetable["stop_times"] = sts
|
||||
return timetable
|
||||
|
||||
|
||||
@login_required
|
||||
def index(request):
|
||||
stops = {s.stop_id: {name: getattr(s, name) for name in ['stop_name', 'stop_lat', 'stop_lon']} for s in Stop.objects.all()}
|
||||
route_name = lambda r : r.route_short_name if r.route_short_name else r.route_long_name
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
"""
|
||||
URL configuration for transport_accessibility project.
|
||||
"""
|
||||
from django.contrib import auth as auth
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include("pt_map.urls"))
|
||||
path('', include("pt_map.urls")),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user