Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Castellum
castellum
Commits
28389228
Commit
28389228
authored
Apr 12, 2018
by
Timo
Browse files
Merge branch '2018-04-tb-auth-views' into 'master'
258: auth views See merge request
!7
parents
61eb6429
7051f913
Changes
8
Hide whitespace changes
Inline
Side-by-side
castellum_core/.gitignore
View file @
28389228
dist/
*.egg-info/
node_modules/
*.pyc
*.sqlite3
castellum_core/Makefile
View file @
28389228
...
...
@@ -20,3 +20,6 @@ createsuperuser:
install
:
pip
install
tox ipdb
pip
install
-e
.
npm
install
mkdir
-p
castellum_core/static/
cp
node_modules/bootstrap/dist/css/bootstrap.min.css castellum_core/static/
castellum_core/castellum_core/castellum_core/settings/default.py
View file @
28389228
...
...
@@ -15,6 +15,7 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'bootstrap4'
,
'castellum_auth.apps.CastellumAuthConfig'
,
]
...
...
@@ -34,7 +35,9 @@ ROOT_URLCONF = 'castellum_core.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
),
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
...
...
@@ -69,6 +72,9 @@ AUTH_PASSWORD_VALIDATORS = [
AUTH_USER_MODEL
=
'castellum_auth.User'
LOGIN_REDIRECT_URL
=
'/'
LOGOUT_REDIRECT_URL
=
'/'
# Internationalization
...
...
@@ -85,4 +91,8 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'static'
),
]
STATIC_URL
=
'/static/'
castellum_core/castellum_core/castellum_core/urls.py
View file @
28389228
from
django.contrib
import
admin
from
django.urls
import
path
from
django.contrib.auth
import
views
as
auth_views
urlpatterns
=
[
path
(
'login/'
,
auth_views
.
LoginView
.
as_view
(
template_name
=
"login.html"
),
name
=
'login'
),
path
(
'logout/'
,
auth_views
.
LogoutView
.
as_view
(),
name
=
'logout'
),
path
(
'admin/'
,
admin
.
site
.
urls
),
]
castellum_core/castellum_core/templates/base.html
0 → 100644
View file @
28389228
<!DOCTYPE html>
{% load i18n static bootstrap4 %}
{% get_current_language as LANGUAGE_CODE %}
<html
lang=
"{{ LANGUAGE_CODE }}"
>
<head>
<meta
charset=
"utf-8"
/>
<title>
{% block title %}Castellum{% endblock %}
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'bootstrap.min.css' %}"
/>
<meta
name=
"viewport"
content=
"width=device-width"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"default-src 'self'"
/>
</head>
<body>
<header
class=
"bg-dark"
>
<div
class=
"container"
>
<div
class=
"row navbar navbar-dark"
>
<a
href=
"/"
rel=
"home"
class=
"navbar-brand"
>
Castellum
</a>
{% if request.user.is_authenticated %}
<div>
<span
class=
"navbar-text"
>
{{ request.user }}
</span>
<a
href=
"{% url 'logout' %}?next={{ request.get_full_path|iriencode }}"
class=
"btn btn-secondary"
>
{% trans 'Logout' %}
</a>
</div>
{% else %}
<a
href=
"{% url 'login' %}?next={{ request.get_full_path|iriencode }}"
class=
"btn btn-primary"
>
{% trans 'Login' %}
</a>
{% endif %}
</div>
</div>
</header>
<main
class=
"container pt-3"
>
<div
class=
"row justify-content-center"
>
<div
class=
"col-lg-8 col-md-10"
>
{% if messages %}
<ul
class=
"messages"
>
{% for message in messages %}
<li
class=
"alert {{ message.tags }}"
role=
"alert"
>
{{ message }}
</li>
{% endfor %}
</ul>
{% endif %}
{% block content %}{% endblock %}
</div>
</div>
</main>
</body>
</html>
castellum_core/castellum_core/templates/login.html
0 → 100644
View file @
28389228
{% extends "base.html" %}
{% load i18n bootstrap4 %}
{% block title %}{% trans "Log in" %}
·
{{ block.super }}{% endblock %}
{% block content %}
<form
method=
"post"
action=
"{% url 'login' %}"
>
{% for error in form.non_field_errors %}
<p
class=
"alert alert-danger"
role=
"alert"
>
{{ error }}
</p>
{% endfor %}
{% csrf_token %}
{% bootstrap_field form.username %}
{% bootstrap_field form.password %}
<input
type=
"submit"
class=
"btn btn-primary"
value=
"{% trans 'Login' %}"
/>
<input
type=
"hidden"
name=
"next"
value=
"{{ next }}"
/>
</form>
{% endblock %}
castellum_core/package.json
0 → 100644
View file @
28389228
{
"name"
:
"castellum-core"
,
"dependencies"
:
{
"bootstrap"
:
"^4.0.0"
}
}
castellum_core/setup.py
View file @
28389228
...
...
@@ -11,5 +11,6 @@ setup(
install_requires
=
[
"Django==2.0.4"
,
"django-bootstrap4==0.0.6"
,
],
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment