From 19719a68b9c7cd7526d569506e18d968d3caf359 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sat, 4 Feb 2017 06:20:46 +0100 Subject: [PATCH] add login function --- billard/templates/registration/login.html | 16 ++++++++++++++++ billard/urls.py | 2 +- caromserver/settings.py | 6 ++++++ caromserver/urls.py | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 billard/templates/registration/login.html diff --git a/billard/templates/registration/login.html b/billard/templates/registration/login.html new file mode 100644 index 0000000..cf71f40 --- /dev/null +++ b/billard/templates/registration/login.html @@ -0,0 +1,16 @@ +{% extends 'billard/base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Login{% endblock %} + +{% block content %} +
+ {% csrf_token %} + {{ form|crispy }} + + + +
+{% endblock %} + + diff --git a/billard/urls.py b/billard/urls.py index 77ac0c7..1c84cba 100644 --- a/billard/urls.py +++ b/billard/urls.py @@ -9,7 +9,7 @@ router.register(r'tables', views.TableViewSet) router.register(r'location_data', views.LocationDataViewSet) urlpatterns = [ - url(r'^$', views.index, name='index'), + url(r'^$', views.index, name='carom_index'), #url(r'^$', views.IndexView.as_view(), name='index'), url(r'^(?P[0-9]+)/$', views.LocationDataDetailView.as_view(), name='detail'), url(r'api/v1/', include(router.urls)), diff --git a/caromserver/settings.py b/caromserver/settings.py index 13a404b..62ac74a 100644 --- a/caromserver/settings.py +++ b/caromserver/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', + 'crispy_forms', 'billard', ] @@ -131,6 +132,11 @@ REST_FRAMEWORK = { ), } +CRISPY_TEMPLATE_PACK = 'bootstrap3' +LOGIN_URL = 'login' +LOGOUT_URL = 'logout' +LOGIN_REDIRECT_URL = 'carom_index' + STATIC_ROOT = "/srv/carom/carom-server/static/" try: diff --git a/caromserver/urls.py b/caromserver/urls.py index a8a57cd..759677d 100644 --- a/caromserver/urls.py +++ b/caromserver/urls.py @@ -21,5 +21,6 @@ urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^billard/', include('billard.urls')), + url(r'^', include('django.contrib.auth.urls')), url(r'^.*$', RedirectView.as_view(url='billard/', permanent=False), name='index') ]