diff --git a/src/contestadmin/views.py b/src/contestadmin/views.py index 444a6282..efc0eb90 100644 --- a/src/contestadmin/views.py +++ b/src/contestadmin/views.py @@ -496,13 +496,13 @@ def contest_statistics(request): # LFG Divisions card data context['num_upper_lfg_profiles'] = LFGProfile.objects.filter( - division=1).count() + user__profile__passed_cop3330=True).count() context['num_upper_lfg_profiles_active'] = LFGProfile.objects.filter( - division=1).filter(active=True).count() + user__profile__passed_cop3330=True).filter(active=True).count() context['num_lower_lfg_profiles'] = LFGProfile.objects.filter( - division=2).count() + user__profile__passed_cop3330=False).count() context['num_lower_lfg_profiles_active'] = LFGProfile.objects.filter( - division=2).filter(active=True).count() + user__profile__passed_cop3330=False).filter(active=True).count() # Course card data context['courses'] = Course.objects.all() diff --git a/src/core/views.py b/src/core/views.py index b63855c7..741ff903 100644 --- a/src/core/views.py +++ b/src/core/views.py @@ -48,8 +48,8 @@ def get_context_data(self, **kwargs): if context['contest'] and context['contest'].lfg_active: # Get Looking For Group profile totals - context['lfg_profiles_upper'] = LFGProfile.objects.filter(active=True).filter(division=1).count() - context['lfg_profiles_lower'] = LFGProfile.objects.filter(active=True).filter(division=2).count() + context['lfg_profiles_upper'] = LFGProfile.objects.filter(active=True).filter(user__profile__passed_cop3330=True).count() + context['lfg_profiles_lower'] = LFGProfile.objects.filter(active=True).filter(user__profile__passed_cop3330=False).count() ### Teams ### diff --git a/src/lfg/forms.py b/src/lfg/forms.py index 0eaf4785..8ec99510 100644 --- a/src/lfg/forms.py +++ b/src/lfg/forms.py @@ -21,23 +21,18 @@ class ProfileForm(forms.ModelForm): class Meta: model = LFGProfile - fields = ('discord_username', 'discord_discriminator', 'division', 'standing') + fields = ('discord_username', 'division', 'standing') labels = { 'discord_username': 'Discord Username', - 'discord_discriminator': 'Discord Discriminator', 'division': 'Preferred Division', 'standing': 'Standing', } help_texts = { - 'discord_username': 'Your username before the #.', - 'discord_discriminator': 'The number after the #.', + 'discord_username': 'Your username.', 'division': 'The division in which you intend to compete.', } error_messages = { 'discord_username': { 'max_length': "The username entered is too long.", }, - 'discord_discriminator': { - 'max_length': "The discriminator entered is too long.", - }, } diff --git a/src/lfg/migrations/0004_remove_discordmember_discriminator_and_more.py b/src/lfg/migrations/0004_remove_discordmember_discriminator_and_more.py new file mode 100644 index 00000000..1317f4bf --- /dev/null +++ b/src/lfg/migrations/0004_remove_discordmember_discriminator_and_more.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.26 on 2026-03-09 18:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lfg', '0003_auto_20220904_0319'), + ] + + operations = [ + migrations.RemoveField( + model_name='discordmember', + name='discriminator', + ), + migrations.RemoveField( + model_name='lfgprofile', + name='discord_discriminator', + ), + ] diff --git a/src/lfg/models.py b/src/lfg/models.py index 9254fa9d..d4707616 100644 --- a/src/lfg/models.py +++ b/src/lfg/models.py @@ -8,40 +8,26 @@ class DiscordMember(models.Model): Discord user model which stores the username and discriminator of a full Discord username. - *** IMPORTANT Dec 2023 *** Discord has updated their username format and - no longer utilizes discriminators. This model MUST be updated to support - the new format. + Updated to reflect new Discord username rules - username (CharField): the username portion of the full Discord username (before the #) + username (CharField): the Discord username (@username) - discriminator (SmallIntegerField): the numerical portion of the full Discord username (after the #) """ username = models.CharField(max_length=32) - discriminator = models.SmallIntegerField() def __str__(self): - return (str(self.username)+'#'+str(self.discriminator).zfill(4)) + return (str(self.username)) class LFGProfile(models.Model): """ Looking For Group Profile model. Each instance is tied to a single contestant. - *** IMPORTANT Dec 2023 *** Discord has updated their username format and - no longer utilizes discriminators. This model MUST be updated to support - the new format. - - discord_username - discord_discriminator - *** - user (OneToOneField): the user instance attached to an LFG profile discord_username (CharField): the username portion of the full Discord username (before the #) - discord_discriminator (SmallIntegerField): the numerical portion of the full Discord username (after the #) - division (PositiveSmallIntegerField): division in which a contestant wants to compete with choices defined in LFGProfile.DIVISION standing (PositiveSmallIntegerField): participant's collegiate standing as with choices defined in LFGProfile.STANDING @@ -72,7 +58,7 @@ class LFGProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) discord_username = models.CharField(max_length=32) - discord_discriminator = models.SmallIntegerField(validators=[MinValueValidator(0), MaxValueValidator(9999)]) + # discord_discriminator = models.SmallIntegerField(validators=[MinValueValidator(0), MaxValueValidator(9999)]) division = models.PositiveSmallIntegerField( choices=DIVISION, blank=True, null=True) standing = models.PositiveSmallIntegerField( @@ -89,7 +75,7 @@ def get_discord_username(self): Returns the full Discord username of a LFGProfile. """ - return str(self.discord_username)+'#'+str(self.discord_discriminator).zfill(4) + return f"@{self.discord_username}" def is_completed(self): """ diff --git a/src/lfg/templates/lfg/dashboard.html b/src/lfg/templates/lfg/dashboard.html index d4353df8..4ecb1075 100644 --- a/src/lfg/templates/lfg/dashboard.html +++ b/src/lfg/templates/lfg/dashboard.html @@ -40,7 +40,6 @@