registration page
This commit is contained in:
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@@ -2,15 +2,13 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
|
<list default="true" id="15f590a5-5017-44f1-a85e-17dfe3fc5379" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/templatetags/__init__.py" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/templates/registration/signup.html" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/templatetags/auth_extras.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/work/templatetags/__init__.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/work/templatetags/auth_extras.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/accounts/forms.py" beforeDir="false" afterPath="$PROJECT_DIR$/accounts/forms.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/accounts/views.py" beforeDir="false" afterPath="$PROJECT_DIR$/accounts/views.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/settings.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/settings.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/config/urls.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/templates/base.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/base.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/work/migrations/__init__.py" beforeDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
BIN
accounts/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/admin.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/admin.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/apps.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/apps.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/forms.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/forms.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/models.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/models.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/views.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/views.cpython-38.pyc
Normal file
Binary file not shown.
@@ -1,6 +1,49 @@
|
|||||||
from django.contrib.auth.forms import AuthenticationForm
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterForm(UserCreationForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ['username', 'password1', 'password2']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(RegisterForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['username'] = forms.CharField(
|
||||||
|
widget=forms.TextInput(attrs={
|
||||||
|
'placeholder': 'Nazwa użytkownika'
|
||||||
|
}),
|
||||||
|
error_messages={
|
||||||
|
'required': 'Wpisz nazwę użytkownika',
|
||||||
|
})
|
||||||
|
self.fields['password1'] = forms.CharField(
|
||||||
|
widget=forms.PasswordInput(attrs={
|
||||||
|
'placeholder': 'Hasło'
|
||||||
|
}),
|
||||||
|
error_messages={
|
||||||
|
'required': 'Podaj hasło',
|
||||||
|
})
|
||||||
|
self.fields['password2'] = forms.CharField(
|
||||||
|
widget=forms.PasswordInput(attrs={
|
||||||
|
'placeholder': 'Powtórz hasło'
|
||||||
|
}),
|
||||||
|
error_messages={
|
||||||
|
'required': 'Podaj hasło',
|
||||||
|
})
|
||||||
|
|
||||||
|
for field in ['username', 'password1', 'password2']:
|
||||||
|
self.fields[field].help_text = None
|
||||||
|
self.fields[field].label = ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# class LoginForm(AuthenticationForm):
|
|
||||||
# username = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}))
|
|
||||||
# password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))
|
|
||||||
|
|||||||
BIN
accounts/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
accounts/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
@@ -1,3 +1,13 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
|
from .forms import RegisterForm
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
def register(response):
|
||||||
|
if response.method == "POST":
|
||||||
|
form = RegisterForm(response.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
return redirect("/")
|
||||||
|
else:
|
||||||
|
form = RegisterForm()
|
||||||
|
return render(response, "registration/signup.html", {"form":form})
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -39,6 +39,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
|
'accounts.apps.AccountsConfig',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ from django.contrib import admin
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from work import views
|
from work import views
|
||||||
|
from accounts import views as accounts_views
|
||||||
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ urlpatterns = [
|
|||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
# path('', TemplateView.as_view(template_name='home.html'), name='home'),
|
# path('', TemplateView.as_view(template_name='home.html'), name='home'),
|
||||||
path('', views.get_basic_workdata, name='home'),
|
path('', views.get_basic_workdata, name='home'),
|
||||||
|
path('register/', accounts_views.register, name='register'),
|
||||||
|
# url(r'^signup/$', accounts_views.signup, name='signup'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
@@ -34,14 +34,14 @@
|
|||||||
</li>
|
</li>
|
||||||
<!--Dodaj godziny-->
|
<!--Dodaj godziny-->
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#">Dodaj godziny</a>
|
<a class="nav-link" href="/">Dodaj godziny</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% load auth_extras %}
|
{% load auth_extras %}
|
||||||
{% if request.user|has_group:"moderators" %}
|
{% if request.user|has_group:"moderators" %}
|
||||||
<!--Dodaj pracownika-->
|
<!--Dodaj pracownika-->
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#">Dodaj pracownika</a>
|
<a class="nav-link" href="/register">Dodaj pracownika</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
17
templates/registration/signup.html
Normal file
17
templates/registration/signup.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-signin">
|
||||||
|
<form method="POST" class="form-group">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form|crispy }}
|
||||||
|
<button class="btn btn-lg btn-success btn-block" type="submit">Zarejestruj</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user