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

#212 account updated signal #385

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 11 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ jobs:
with:
python-version: "3.11"

- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Lint with ruff
run: |
ruff --format=github --target-version=py311 account
uses: chartboost/ruff-action@v1
with:
src: "./account"
version: 0.1.11
args: --target-version=py311

test:
name: Testing
Expand All @@ -32,12 +30,18 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
django:
- "3.2.*"
- "4.2.*"
- "5.0.*"
exclude:
- python: "3.11"
django: "3.2.*"
- python: "3.8"
django: "5.0.*"
- python: "3.9"
django: "5.0.*"

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions account/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import django.dispatch


user_signed_up = django.dispatch.Signal()
user_sign_up_attempt = django.dispatch.Signal()
user_logged_in = django.dispatch.Signal()
Expand All @@ -10,3 +11,4 @@
email_confirmation_sent = django.dispatch.Signal()
password_changed = django.dispatch.Signal()
password_expired = django.dispatch.Signal()
account_updated = django.dispatch.Signal()
6 changes: 5 additions & 1 deletion account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def send_email_confirmation(self, email_address):
email_address.send_confirmation(site=get_current_site(self.request))

def after_signup(self, form):
signals.user_signed_up.send(sender=SignupForm, user=self.created_user, form=form)
signals.user_signed_up.send(sender=SignupForm, user=self.created_user, form=form, request=self.request)

def login_user(self):
user = auth.authenticate(**self.user_credentials())
Expand Down Expand Up @@ -796,6 +796,10 @@ def form_valid(self, form):
def update_settings(self, form):
self.update_email(form)
self.update_account(form)
self.after_update_account()

def after_update_account(self):
signals.account_updated.send(sender=SettingsView, user=self.request.user, request=self.request)

def update_email(self, form, confirm=None):
user = self.request.user
Expand Down
11 changes: 9 additions & 2 deletions docs/signals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ user_signed_up
--------------

Triggered when a user signs up successfully. Providing arguments ``user``
(User instance) and ``form`` (form instance) as arguments.
(User instance), ``form`` (form instance), and ``request`` as arguments.


user_sign_up_attempt
Expand Down Expand Up @@ -73,4 +73,11 @@ password_expired
----------------

Triggered when a user password is expired. Providing argument ``user``
(User instance).
(User instance).


account_updated
---------------

Triggered when a user updates their account. Provided ``user`` and ``request``
as arguments.
Loading