added user management system
This commit is contained in:
parent
0b31a83f83
commit
8e855e0748
16 changed files with 446 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -102,3 +102,6 @@ venv.bak/
|
||||||
|
|
||||||
# mypy
|
# mypy
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'user_manager',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
|
|
@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'Europe/Berlin'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
|
@ -118,3 +119,8 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
LOGIN_REDIRECT_URL = '/'
|
||||||
|
LOGIN_URL = '/accounts/login'
|
||||||
|
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,7 @@ from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
|
path('', include('user_manager.urls')),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
11
invsystem/user_manager/forms.py
Normal file
11
invsystem/user_manager/forms.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.forms import CharField
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class SignUpForm(UserCreationForm):
|
||||||
|
username = CharField(required=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2', )
|
||||||
BIN
invsystem/user_manager/static/user_manager/images/favicon.ico
Normal file
BIN
invsystem/user_manager/static/user_manager/images/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
invsystem/user_manager/static/user_manager/images/logo_32_32.png
Normal file
BIN
invsystem/user_manager/static/user_manager/images/logo_32_32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
invsystem/user_manager/static/user_manager/images/logo_50_50.png
Normal file
BIN
invsystem/user_manager/static/user_manager/images/logo_50_50.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1 MiB |
231
invsystem/user_manager/static/user_manager/style.css
Normal file
231
invsystem/user_manager/static/user_manager/style.css
Normal file
|
|
@ -0,0 +1,231 @@
|
||||||
|
.logo {
|
||||||
|
height: 50px;
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome {
|
||||||
|
font-size: 14pt;
|
||||||
|
color: darkgray;
|
||||||
|
float: left;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo_not_logged_in {
|
||||||
|
height: 50px;
|
||||||
|
width: 50px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
margin: 5px;
|
||||||
|
height: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form {
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-fluid {
|
||||||
|
height: 50px;
|
||||||
|
top: 50%;
|
||||||
|
margin-top: -25px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.userlist {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilecontainer {
|
||||||
|
height: 60px;
|
||||||
|
margin: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilecontainer:hover {
|
||||||
|
height: 60px;
|
||||||
|
margin: 20px;
|
||||||
|
-webkit-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.64);
|
||||||
|
-moz-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.64);
|
||||||
|
box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.64);
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: 0.3s;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilepic {
|
||||||
|
height: 50px;
|
||||||
|
float: left;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-top: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilename {
|
||||||
|
position: relative;
|
||||||
|
top: 16%;
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
font-size: 1.6em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-info {
|
||||||
|
margin-left: 3%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgcontainer {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilepic-big {
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-left: 70px;
|
||||||
|
-webkit-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
-moz-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: 0.3s;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
font-size: 1.3em;
|
||||||
|
margin: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shadow {
|
||||||
|
-webkit-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
-moz-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.verified {
|
||||||
|
height: 23px;
|
||||||
|
width: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
width: 210px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 2px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 16px;
|
||||||
|
background-color: white;
|
||||||
|
background-position: 10px 10px;
|
||||||
|
background-size: 24px 24px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
padding: 12px 20px 12px 40px;
|
||||||
|
-webkit-transition: width 0.4s ease-in-out;
|
||||||
|
transition: width 0.4s ease-in-out;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search:focus {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-del {
|
||||||
|
margin-left: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilepic-1 {
|
||||||
|
height: 50px;
|
||||||
|
float: left;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-top: -11px;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.bot {
|
||||||
|
font-size: 1.3em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
bot:hover {
|
||||||
|
-webkit-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
-moz-box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
box-shadow: 3px 3px 28px -3px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.botheading {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nodec {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detaillist {
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.startbutton {
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
float: left;
|
||||||
|
order: 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.notrunning {
|
||||||
|
color: red;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.running {
|
||||||
|
color: greenyellow;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.red {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yellowgreen {
|
||||||
|
color: yellowgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-reload {
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uilink {
|
||||||
|
margin-left: 1.1em;
|
||||||
|
font-size: 1.3em;
|
||||||
|
order: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bot-btn-cont {
|
||||||
|
height: 3em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.stop-api-button{
|
||||||
|
margin-top: 2em;
|
||||||
|
}
|
||||||
55
invsystem/user_manager/templates/bases/navbar.html
Normal file
55
invsystem/user_manager/templates/bases/navbar.html
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'user_manager/style.css' %}">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||||
|
<link rel="shortcut icon" type="image/png" href="{% static 'user_manager/images' %}/favicon.ico"/>
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
|
||||||
|
integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Dosis" rel="stylesheet">
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-inverse">
|
||||||
|
<div class="container-fluid">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<div class="navbar-header">
|
||||||
|
|
||||||
|
<img src="{% static 'user_manager/images/logo_50_50.png' %}" class="logo">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<span class="welcome">Welcome {{ user.username }}!</span>
|
||||||
|
{% else %}
|
||||||
|
<div class="navbar-header">
|
||||||
|
<img src="{% static 'user_manager/images/logo_50_50.png' %}" class="logo_not_logged_in">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="{% url 'index' %}">Home</a></li>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
{% else %}
|
||||||
|
<li><a href="#">Page 2</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<li><a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>
|
||||||
|
<li><a href="#"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<li><a href="{% url 'register' %}"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
|
||||||
|
<li><a href="{% url 'login' %}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
{% extends 'bases/navbar.html' %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<p>Logged out!</p>
|
||||||
|
<a href="{% url 'login'%}">Click here to login again.</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
50
invsystem/user_manager/templates/registration/login.html
Normal file
50
invsystem/user_manager/templates/registration/login.html
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{% extends 'bases/navbar.html' %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<html>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
{% if form.errors %}
|
||||||
|
<p class="error">Wrong username/password combination</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if next %}
|
||||||
|
<p class="error">You cannot access that page without being logged in.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<form class="form-horizontal login-form" action="{% url 'login' %}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-sm-2" for="email">Username:</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
{{ form.username }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-sm-2" for="pwd">Password:</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
{{ form.password }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<button type="submit" class="btn btn-default">Login</button>
|
||||||
|
<input type="hidden" name="next" value="{{ next }}">
|
||||||
|
<span class="reset"><a href="{% url 'password_reset' %}">Lost password?</a></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
{% endblock %}
|
||||||
25
invsystem/user_manager/templates/registration/register.html
Normal file
25
invsystem/user_manager/templates/registration/register.html
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
{% extends 'bases/navbar.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>registration page</h1>
|
||||||
|
<form method="post" action="{% url 'register' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% if form.errors %}
|
||||||
|
<p>There are errors in the form</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ form }}
|
||||||
|
<input type="submit" value="Register">
|
||||||
|
</form>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
{% endblock %}
|
||||||
13
invsystem/user_manager/templates/user_manager/index.html
Normal file
13
invsystem/user_manager/templates/user_manager/index.html
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends 'bases/navbar.html' %}
|
||||||
|
<html>
|
||||||
|
{% block content%}
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h3>Right Aligned Navbar</h3>
|
||||||
|
<p>The .navbar-right class is used to right-align navigation bar buttons.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</html>
|
||||||
7
invsystem/user_manager/urls.py
Normal file
7
invsystem/user_manager/urls.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.index, name='index'),
|
||||||
|
path('register', views.register, name='register'),
|
||||||
|
]
|
||||||
|
|
@ -1,3 +1,27 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
|
from django.contrib.auth import authenticate, login
|
||||||
|
|
||||||
# Create your views here.
|
from .forms import SignUpForm
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
return render(request, 'user_manager/index.html')
|
||||||
|
|
||||||
|
|
||||||
|
def register(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = SignUpForm(request.POST)
|
||||||
|
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
username = form.cleaned_data['username']
|
||||||
|
password = form.cleaned_data['password1']
|
||||||
|
user = authenticate(username=username, password=password)
|
||||||
|
login(request, user)
|
||||||
|
return redirect('index')
|
||||||
|
|
||||||
|
else:
|
||||||
|
form = SignUpForm()
|
||||||
|
|
||||||
|
context = {'form': form}
|
||||||
|
return render(request, 'registration/register.html', context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue