diff --git a/.gitignore b/.gitignore index 894a44c..ac3dec0 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# IDE +.idea diff --git a/invsystem/invsystem/settings.py b/invsystem/invsystem/settings.py index e5cb2b2..37c95e0 100644 --- a/invsystem/invsystem/settings.py +++ b/invsystem/invsystem/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'user_manager', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Berlin' USE_I18N = True @@ -118,3 +119,8 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' + +LOGIN_REDIRECT_URL = '/' +LOGIN_URL = '/accounts/login' + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/invsystem/invsystem/urls.py b/invsystem/invsystem/urls.py index e801338..972ff28 100644 --- a/invsystem/invsystem/urls.py +++ b/invsystem/invsystem/urls.py @@ -18,4 +18,7 @@ from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('accounts/', include('django.contrib.auth.urls')), + path('', include('user_manager.urls')), + ] diff --git a/invsystem/user_manager/forms.py b/invsystem/user_manager/forms.py new file mode 100644 index 0000000..dccf4d3 --- /dev/null +++ b/invsystem/user_manager/forms.py @@ -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', ) \ No newline at end of file diff --git a/invsystem/user_manager/static/user_manager/images/favicon.ico b/invsystem/user_manager/static/user_manager/images/favicon.ico new file mode 100644 index 0000000..afb619a Binary files /dev/null and b/invsystem/user_manager/static/user_manager/images/favicon.ico differ diff --git a/invsystem/user_manager/static/user_manager/images/logo_32_32.png b/invsystem/user_manager/static/user_manager/images/logo_32_32.png new file mode 100644 index 0000000..afb619a Binary files /dev/null and b/invsystem/user_manager/static/user_manager/images/logo_32_32.png differ diff --git a/invsystem/user_manager/static/user_manager/images/logo_50_50.png b/invsystem/user_manager/static/user_manager/images/logo_50_50.png new file mode 100644 index 0000000..6cabbaf Binary files /dev/null and b/invsystem/user_manager/static/user_manager/images/logo_50_50.png differ diff --git a/invsystem/user_manager/static/user_manager/images/logo_original.png b/invsystem/user_manager/static/user_manager/images/logo_original.png new file mode 100644 index 0000000..be7014c Binary files /dev/null and b/invsystem/user_manager/static/user_manager/images/logo_original.png differ diff --git a/invsystem/user_manager/static/user_manager/style.css b/invsystem/user_manager/static/user_manager/style.css new file mode 100644 index 0000000..292254a --- /dev/null +++ b/invsystem/user_manager/static/user_manager/style.css @@ -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; +} \ No newline at end of file diff --git a/invsystem/user_manager/templates/bases/navbar.html b/invsystem/user_manager/templates/bases/navbar.html new file mode 100644 index 0000000..ac7d2ae --- /dev/null +++ b/invsystem/user_manager/templates/bases/navbar.html @@ -0,0 +1,55 @@ +{% load static %} + + + + + + + + + + + + + + + + +{% block content %} +{% endblock %} \ No newline at end of file diff --git a/invsystem/user_manager/templates/registration/logged_out.html b/invsystem/user_manager/templates/registration/logged_out.html new file mode 100644 index 0000000..1968dd3 --- /dev/null +++ b/invsystem/user_manager/templates/registration/logged_out.html @@ -0,0 +1,15 @@ +{% extends 'bases/navbar.html' %} + +{% load static %} + +{% block content %} +
+

Logged out!

+ Click here to login again. +
+ +{% endblock %} + + + + diff --git a/invsystem/user_manager/templates/registration/login.html b/invsystem/user_manager/templates/registration/login.html new file mode 100644 index 0000000..b3a88ce --- /dev/null +++ b/invsystem/user_manager/templates/registration/login.html @@ -0,0 +1,50 @@ +{% extends 'bases/navbar.html' %} + +{% load static %} + +{% block content %} + + + +
+ {% if form.errors %} +

Wrong username/password combination

+ {% endif %} + + {% if next %} +

You cannot access that page without being logged in.

+ {% endif %} + + +
+ {% csrf_token %} +
+ +
+ {{ form.username }} +
+
+
+ +
+ {{ form.password }} +
+
+ +
+
+ + + Lost password? + +
+ +
+ +
+ +
+ + + +{% endblock %} diff --git a/invsystem/user_manager/templates/registration/register.html b/invsystem/user_manager/templates/registration/register.html new file mode 100644 index 0000000..76c412a --- /dev/null +++ b/invsystem/user_manager/templates/registration/register.html @@ -0,0 +1,25 @@ +{% extends 'bases/navbar.html' %} +{% load static %} + + +{% block content %} + + +
+

registration page

+
+ {% csrf_token %} + + {% if form.errors %} +

There are errors in the form

+ {% endif %} + + {{ form }} + +
+
+ + + + +{% endblock %} \ No newline at end of file diff --git a/invsystem/user_manager/templates/user_manager/index.html b/invsystem/user_manager/templates/user_manager/index.html new file mode 100644 index 0000000..c9c8240 --- /dev/null +++ b/invsystem/user_manager/templates/user_manager/index.html @@ -0,0 +1,13 @@ +{% extends 'bases/navbar.html' %} + +{% block content%} + + +
+

Right Aligned Navbar

+

The .navbar-right class is used to right-align navigation bar buttons.

+
+ +{% endblock %} + + \ No newline at end of file diff --git a/invsystem/user_manager/urls.py b/invsystem/user_manager/urls.py new file mode 100644 index 0000000..2b945f6 --- /dev/null +++ b/invsystem/user_manager/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('register', views.register, name='register'), +] diff --git a/invsystem/user_manager/views.py b/invsystem/user_manager/views.py index 91ea44a..f2ac587 100644 --- a/invsystem/user_manager/views.py +++ b/invsystem/user_manager/views.py @@ -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)