Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registration feat bis : this PR will cover the registration and resetting password functionality #25

Merged
merged 83 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
23b55af
give a choice on database settings
anjaniacatus Nov 18, 2024
b2303c3
Merge branch 'main' into registration_feat_bis
anjaniacatus Nov 18, 2024
3fc6f2a
add django extensions to list urls
anjaniacatus Nov 18, 2024
1b60b62
activate forgot_password and register link
anjaniacatus Nov 19, 2024
a4a92c4
add register form
anjaniacatus Nov 19, 2024
37840aa
email template sample
anjaniacatus Nov 19, 2024
583743e
reset_password wip
anjaniacatus Nov 19, 2024
a62f0d4
reset_password functional
anjaniacatus Nov 19, 2024
327cbb7
reset_password functional
anjaniacatus Nov 19, 2024
c753c11
.
anjaniacatus Nov 19, 2024
79b21c8
typo
anjaniacatus Nov 19, 2024
3b19f93
we don't need to rewrite the reset_password_view
anjaniacatus Nov 19, 2024
1e1ed45
cleaning code
anjaniacatus Nov 19, 2024
6df1a6a
setting up test for authentication
anjaniacatus Nov 20, 2024
c016b9e
fix registration feat
anjaniacatus Nov 20, 2024
64ac6f8
display flash message
anjaniacatus Nov 20, 2024
9eccddd
.
anjaniacatus Nov 20, 2024
608de39
setting up registration unit test
anjaniacatus Nov 20, 2024
e7d8b72
register unit test
anjaniacatus Nov 20, 2024
50a2e8a
unit test for resetting pasword wip
anjaniacatus Nov 21, 2024
32a0bd7
use code coverage to write test
anjaniacatus Nov 21, 2024
bbbb62c
unit test : resetting password
anjaniacatus Nov 21, 2024
88c8794
use a method for sending email registation
anjaniacatus Nov 27, 2024
94b6dad
review url
anjaniacatus Nov 27, 2024
54031ca
we don't need to fix the url
anjaniacatus Nov 27, 2024
825e9ef
Merge branch 'main' into registration_feat_bis
anjaniacatus Nov 27, 2024
1a5eb00
use pytest for testing
anjaniacatus Nov 27, 2024
7d19e19
use pytest for testing
anjaniacatus Nov 27, 2024
dd7c680
.
anjaniacatus Nov 27, 2024
09fe246
add unit test
anjaniacatus Nov 28, 2024
2713a16
setting up allauth
anjaniacatus Nov 28, 2024
8ba504d
setting up allauth template
anjaniacatus Nov 29, 2024
7556bb2
setting up allauth template : reset password
anjaniacatus Nov 29, 2024
d44f704
add allauth in requirements
anjaniacatus Nov 29, 2024
b9ff79e
cleaning code, fix test
anjaniacatus Nov 29, 2024
1221b88
.
anjaniacatus Nov 30, 2024
0d7bc92
add allauth
anjaniacatus Nov 30, 2024
405b7b6
add django-extensions
anjaniacatus Nov 30, 2024
e3fab5d
override template for confirming email after signing up
anjaniacatus Nov 30, 2024
740316b
remove unused template
anjaniacatus Nov 30, 2024
da35abb
typo
anjaniacatus Nov 30, 2024
29d6e54
update template change password
anjaniacatus Dec 1, 2024
36bbe94
username is not used
anjaniacatus Dec 1, 2024
7c8ceb2
cleaning unsede template
anjaniacatus Dec 1, 2024
04270e7
update logout link to use all-auth
anjaniacatus Dec 1, 2024
0a332ef
fix pipeline : role 'pguser' does not exist
anjaniacatus Dec 2, 2024
2952408
Revert "fix pipeline : role 'pguser' does not exist"
anjaniacatus Dec 2, 2024
439241d
fix the right file
anjaniacatus Dec 2, 2024
39b83d3
.
anjaniacatus Dec 2, 2024
92892ef
.
anjaniacatus Dec 2, 2024
6736ef7
fix db name
anjaniacatus Dec 2, 2024
e4ce1cb
fix db name
anjaniacatus Dec 2, 2024
d0dab7a
fix db name for dev and test environnement
anjaniacatus Dec 2, 2024
f67dcbe
debugging workflow
anjaniacatus Dec 2, 2024
c619e39
debugging workflow
anjaniacatus Dec 2, 2024
988f2ac
.
anjaniacatus Dec 2, 2024
beb99e5
.
anjaniacatus Dec 2, 2024
381ca55
bug fix
anjaniacatus Dec 2, 2024
ab61824
fix postgres db user
anjaniacatus Dec 2, 2024
4646ce0
typo
anjaniacatus Dec 2, 2024
c09a6fb
upgrade postgres image
anjaniacatus Dec 2, 2024
556f7f4
fix Missing staticfiles manifest
anjaniacatus Dec 2, 2024
e288a32
no need to change this
anjaniacatus Dec 3, 2024
d59c807
sticky footer
anjaniacatus Dec 3, 2024
0f50ada
update login page
anjaniacatus Dec 9, 2024
1da6490
fix merge conflict
anjaniacatus Dec 9, 2024
da0b566
review
anjaniacatus Dec 14, 2024
cd70773
fix : conflict from merging main
anjaniacatus Dec 14, 2024
d4ff91f
bug fix
anjaniacatus Dec 14, 2024
bec5bd3
.
anjaniacatus Dec 15, 2024
e6e3731
fix database parameters
anjaniacatus Dec 15, 2024
4e8e2b4
.
anjaniacatus Dec 15, 2024
c0b2d53
we don't need to display message when logged in or logged out : its o…
anjaniacatus Dec 15, 2024
20c4bde
automatiquely logged out when the link is redirect to logout
anjaniacatus Dec 15, 2024
dd7aab0
activate login/logout link
anjaniacatus Dec 15, 2024
8dc4b89
review test
anjaniacatus Dec 16, 2024
d4ca317
.
anjaniacatus Dec 16, 2024
e5958de
review done
anjaniacatus Dec 17, 2024
9c05dff
,
anjaniacatus Dec 17, 2024
31cb1cd
cleaning code
anjaniacatus Dec 19, 2024
ce025ed
add button design
anjaniacatus Dec 19, 2024
bf9d0d4
use the right word as displayed on figma
anjaniacatus Dec 19, 2024
15c83ce
format code :(
anjaniacatus Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: CodeCov
on: [push, pull_request]

Expand All @@ -17,11 +16,11 @@ jobs:

services:
postgres:
image: postgres:10.8
image: postgres:12
env:
DB_USER: postgres
DB_PASSWORD: postgres
DB_NAME: djangocon_africa
POSTGRES_USER: pguser
POSTGRES_PASSWORD: password
POSTGRES_DB: db
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
Expand All @@ -39,12 +38,13 @@ jobs:
- name: Generate Report
run: |
pip install -r requirements.txt
python manage.py collectstatic
coverage run -m pytest
coverage xml
env:
DB_NAME: djangocon_africa
DB_HOST: localhost
DB_PASSWORD: postgres
DB_USER: postgres
POSTGRES_DB: db
POSTGRES_USER: pguser
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: password
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
34 changes: 30 additions & 4 deletions core/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"template_partials",
"crispy_forms",
"crispy_tailwind",
"website",
"custom_auth",
"proposals",
"custom_auth",
"allauth",
"allauth.account",
]

MIDDLEWARE = [
Expand All @@ -41,6 +44,7 @@
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

Expand Down Expand Up @@ -129,9 +133,6 @@

CRISPY_TEMPLATE_PACK = "tailwind"

# django.contrib.auth settings
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
Expand All @@ -141,3 +142,28 @@
DB_PASSWORD = os.environ.get("DATABASE_PASSWORD")
DB_NAME = os.environ.get("DATABASE_NAME")
DB_PORT = os.environ.get("DATABASE_PORT", 5432)

# django-allauth configurations
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
]

ACCOUNT_FORMS = {
'signup': 'custom_auth.forms.CustomSignupForm',
}

SITE_ID = 1 # new
ACCOUNT_EMAIL_VERIFICATION = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 1
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_LOGOUT_REDIRECT_URL ='/accounts/login/'
LOGIN_REDIRECT_URL = "/"
ACCOUNT_LOGIN_ON_PASSWORD_RESET = True #logged automatiquely when success
ACCOUNT_LOGOUT_ON_GET = True
5 changes: 5 additions & 0 deletions core/settings_dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .settings_base import * # noqa: F403
from .settings_base import BASE_DIR
import dj_database_url

SECRET_KEY = "not really a secret"
Expand All @@ -11,6 +12,7 @@
INSTALLED_APPS += [ # noqa: F405
"django_browser_reload",
"whitenoise.runserver_nostatic",
"django_extensions",
]


Expand All @@ -32,3 +34,6 @@
default=f"postgres://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
)
}

EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = BASE_DIR / "emails"
12 changes: 12 additions & 0 deletions core/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@
default=f"postgres://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" # noqa: F405
)
}


# email config - to be setted in another feature
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = BASE_DIR / 'emails'

Check failure on line 22 in core/settings_prod.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

core/settings_prod.py:22:19: F405 `BASE_DIR` may be undefined, or defined from star imports

# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# EMAIL_HOST = 'smtp.gmail.com'
# EMAIL_USE_TLS = True
# EMAIL_PORT = 587
# EMAIL_HOST_USER = str(os.getenv('EMAIL_USER'))
# EMAIL_HOST_PASSWORD = str(os.getenv('EMAIL_PASSWORD'))
3 changes: 2 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
from django.contrib import admin
from django.urls import path, include


urlpatterns = [
path("", include("website.urls")),
path("accounts/", include("allauth.urls")),
path("proposals/", include("proposals.urls")),
path("accounts/", include("django.contrib.auth.urls")),
path("admin/", admin.site.urls),
path("__reload__/", include("django_browser_reload.urls")),
]
15 changes: 15 additions & 0 deletions custom_auth/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django import forms
from allauth.account.forms import SignupForm


class CustomSignupForm(SignupForm):
first_name = forms.CharField(max_length=30, label='First Name')
last_name = forms.CharField(max_length=30, label='Last Name')
email = forms.EmailField()

def signup(self, request, user):
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
user.email = self.cleaned_data['email']
user.save()
return user
2 changes: 2 additions & 0 deletions custom_auth/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
urlpatterns = [
]
4 changes: 2 additions & 2 deletions custom_auth/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# from django.shortcuts import render

# Create your views here.


6 changes: 3 additions & 3 deletions proposals/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.2.13 on 2024-12-10 14:29
# Generated by Django 5.1.3 on 2024-12-15 15:22

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down Expand Up @@ -42,9 +42,9 @@ class Migration(migrations.Migration):
('audience_level', models.CharField(choices=[('b', 'Beginner - just starting'), ('i', 'Intermediate'), ('a', 'Advanced'), ('n', 'Non technical talk')])),
('accessibility_requests', models.TextField(blank=True, null=True)),
('status', models.CharField(choices=[('submitted', 'Submitted'), ('rejected', 'Rejected'), ('accepted', 'Accepted'), ('shortlisted', 'Shortlisted'), ('backup', 'Backup')], default='submitted')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('proposal_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='proposals.proposaltype')),
('track', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='proposals.track')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
1 change: 1 addition & 0 deletions requirements.dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django-extensions>=3.2.3
8 changes: 5 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
django>=4.2,<5
django>=4.2,<=5
coverage==7.5.3
dj-database-url==2.2.0
psycopg2-binary==2.9.9
python-dotenv==1.0.1
pytest==8.2.2
pytest==8.3.3
pytest-django==4.8.0
pytest-dotenv==0.5.2
django-browser-reload==1.16.0
django-template-partials==24.4
whitenoise==6.8.2
django-allauth==65.2.0
django-extensions>=3.2.0
crispy-tailwind==1.0.3
django-template-partials==24.4
django-template-partials==24.4
11 changes: 9 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,32 @@
asgiref==3.8.1
# via
# django
# django-allauth
# django-browser-reload
coverage==7.5.3
# via -r requirements.in
crispy-tailwind==1.0.3
# via -r requirements.in
dj-database-url==2.2.0
# via -r requirements.in
django==4.2.13
django==4.2.16
# via
# -r requirements.in
# crispy-tailwind
# dj-database-url
# django-allauth
# django-browser-reload
# django-crispy-forms
# django-extensions
# django-template-partials
django-allauth==65.2.0
# via -r requirements.in
django-browser-reload==1.16.0
# via -r requirements.in
django-crispy-forms==2.3
# via crispy-tailwind
django-extensions==3.2.3
# via -r requirements.in
django-template-partials==24.4
# via -r requirements.in
iniconfig==2.0.0
Expand All @@ -36,7 +43,7 @@ pluggy==1.5.0
# via pytest
psycopg2-binary==2.9.9
# via -r requirements.in
pytest==8.2.2
pytest==8.3.3
# via
# -r requirements.in
# pytest-django
Expand Down
33 changes: 9 additions & 24 deletions templates/_base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load static %}

{% load tailwind_filters %}
{% load partials %}

{% partialdef header-menu-item-large %}
Expand All @@ -22,7 +23,7 @@
style="display: none;">

{% for child in link.children %}
<a href="{{ child.href }}" class="header_button">{{ child.label }}</a>
<a href="{{ child.href }}" class="header_button">{{ child.label }}</a>
{% endfor %}

</div>
Expand All @@ -33,7 +34,6 @@


<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down Expand Up @@ -63,45 +63,30 @@
{% for link in header_menu_items %}
{% partial header-menu-item-large %}
{% endfor %}

<!--

{% if user.is_authenticated %}
{% with link=user_loggedin_link %}
{% partial header-menu-item-large %}
{% endwith %}
{% with link=user_loggedin_link %}
{% partial header-menu-item-large %}
{% endwith %}
{% else %}

{% with link=user_not_loggedin_link %}
{% partial header-menu-item-large %}
{% endwith %}

{% with link=user_not_loggedin_link %}
{% partial header-menu-item-large %}
{% endwith %}
{% endif %}
-->

</div>
</div>

</div>
</nav>
<section class="max-w-7xl mx-auto pt-14">
{% block content %}



{% endblock %}

<section class="bg-darkPrimary text-white text-2xl text-center py-8">

<a target="_blank" href="https://x.com/djcafrica"><i class="fab fa-twitter"></i></a>
<a target="_blank" href="https://github.com/djangocon/2025.djangocon.africa"><i
class="fab fa-github"></i></a>
<a target="_blank" href="https://fosstodon.org/@djangoconafrica"><i class="fab fa-mastodon"></i></a>
<a target="_blank" href="https://www.facebook.com/djcafrica/"><i class="fab fa-facebook"></i></a>

</section>
</section>

</body>

</html>
</html>
14 changes: 14 additions & 0 deletions templates/account/account_inactive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "_base.html" %}
{% load i18n %}
{% load allauth %}
{% block head_title %}
{% translate "Account Inactive" %}
{% endblock head_title %}
{% block content %}
{% element h1 %}
{% translate "Account Inactive" %}
{% endelement %}
{% element p %}
{% translate "This account is inactive." %}
{% endelement %}
{% endblock content %}
13 changes: 13 additions & 0 deletions templates/account/email/account_already_exists_message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "account/email/base_message.txt" %}
{% load i18n %}

{% block content %}{% autoescape off %}{% blocktrans %}You are receiving this email because you or someone else tried to signup for an
account using email address:

{{ email }}

However, an account using that email address already exists. In case you have
forgotten about this, please use the password forgotten procedure to recover
your account:

{{ password_reset_url }}{% endblocktrans %}{% endautoescape %}{% endblock content %}
4 changes: 4 additions & 0 deletions templates/account/email/account_already_exists_subject.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Account Already Exists{% endblocktrans %}
{% endautoescape %}
7 changes: 7 additions & 0 deletions templates/account/email/base_message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name %}Hello from {{ site_name }}!{% endblocktrans %}

{% block content %}{% endblock content %}

{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
{% endautoescape %}
14 changes: 14 additions & 0 deletions templates/account/email/base_notification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "account/email/base_message.txt" %}
{% load account %}
{% load i18n %}

{% block content %}{% autoescape off %}{% blocktrans %}You are receiving this mail because the following change was made to your account:{% endblocktrans %}

{% block notification_message %}
{% endblock notification_message%}

{% blocktrans %}If you do not recognize this change then please take proper security precautions immediately. The change to your account originates from:

- IP address: {{ip}}
- Browser: {{user_agent}}
- Date: {{timestamp}}{% endblocktrans %}{% endautoescape %}{% endblock %}
Loading
Loading