-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from SADiLaR/feature/user-management-styling
user management frontend
- Loading branch information
Showing
10 changed files
with
254 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from users.models import CustomUser | ||
|
||
|
||
class CustomUserCreationForm(UserCreationForm): | ||
email = forms.EmailField(required=True, help_text="Required. Add a valid email address.") | ||
username = forms.CharField(required=True, help_text="Required. Add a valid username.") | ||
first_name = forms.CharField(required=True, help_text="Required. Add a valid first name.") | ||
last_name = forms.CharField(required=True, help_text="Required. Add a valid last name.") | ||
email = forms.EmailField( | ||
required=True, | ||
help_text=_("Required. Add a valid email address."), | ||
) | ||
username = forms.CharField( | ||
required=True, | ||
help_text=_("Required. Add a valid username."), | ||
) | ||
first_name = forms.CharField( | ||
required=True, | ||
help_text=_("Required. Add a valid first name."), | ||
) | ||
last_name = forms.CharField( | ||
required=True, | ||
) | ||
|
||
class Meta: | ||
model = CustomUser | ||
fields = ("username", "email", "first_name", "last_name") | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(CustomUserCreationForm, self).__init__(*args, **kwargs) | ||
self.fields["email"].required = True | ||
self.fields["username"].required = True | ||
self.fields["first_name"].required = True | ||
self.fields["last_name"].required = True | ||
for field_name, field in self.fields.items(): | ||
field.widget.attrs["class"] = "form-control" | ||
|
||
|
||
class CustomAuthenticationForm(AuthenticationForm): | ||
username = forms.CharField(label=_("Username"), help_text=_("Required. Enter your username.")) | ||
password = forms.CharField(label=_("Password"), help_text=_("Required. Enter your password.")) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(CustomAuthenticationForm, self).__init__(*args, **kwargs) | ||
for field in self.fields.values(): | ||
field.widget.attrs.update({"class": "form-control"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,76 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}Log In{% endblock %} | ||
{% block title %}{% trans "Log In" %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<h2>Log In</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form }} | ||
<button type="submit">Log In</button> | ||
</form> | ||
|
||
<br> | ||
<hr> | ||
<form method="post" action="{% url 'logout' %}"> | ||
{% csrf_token %} | ||
<button type="submit">logout</button> | ||
</form> | ||
</div> | ||
<div class="container"> | ||
<div class="section mt-3 mb-3"> | ||
<div class="card body-card"> | ||
<div class="user-account-body"> | ||
<h2>{% trans "Log In" %}</h2> | ||
<br/> | ||
<form method="post" class="text-left"> | ||
{% csrf_token %} | ||
|
||
<!-- Username Field --> | ||
<div class="form-group login-form-group mb-4"> | ||
<label for="id_username">{% trans "Username:" %}</label> | ||
<input type="text" name="username" id="id_username" class="form-control" placeholder="{% trans 'Username' %}" value="{{ form.username.value|default:'' }}"> | ||
{% if form.username.help_text %} | ||
<small class="form-text text-muted">{{ form.username.help_text }}</small> | ||
{% endif %} | ||
{% if form.username.errors %} | ||
<div class="invalid-feedback d-block"> | ||
{% for error in form.username.errors %} | ||
<p>{{ error }}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<!-- Password Field --> | ||
<div class="form-group login-form-group mb-1"> | ||
<label for="id_password">{% trans "Password:" %}</label> | ||
<input type="password" name="password" id="id_password" class="form-control" placeholder="{% trans 'Password' %}" value="{{ form.password.value|default:'' }}"> | ||
{% if form.password.help_text %} | ||
<small class="form-text text-muted">{{ form.password.help_text }}</small> | ||
{% endif %} | ||
{% if form.password.errors %} | ||
<div class="invalid-feedback d-block"> | ||
{% for error in form.password.errors %} | ||
<p>{{ error }}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<!-- Log In Button and Forgot Password --> | ||
<div class="form-group"> | ||
<a href="{% url 'password_reset' %}" class="d-block mb-2">{% trans "Forgot Password?" %}</a> | ||
|
||
{% if form.non_field_errors %} | ||
<div class="invalid-feedback d-block"> | ||
{% for error in form.non_field_errors %} | ||
<p>{{ error }}</p> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
|
||
<button type="submit" class="btn btn-primary">{% trans "Log In" %}</button> | ||
</div> | ||
</form> | ||
|
||
<br> | ||
<hr> | ||
<div class="form-group row"> | ||
<div class="col-sm-10"> | ||
<p>{% trans "Don't have an account?" %} <a href="{% url 'accounts_register' %}">{% trans "Create one" %}</a></p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}Password reset complete{% endblock %} | ||
{% block title %}{% trans "Password reset complete" %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<p>Your password has been set. You may go ahead and log in now.</p> | ||
<br> | ||
<p><a href="{{ login_url }}">Log in</a></p> | ||
<div class="section mt-3 mb-3"> | ||
<div class="card text-center body-card"> | ||
<div class="user-account-body"> | ||
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p> | ||
<br> | ||
<p> | ||
<a href="{{ login_url }}" class="btn btn-primary"> | ||
{% trans "Log in" %} | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,50 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}Enter new password{% endblock %} | ||
{% block title %}{% trans "Enter new password" %}{% endblock %} | ||
|
||
{% block content %} | ||
|
||
{% if validlink %} | ||
|
||
<div class="container"> | ||
<p>Please enter your new password twice so we can verify you typed it in correctly.</p> | ||
|
||
<form method="post">{% csrf_token %} | ||
<fieldset class="module aligned"> | ||
<div class="form-row field-password1"> | ||
{{ form.new_password1.errors }} | ||
<div class="flex-container"> | ||
<label for="id_new_password1">New password:</label> | ||
{{ form.new_password1 }} | ||
<div class="section mt-3 mb-3"> | ||
<div class="card text-center body-card"> | ||
<div class="user-account-body"> | ||
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p> | ||
|
||
<form method="post">{% csrf_token %} | ||
<fieldset class="module aligned"> | ||
<div class="form-row field-password1"> | ||
{{ form.new_password1.errors }} | ||
<div class="flex-container"> | ||
<label for="id_new_password1">{% trans "New password:" %}</label> | ||
{{ form.new_password1 }} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-row field-password2"> | ||
{{ form.new_password2.errors }} | ||
<div class="flex-container"> | ||
<label for="id_new_password2">Confirm password:</label> | ||
{{ form.new_password2 }} | ||
<div class="form-row field-password2"> | ||
{{ form.new_password2.errors }} | ||
<div class="flex-container"> | ||
<label for="id_new_password2">{% trans "Confirm password:" %}</label> | ||
{{ form.new_password2 }} | ||
</div> | ||
</div> | ||
</fieldset> | ||
<br> | ||
<br> | ||
<div class="submit-row"> | ||
<input type="submit" class="btn btn-primary" value="{% trans 'Change my password' %}"> | ||
</div> | ||
</fieldset> | ||
<br> | ||
<br> | ||
<div class="submit-row"> | ||
<input type="submit" value="Change my password"> | ||
</div> | ||
</form> | ||
</form> | ||
|
||
{% else %} | ||
{% else %} | ||
|
||
<p>"The password reset link was invalid, possibly because it has already been used. Please request a new | ||
password reset.</p> | ||
<p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new | ||
password reset.{% endblocktrans %}</p> | ||
|
||
{% endif %} | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}Email Sent{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<p>We’ve emailed you instructions for setting your password, if an account exists with the email you entered. | ||
You should receive them shortly.</p> | ||
<div class="section mt-3 mb-3"> | ||
<div class="card text-center body-card"> | ||
<div class="user-account-body"> | ||
<p>{% blocktrans %}We’ve emailed you instructions for setting your password, if an account exists with the email you entered. | ||
You should receive them shortly.{% endblocktrans %}</p> | ||
|
||
<p>If you don’t receive an email, please make sure you’ve entered the address you registered with, and check | ||
your spam folder.</p> | ||
<p>{% blocktrans %}If you don’t receive an email, please make sure you’ve entered the address you registered with, and check | ||
your spam folder.{% endblocktrans %}</p> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block title %}Forgot Your Password?{% endblock %} | ||
{% block title %}{% trans "Forgot Your Password?" %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<p>Forgotten your password? Enter your email address below, and we’ll email instructions for setting a new | ||
one.</p> | ||
<div class="section mt-3 mb-3"> | ||
<div class="card body-card"> | ||
<div class="user-account-body"> | ||
<p>{% blocktrans %}Forgotten your password? Enter your email address below, and we’ll email instructions for setting a new | ||
one.{% endblocktrans %}</p> | ||
|
||
<form method="post"> | ||
{% csrf_token %} | ||
<fieldset class="module aligned"> | ||
<div class="form-row field-email"> | ||
{{ form.email.errors }} | ||
<div class="flex-container"> | ||
<label for="id_email">Email address:</label> | ||
{{ form.email }} | ||
<form method="post"> | ||
{% csrf_token %} | ||
<fieldset class="module aligned"> | ||
<div class="form-row field-email"> | ||
{{ form.email.errors }} | ||
<div class="flex-container"> | ||
<label for="id_email">{% trans "Email address:" %}</label> | ||
{{ form.email }} | ||
</div> | ||
</div> | ||
</fieldset> | ||
<div class="submit-row"> | ||
<br> | ||
<br> | ||
<input type="submit" class="btn btn-primary" value="{% trans 'Reset my password' %}"> | ||
</div> | ||
</fieldset> | ||
<div class="submit-row"> | ||
<br> | ||
<br> | ||
<input type="submit" value="Reset my password"> | ||
</div> | ||
</form> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.