make mehtod name mandatory

This commit is contained in:
Matthias 2021-12-04 01:07:07 +01:00
parent 0f3a78c7be
commit e18f7d49cc
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -1,7 +1,7 @@
import logging import logging
from datetime import timedelta from datetime import timedelta
from django.conf import settings
from django.conf import settings
from django.template.loader import render_to_string from django.template.loader import render_to_string
from allauth.account.models import EmailAddress from allauth.account.models import EmailAddress
@ -24,6 +24,10 @@ class NotificationMethod:
if (not hasattr(self, 'send')) and (not hasattr(self, 'send_bulk')): if (not hasattr(self, 'send')) and (not hasattr(self, 'send_bulk')):
raise NotImplementedError('A NotificationMethod must either define a `send` or a `send_bulk` method') raise NotImplementedError('A NotificationMethod must either define a `send` or a `send_bulk` method')
# No method name is no good
if self.METHOD_NAME in ('', None):
raise NotImplementedError(f'The NotificationMethod {self.__class__} did not provide a METHOD_NAME')
# Define arguments # Define arguments
self.obj = obj self.obj = obj
self.entry_name = entry_name self.entry_name = entry_name