Implement login/register
This commit is contained in:
parent
3220219b16
commit
3cd8535ab9
23 changed files with 337 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -109,3 +109,4 @@ GitHub.sublime-settings
|
|||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history
|
||||
/nuitdelinfo_2021/settings.py
|
||||
|
|
21
error/migrations/0001_initial.py
Normal file
21
error/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 20:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ThomasPesquetQuotes',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.TextField()),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -135,3 +135,12 @@ STATICFILES_DIRS = (path.join('static'),)
|
|||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
ACCOUNT_ACTIVATION_DAYS = 7
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
EMAIL_USE_TLS = True
|
||||
EMAIL_HOST = 'smtp.gmail.com'
|
||||
EMAIL_PORT = 587
|
||||
EMAIL_HOST_USER = 'me@gmail.com'
|
||||
EMAIL_HOST_PASSWORD = 'password'
|
|
@ -23,6 +23,8 @@ urlpatterns = [
|
|||
path("a/", include("rescue.urls")),
|
||||
path("p/", include("people.urls")),
|
||||
path('admin/', admin.site.urls),
|
||||
path('accounts/', include('django_registration.backends.activation.urls')),
|
||||
path('accounts/', include('django.contrib.auth.urls'))
|
||||
]
|
||||
|
||||
handler400 = "error.views.index"
|
||||
|
|
32
people/migrations/0001_initial.py
Normal file
32
people/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 20:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='People',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('first_name', models.CharField(max_length=40)),
|
||||
('last_name', models.CharField(max_length=60)),
|
||||
('title', models.CharField(max_length=70)),
|
||||
('description', models.TextField()),
|
||||
('birth', models.DateField()),
|
||||
('death', models.DateField()),
|
||||
('history', models.TextField()),
|
||||
('genealogy', models.TextField()),
|
||||
('awards', models.TextField()),
|
||||
('pro_life', models.TextField()),
|
||||
('testimonials', models.TextField()),
|
||||
('sources', models.TextField()),
|
||||
],
|
||||
),
|
||||
]
|
59
people/migrations/0002_auto_20211202_2127.py
Normal file
59
people/migrations/0002_auto_20211202_2127.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 21:27
|
||||
|
||||
from django.db import migrations, models
|
||||
import django_quill.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='awards',
|
||||
field=django_quill.fields.QuillField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='death',
|
||||
field=models.DateField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='description',
|
||||
field=django_quill.fields.QuillField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='genealogy',
|
||||
field=django_quill.fields.QuillField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='history',
|
||||
field=django_quill.fields.QuillField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='pro_life',
|
||||
field=django_quill.fields.QuillField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='sources',
|
||||
field=django_quill.fields.QuillField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='testimonials',
|
||||
field=django_quill.fields.QuillField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='title',
|
||||
field=models.CharField(max_length=70, null=True),
|
||||
),
|
||||
]
|
60
people/migrations/0003_auto_20211202_2225.py
Normal file
60
people/migrations/0003_auto_20211202_2225.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 22:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django_quill.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0002_auto_20211202_2127'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='people',
|
||||
name='pending_edit_of',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='people.people'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='people',
|
||||
name='validated',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='awards',
|
||||
field=django_quill.fields.QuillField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='death',
|
||||
field=models.DateField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='genealogy',
|
||||
field=django_quill.fields.QuillField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='history',
|
||||
field=django_quill.fields.QuillField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='pro_life',
|
||||
field=django_quill.fields.QuillField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='testimonials',
|
||||
field=django_quill.fields.QuillField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='people',
|
||||
name='title',
|
||||
field=models.CharField(blank=True, max_length=70, null=True),
|
||||
),
|
||||
]
|
30
rescue/migrations/0001_initial.py
Normal file
30
rescue/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 20:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('people', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Rescue',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=70)),
|
||||
('date', models.DateField()),
|
||||
('location_long', models.DecimalField(decimal_places=6, max_digits=9)),
|
||||
('location_lat', models.DecimalField(decimal_places=6, max_digits=9)),
|
||||
('resume', models.CharField(max_length=125)),
|
||||
('description', models.TextField()),
|
||||
('sources', models.TextField()),
|
||||
('rescuers', models.ManyToManyField(related_name='rescued', to='people.People')),
|
||||
('saved', models.ManyToManyField(related_name='saved', to='people.People')),
|
||||
],
|
||||
),
|
||||
]
|
24
rescue/migrations/0002_auto_20211202_2301.py
Normal file
24
rescue/migrations/0002_auto_20211202_2301.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.2.9 on 2021-12-02 23:01
|
||||
|
||||
from django.db import migrations
|
||||
import django_quill.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rescue', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='rescue',
|
||||
name='description',
|
||||
field=django_quill.fields.QuillField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='rescue',
|
||||
name='sources',
|
||||
field=django_quill.fields.QuillField(),
|
||||
),
|
||||
]
|
1
templates/django_registration/activation_complete.html
Normal file
1
templates/django_registration/activation_complete.html
Normal file
|
@ -0,0 +1 @@
|
|||
Activation complete :/
|
2
templates/django_registration/activation_email_body.txt
Normal file
2
templates/django_registration/activation_email_body.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
activation URL: {{site}}/accounts/activate/{{ activation_key }}/
|
||||
The number of days remaining during which the account may be activated: {{ expiration_days }}
|
|
@ -0,0 +1 @@
|
|||
Activation email for {{ user }}
|
1
templates/django_registration/activation_failed.html
Normal file
1
templates/django_registration/activation_failed.html
Normal file
|
@ -0,0 +1 @@
|
|||
Activation failed :/
|
1
templates/django_registration/registration_closed.html
Normal file
1
templates/django_registration/registration_closed.html
Normal file
|
@ -0,0 +1 @@
|
|||
Registration closed :/
|
1
templates/django_registration/registration_complete.html
Normal file
1
templates/django_registration/registration_complete.html
Normal file
|
@ -0,0 +1 @@
|
|||
Registration complete !
|
5
templates/django_registration/registration_form.html
Normal file
5
templates/django_registration/registration_form.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit" value="login" />
|
||||
</form>
|
4
templates/registration/logged_out.html
Normal file
4
templates/registration/logged_out.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{% block content %}
|
||||
<p>Logged out!</p>
|
||||
<a href="{% url 'login'%}">Click here to login again.</a>
|
||||
{% endblock %}
|
37
templates/registration/login.html
Normal file
37
templates/registration/login.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
{% block content %}
|
||||
|
||||
{% if form.errors %}
|
||||
<p>Your username and password didn't match. Please try again.</p>
|
||||
{% endif %}
|
||||
|
||||
{% if next %}
|
||||
{% if user.is_authenticated %}
|
||||
<p>Your account doesn't have access to this page. To proceed,
|
||||
please login with an account that has access.</p>
|
||||
{% else %}
|
||||
<p>Please login to see this page.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="{% url 'login' %}">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<tr>
|
||||
<td>{{ form.username.label_tag }}</td>
|
||||
<td>{{ form.username }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ form.password.label_tag }}</td>
|
||||
<td>{{ form.password }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" value="login" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</form>
|
||||
|
||||
{# Assumes you setup the password_reset view in your URLconf #}
|
||||
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
|
||||
|
||||
<p><a href="{% url 'django_registration_register' %}">Register</a></p>
|
||||
|
||||
{% endblock %}
|
4
templates/registration/password_reset_complete.html
Normal file
4
templates/registration/password_reset_complete.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{% block content %}
|
||||
<h1>The password has been changed!</h1>
|
||||
<p><a href="{% url 'login' %}">log in again?</a></p>
|
||||
{% endblock %}
|
27
templates/registration/password_reset_confirm.html
Normal file
27
templates/registration/password_reset_confirm.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% block content %}
|
||||
{% if validlink %}
|
||||
<p>Please enter (and confirm) your new password.</p>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<tr>
|
||||
<td>{{ form.new_password1.errors }}
|
||||
<label for="id_new_password1">New password:</label></td>
|
||||
<td>{{ form.new_password1 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ form.new_password2.errors }}
|
||||
<label for="id_new_password2">Confirm password:</label></td>
|
||||
<td>{{ form.new_password2 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="Change my password" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
{% else %}
|
||||
<h1>Password reset failed</h1>
|
||||
<p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
3
templates/registration/password_reset_done.html
Normal file
3
templates/registration/password_reset_done.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
{% block content %}
|
||||
<p>We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder.</p>
|
||||
{% endblock %}
|
2
templates/registration/password_reset_email.html
Normal file
2
templates/registration/password_reset_email.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
Someone asked for password reset for email {{ email }}. Follow the link below:
|
||||
{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
10
templates/registration/password_reset_form.html
Normal file
10
templates/registration/password_reset_form.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% block content %}
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{% if form.email.errors %}
|
||||
{{ form.email.errors }}
|
||||
{% endif %}
|
||||
<p>{{ form.email }}</p>
|
||||
<input type="submit" class="btn btn-default btn-lg" value="Reset password">
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue