Debian Codegraph @

django_mailman3/views/user_adapter.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2021-2023 by the Free Software Foundation, Inc.
3 #
4 # This file is part of Django-Mailman.
5 #
6 # Django-Mailman3 is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option) any
9 # later version.
10 #
11 # Django-Mailman3 is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Django-Mailman. If not, see <http://www.gnu.org/licenses/>.
18
19
20 from allauth.account.adapter import DefaultAccountAdapter
21 from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
22
23
24 class DisableSignupAdapter(DefaultAccountAdapter):
25 """Account adapter that disables signups.
26
27 To use this, just set this in your settings.py::
28
29 ACCOUNT_ADAPTER = \
30 'django_mailman3.views.user_adapter.DisableSignupAdapter'
31 """
32
33 def is_open_for_signup(self, req):
34 return False
35
36
37 class EnableSocialSignupAdapter(DefaultSocialAccountAdapter):
38 """Social account adapter that enables social signup even when the
39 regular signup is disabled.
40
41 To use this, just set this in your settings.py::
42
43 SOCIALACCOUNT_ADAPTER = \
44 'django_mailman3.views.user_adapter.EnableSocialSignupAdapter'
45 """
46
47 def is_open_for_signup(self, req, socialaccount):
48 return True
49
50
51 class DisableSocialSignupAdapter(DefaultSocialAccountAdapter):
52 """Social account adapter that disables signup.
53
54 To use this, just set this in your settings.py::
55
56 SOCIALACCOUNT_ADAPTER = \
57 'django_mailman3.views.user_adapter.DisableSocialSignupAdapter'
58 """
59
60 def is_open_for_signup(self, req, socialaccount):
61 return False