Merge pull request 'Upgrade to 3.12' (#630) from python-3.12 into main
[inboxen.git] / inboxen / signals.py
blob1e7cdac5b91e5c1dd53814a70353f423d6a7eda2
1 ##
2 # Copyright (C) 2013, 2014, 2015 Jessica Tallon & Matt Molyneaux
4 # This file is part of Inboxen.
6 # Inboxen is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Inboxen is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Inboxen. If not, see <http://www.gnu.org/licenses/>.
20 from django.conf import settings
21 from django.contrib import messages
23 from inboxen.models import Liberation, UserProfile
26 def logout_message(sender, request, **kwargs):
27 msg = getattr(request, "_logout_message", settings.LOGOUT_MSG)
28 messages.add_message(request, messages.INFO, msg, fail_silently=True)
31 def populate_user_one_to_one_fields(sender, instance, created, **kwargs):
32 if not created:
33 return
35 Liberation.objects.get_or_create(user=instance)
36 UserProfile.objects.get_or_create(user=instance)