created accounts app
parent
a5271dd467
commit
33130d3607
|
|
@ -0,0 +1,10 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
|
||||
from .models import User
|
||||
|
||||
|
||||
@admin.register(User)
|
||||
class UserAdmin(UserAdmin):
|
||||
list_display = ["usernsame", "email", "first_name", "last_name", "display_name"]
|
||||
list_filter = ["is_active"]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "accounts"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(AbstractUser):
|
||||
display_name = models.CharField(
|
||||
max_lenth=200, help_test="Display name", blank=True, null=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
if self.display_name:
|
||||
return self.display_name
|
||||
elif self.first_name and self.last_name:
|
||||
return f"{self.first_name} {self.last_name}"
|
||||
elif self.first_name:
|
||||
return self.first_name
|
||||
else:
|
||||
return self.username
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Login</h1>
|
||||
{% if form.errors %}
|
||||
<p>The username and password combination entered did not match an active account.</p>
|
||||
{% endif %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Login"/>
|
||||
<a href="{% url 'core:homepage' %}">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Password change complete</h1>
|
||||
<p>Your password has been successfully changed. Don't forget your new password!</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Change your password</h1>
|
||||
<form method="post">
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<button type="submit">Change password</button>
|
||||
<button type="reset">Reset form</button>
|
||||
<a href="{% url 'display_profile' %}">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Password reset</h1>
|
||||
<p>
|
||||
Your password has been reset successfully. You can <a href="{% url 'login' %}">login now</a>.
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Reset your password</h1>
|
||||
{% if validlink %}
|
||||
<p>Enter your new password twice.</p>
|
||||
<form method="post">
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<input type="submit" value="Change my password"/>
|
||||
<a href="{% url 'core:homepage' %}">Cancel</a>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>
|
||||
The password reset link you clicked was invalid. This may mean it has already been used or too much time
|
||||
has passed since you requested it.
|
||||
</p>
|
||||
<p>
|
||||
If you have not already reset your password successfully, you may request a <a
|
||||
href="{% url 'password_reset' %}">new password reset.</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Password reset requested</h1>
|
||||
<p>An email has been sent with a link which will allow you to reset your password.</p>
|
||||
<p>
|
||||
If you do not receive it, check your spam or junk folders and ensure you typed the email address connected
|
||||
with your account.
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
A request to reset the password associated with this account has been made on our health website.
|
||||
|
||||
If this was you, please click the following link to reset your password.
|
||||
|
||||
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
||||
|
||||
If you did not make this request, we would suggest you log into your account to confirm there has been no malicious activity. You may also want to consider changing your password as a precaution.
|
||||
|
||||
--
|
||||
The Dazed Gerbil
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Reset your password</h1>
|
||||
<p>Have you forgotten your password? Enter your email address to request a password reset.</p>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %} {{ form.as_p }}
|
||||
<input type="submit" value="Reset my password"/>
|
||||
<a href="{% url 'core:homepage' %}">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from django.urls import include, path
|
||||
|
||||
urlpatterns = [
|
||||
path("", include("django.contrib.auth.urls")),
|
||||
]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Loading…
Reference in New Issue