2018-05-06 10:50:53 +00:00
|
|
|
from allauth.account.adapter import DefaultAccountAdapter
|
2018-06-10 08:55:16 +00:00
|
|
|
from django.conf import settings
|
2018-02-24 11:20:42 +00:00
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
2017-06-23 21:00:42 +00:00
|
|
|
|
|
|
|
|
2019-04-23 09:14:58 +00:00
|
|
|
def get_email_context():
|
|
|
|
context = {}
|
|
|
|
context["funkwhale_url"] = settings.FUNKWHALE_URL
|
|
|
|
manager = global_preferences_registry.manager()
|
|
|
|
context["funkwhale_site_name"] = (
|
|
|
|
manager["instance__name"] or settings.FUNKWHALE_HOSTNAME
|
|
|
|
)
|
|
|
|
context["funkwhale_site_domain"] = settings.FUNKWHALE_HOSTNAME
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
2017-06-23 21:00:42 +00:00
|
|
|
class FunkwhaleAccountAdapter(DefaultAccountAdapter):
|
|
|
|
def is_open_for_signup(self, request):
|
2018-02-24 11:20:42 +00:00
|
|
|
manager = global_preferences_registry.manager()
|
2018-06-09 13:36:16 +00:00
|
|
|
return manager["users__registration_enabled"]
|
2018-05-06 10:50:53 +00:00
|
|
|
|
|
|
|
def send_mail(self, template_prefix, email, context):
|
2019-04-23 09:14:58 +00:00
|
|
|
context.update(get_email_context())
|
2018-05-06 10:50:53 +00:00
|
|
|
return super().send_mail(template_prefix, email, context)
|