Adds signals for user creation

clubs
Laurent 1 year ago
parent 9f42696283
commit 9d30c624a7
  1. 6
      tournaments/models/custom_user.py
  2. 3
      tournaments/models/failed_api_call.py
  3. 6
      tournaments/signals.py

@ -37,9 +37,13 @@ class CustomUser(AbstractUser):
# returns the list of fields to update without password # returns the list of fields to update without password
return ['id', 'username', 'email', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name', return ['id', 'username', 'email', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name',
'licence_id', 'country', 'licence_id', 'country',
'summons_message_body', 'summons_message_signature', 'summons_available_payment_methods', 'summons_display_format', 'summons_display_entry_fee', 'summons_message_body', 'summons_message_signature', 'summons_available_payment_methods',
'summons_display_format', 'summons_display_entry_fee',
'summons_use_full_custom_message', 'match_formats_default_duration', 'bracket_match_format_preference', 'summons_use_full_custom_message', 'match_formats_default_duration', 'bracket_match_format_preference',
'group_stage_match_format_preference', 'loser_bracket_match_format_preference'] 'group_stage_match_format_preference', 'loser_bracket_match_format_preference']
def __str__(self): def __str__(self):
return self.username
def discord_string(self):
return f"{self.username} : {self.first_name} {self.last_name} | {self.email} | {self.phone}" return f"{self.username} : {self.first_name} {self.last_name} | {self.email} | {self.phone}"

@ -17,3 +17,6 @@ class FailedApiCall(models.Model):
return f"{datetime} | {self.user.username} | {self.type} : {self.error}" return f"{datetime} | {self.user.username} | {self.type} : {self.error}"
else: else:
return f"{datetime} | {self.type} : {self.error}" return f"{datetime} | {self.type} : {self.error}"
def discord_string(self):
return str(self)

@ -32,9 +32,9 @@ def notify_user_creation_on_discord(sender, instance, created, **kwargs):
def notify_object_creation_on_discord(created, instance): def notify_object_creation_on_discord(created, instance):
if created: if created:
default_db_engine = settings.DATABASES['default']['ENGINE'] # default_db_engine = settings.DATABASES['default']['ENGINE']
if default_db_engine != 'django.db.backends.sqlite3': # if default_db_engine != 'django.db.backends.sqlite3':
message = f'New {instance.__class__.__name__} created: {instance}' message = f'New {instance.__class__.__name__} created: {instance.discord_string()}'
send_discord_message(DISCORD_WEBHOOK_URL, message) send_discord_message(DISCORD_WEBHOOK_URL, message)
def send_discord_message(webhook_url, content): def send_discord_message(webhook_url, content):

Loading…
Cancel
Save