From 5a0304242baa110a4e2960384ae71355051e22ab Mon Sep 17 00:00:00 2001 From: michigg Date: Sat, 28 Oct 2017 23:26:43 +0200 Subject: [PATCH 1/5] add simple user management --- ofu_app/ofu_app/settings.py | 4 ++- ofu_app/ofu_app/urls.py | 4 +++ ofu_app/templates/base.jinja | 8 +++-- ofu_app/templates/registration/login.jinja | 31 ++++++++++++++++++++ ofu_app/templates/registration/sign_up.jinja | 0 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 ofu_app/templates/registration/login.jinja create mode 100644 ofu_app/templates/registration/sign_up.jinja diff --git a/ofu_app/ofu_app/settings.py b/ofu_app/ofu_app/settings.py index 0f548c2..17b7f54 100644 --- a/ofu_app/ofu_app/settings.py +++ b/ofu_app/ofu_app/settings.py @@ -58,7 +58,7 @@ REST_FRAMEWORK = { # ] ROOT_URLCONF = 'ofu_app.urls' - +TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates'), TEMPLATES = [ { 'BACKEND': 'django_jinja.backend.Jinja2', @@ -160,3 +160,5 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Media files should be stored here MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_URL = '/media/' + +LOGIN_REDIRECT_URL = 'home' diff --git a/ofu_app/ofu_app/urls.py b/ofu_app/ofu_app/urls.py index d26dcc4..79b9c4c 100644 --- a/ofu_app/ofu_app/urls.py +++ b/ofu_app/ofu_app/urls.py @@ -15,10 +15,14 @@ Including another URLconf """ from django.conf.urls import url, include from django.contrib import admin +from django.contrib.auth import views as auth_views from ofu_app import views urlpatterns = [ + url(r'^login/$', auth_views.login, {'template_name': 'registration/login.jinja'}, name='login'), + url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'), url(r'^admin/', admin.site.urls), + # url(r'^signup/$', core_views.signup, name='signup'), url(r'^$', views.home, name="home"), # -- Apps -- diff --git a/ofu_app/templates/base.jinja b/ofu_app/templates/base.jinja index 21c1944..e4d8545 100644 --- a/ofu_app/templates/base.jinja +++ b/ofu_app/templates/base.jinja @@ -22,8 +22,12 @@ {% block body %}
-
- +
+ {% if request.user.is_authenticated() %} + + {% else %} + + {% endif %}
{% block headline %}{% endblock %}
diff --git a/ofu_app/templates/registration/login.jinja b/ofu_app/templates/registration/login.jinja new file mode 100644 index 0000000..3957bc9 --- /dev/null +++ b/ofu_app/templates/registration/login.jinja @@ -0,0 +1,31 @@ +{% extends 'base.jinja' %} + +{% block headline %}

BaStA Login

{% endblock %} + +{% block content %} +
+
+

Login

+
+ {% csrf_token %} + {% if form.errors %} +
+
+ Your username and password didn't match. Please try again. +
+
+ {% endif %} + +

+ +

+ +

+ +

+ + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/ofu_app/templates/registration/sign_up.jinja b/ofu_app/templates/registration/sign_up.jinja new file mode 100644 index 0000000..e69de29 From 6ca65366d7170413f1dd393aad3a4f5c27e4f8a8 Mon Sep 17 00:00:00 2001 From: michigg Date: Sun, 29 Oct 2017 00:21:08 +0200 Subject: [PATCH 2/5] little layout fixing --- ofu_app/static/css/nav.css | 5 -- ofu_app/templates/base.jinja | 77 +++++++++++----------- ofu_app/templates/food/daily_food.jinja | 2 +- ofu_app/templates/food/food_wrapper.jinja | 2 +- ofu_app/templates/food/weekly_food.jinja | 2 +- ofu_app/templates/home.jinja | 6 +- ofu_app/templates/macros/food_macros.jinja | 2 +- ofu_app/templates/registration/login.jinja | 44 ++++++------- 8 files changed, 67 insertions(+), 73 deletions(-) diff --git a/ofu_app/static/css/nav.css b/ofu_app/static/css/nav.css index fb14fd1..5c19023 100644 --- a/ofu_app/static/css/nav.css +++ b/ofu_app/static/css/nav.css @@ -55,12 +55,7 @@ #menu-button { text-align: center; - margin-top: 12px;; height: 100%; } -#menu-button i { - -} - diff --git a/ofu_app/templates/base.jinja b/ofu_app/templates/base.jinja index e4d8545..614cdb6 100644 --- a/ofu_app/templates/base.jinja +++ b/ofu_app/templates/base.jinja @@ -21,55 +21,56 @@ {% block body %} -
-
- {% if request.user.is_authenticated() %} - - {% else %} - - {% endif %} -
-
- {% block headline %}{% endblock %}
-
-