Adds origin to the user to indicate where the account comes from

bracket-feature
Laurent 10 months ago
parent 19d8c26869
commit 3e748ed428
  1. 2
      api/serializers.py
  2. 2
      tournaments/admin.py
  3. 18
      tournaments/migrations/0107_customuser_origin.py
  4. 2
      tournaments/models/__init__.py
  5. 4
      tournaments/models/custom_user.py
  6. 5
      tournaments/models/enums.py
  7. 3
      tournaments/views.py

@ -13,6 +13,7 @@ from api.tokens import account_activation_token
from shared.cryptography import encryption_util
from tournaments.models.draw_log import DrawLog
from tournaments.models.enums import UserOrigin
class EncryptedUserField(serializers.Field):
def to_representation(self, value):
@ -69,6 +70,7 @@ class UserSerializer(serializers.ModelSerializer):
group_stage_match_format_preference=validated_data.get('group_stage_match_format_preference'),
loser_bracket_match_format_preference=validated_data.get('loser_bracket_match_format_preference'),
loser_bracket_mode=validated_data.get('loser_bracket_mode'),
origin=UserOrigin.APP,
)
self.send_email(self.context['request'], user)

@ -27,7 +27,7 @@ class CustomUserAdmin(UserAdmin):
'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', 'group_stage_match_format_preference',
'loser_bracket_match_format_preference', 'device_id', 'loser_bracket_mode', 'groups'
'loser_bracket_match_format_preference', 'device_id', 'loser_bracket_mode', 'groups', 'origin'
]}),
]
add_fieldsets = [

@ -0,0 +1,18 @@
# Generated by Django 5.1 on 2025-01-28 07:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tournaments', '0106_alter_customuser_licence_id'),
]
operations = [
migrations.AddField(
model_name='customuser',
name='origin',
field=models.IntegerField(blank=True, choices=[(0, 'Admin'), (1, 'Site'), (2, 'App')], default=0, null=True),
),
]

@ -2,7 +2,7 @@ from .custom_user import CustomUser
from .club import Club
from .court import Court
from .date_interval import DateInterval
from .enums import TournamentPayment, FederalCategory, FederalLevelCategory, FederalAgeCategory, FederalMatchCategory, OnlineRegistrationStatus
from .enums import UserOrigin, TournamentPayment, FederalCategory, FederalLevelCategory, FederalAgeCategory, FederalMatchCategory, OnlineRegistrationStatus
from .player_enums import PlayerSexType, PlayerDataSource, PlayerPaymentType
from .event import Event
from .tournament import Tournament, TeamSummon, TeamSortingType, TeamItem

@ -32,6 +32,8 @@ class CustomUser(AbstractUser):
device_id = models.CharField(max_length=50, null=True, blank=True)
loser_bracket_mode = models.IntegerField(default=0)
origin = models.IntegerField(default=enums.UserOrigin.ADMIN, choices=enums.UserOrigin.choices, null=True, blank=True)
### ### ### ### ### ### ### ### ### ### ### WARNING ### ### ### ### ### ### ### ### ### ###
### WARNING : Any added field MUST be inserted in the method below: fields_for_update() ###
### ### ### ### ### ### ### ### ### ### ### WARNING ### ### ### ### ### ### ### ### ### ###
@ -43,7 +45,7 @@ class CustomUser(AbstractUser):
'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',
'group_stage_match_format_preference', 'loser_bracket_match_format_preference', 'device_id', 'loser_bracket_mode']
'group_stage_match_format_preference', 'loser_bracket_match_format_preference', 'device_id', 'loser_bracket_mode', 'origin']
def __str__(self):
return self.username

@ -1,6 +1,11 @@
from django.db import models
import uuid
class UserOrigin(models.IntegerChoices):
ADMIN = 0, 'Admin'
SITE = 1, 'Site'
APP = 2, 'App'
class TournamentPayment(models.IntegerChoices):
FREE = 0, 'Gratuit'
UNIT = 1, 'Unité'

@ -14,7 +14,7 @@ from django.core.files.base import ContentFile
from tournaments.models.device_token import DeviceToken
from .models import Court, DateInterval, Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration, Purchase, FailedApiCall
from .models import Court, DateInterval, Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration, Purchase, FailedApiCall, UserOrigin
from .models import TeamSummon
from datetime import datetime, timedelta
import time
@ -627,6 +627,7 @@ def signup(request):
if form.is_valid():
user = form.save(commit=False)
user.is_active = False
user.origin = UserOrigin.SITE
user.save()
send_verification_email(request, user, next_url)

Loading…
Cancel
Save