Add registration form
Prepare for closed registrations (will be default probably)
This commit is contained in:
parent
e7a0ff4a64
commit
4e4d47a9ad
6 changed files with 116 additions and 58 deletions
33
frontend/templates/registration/base.html
Normal file
33
frontend/templates/registration/base.html
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{% include "frontend/header.html" %}
|
||||||
|
|
||||||
|
<body class="bg-gradient-primary">
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<!-- Outer Row -->
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
|
||||||
|
<div class="col-xl-10 col-lg-12 col-md-9">
|
||||||
|
|
||||||
|
<div class="card o-hidden border-0 shadow-lg my-5">
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<!-- Nested Row within Card Body -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include "frontend/footer.html" %}
|
|
@ -1,57 +1,32 @@
|
||||||
{% include "frontend/header.html" %}
|
{% extends "registration/base.html" %}
|
||||||
|
|
||||||
<body class="bg-gradient-primary">
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
|
|
||||||
<!-- Outer Row -->
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
|
|
||||||
<div class="col-xl-10 col-lg-12 col-md-9">
|
|
||||||
|
|
||||||
<div class="card o-hidden border-0 shadow-lg my-5">
|
|
||||||
<div class="card-body p-0">
|
|
||||||
<!-- Nested Row within Card Body -->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<div class="p-5">
|
|
||||||
<div class="text-center">
|
|
||||||
<h1 class="h4 text-gray-900 mb-4">Welcome Back!</h1>
|
|
||||||
</div>
|
|
||||||
<form class="user" action="" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="form-group">
|
|
||||||
<input class="form-control form-control-user"
|
|
||||||
id="id_username" aria-describedby="emailHelp" name="username"
|
|
||||||
placeholder="Username">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="password" class="form-control form-control-user"
|
|
||||||
id="id_password" name="password" placeholder="Password">
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary btn-user btn-block">
|
|
||||||
Login
|
|
||||||
</button>
|
|
||||||
<hr>
|
|
||||||
</form>
|
|
||||||
<hr>
|
|
||||||
<div class="text-center">
|
|
||||||
<a class="small" href="forgot-password.html">Forgot Password?</a>
|
|
||||||
</div>
|
|
||||||
<div class="text-center">
|
|
||||||
<a class="small" href="register.html">Create an Account!</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="p-5">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="h4 text-gray-900 mb-4">Welcome Back!</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<form class="user" action="" method="post">
|
||||||
{% include "frontend/footer.html" %}
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<input class="form-control form-control-user"
|
||||||
|
id="id_username" aria-describedby="emailHelp" name="username"
|
||||||
|
placeholder="Username">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="password" class="form-control form-control-user"
|
||||||
|
id="id_password" name="password" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-user btn-block">
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
<hr>
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
|
<div class="text-center">
|
||||||
|
<a class="small" href="#">Forgot Password?</a>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<a class="small" href="{% url "frontend:register" %}">Create an Account!</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
0
frontend/templates/registration/registration_closed.html
Normal file
0
frontend/templates/registration/registration_closed.html
Normal file
32
frontend/templates/registration/registration_form.html
Normal file
32
frontend/templates/registration/registration_form.html
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{% extends "registration/base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="p-5">
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="h4 text-gray-900 mb-4">Let's get started!</h1>
|
||||||
|
</div>
|
||||||
|
<form class="user" action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<input class="form-control form-control-user"
|
||||||
|
id="id_username" aria-describedby="emailHelp" name="username"
|
||||||
|
placeholder="Username">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="password" class="form-control form-control-user"
|
||||||
|
id="id_password1" name="password1" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="password" class="form-control form-control-user"
|
||||||
|
id="id_password2" name="password2" placeholder="Repeat Password">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-user btn-block">
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
<hr>
|
||||||
|
</form>
|
||||||
|
<div class="text-center">
|
||||||
|
<a class="small" href="{% url "login" %}">Already have an account? Sign in!</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
from .views import DashboardView
|
from .views import DashboardView, UserRegistrationView
|
||||||
|
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
|
@ -6,4 +6,5 @@ app_name = "frontend"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', DashboardView.as_view(), name="dashboard"),
|
path('', DashboardView.as_view(), name="dashboard"),
|
||||||
|
path('accounts/register/', UserRegistrationView.as_view(), name="register"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
from django.views.generic import TemplateView, ListView, UpdateView, DetailView, CreateView, DeleteView
|
from django.views.generic import TemplateView, CreateView
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.contrib.auth import get_user_model, login
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
|
|
||||||
class DashboardView(LoginRequiredMixin, TemplateView):
|
class DashboardView(LoginRequiredMixin, TemplateView):
|
||||||
|
@ -9,4 +12,18 @@ class DashboardView(LoginRequiredMixin, TemplateView):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["title"] = "Dashboard"
|
context["title"] = "Dashboard"
|
||||||
context["subtitle"] = "An overview of everything going on in your Kumify account."
|
context["subtitle"] = "An overview of everything going on in your Kumify account."
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class UserRegistrationView(CreateView):
|
||||||
|
form_class = UserCreationForm
|
||||||
|
model = get_user_model()
|
||||||
|
template_name = "registration/registration_form.html"
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
ret = super().form_valid(form)
|
||||||
|
login(self.request, self.object)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("frontend:dashboard")
|
Loading…
Reference in a new issue