Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/contestadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

Expand Down
9 changes: 2 additions & 7 deletions src/lfg/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
}
Original file line number Diff line number Diff line change
@@ -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',
),
]
24 changes: 5 additions & 19 deletions src/lfg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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):
"""
Expand Down
5 changes: 2 additions & 3 deletions src/lfg/templates/lfg/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h1 class="text-center">Looking For Group</h1>
{% if user.lfgprofile %}
<ul class="list-group list-group-flush">
<li class="list-group-item"><span class="font-weight-bolder">Discord Username:</span> {{ user.lfgprofile.discord_username }}</li>
<li class="list-group-item"><span class="font-weight-bolder">Discord Discriminator:</span> {{ user.lfgprofile.discord_discriminator }}</li>
<li class="list-group-item"><span class="font-weight-bolder">Preferred Division:</span> {{ divisions | return_item:user.lfgprofile.division }}</li>
{% if user.lfgprofile.is_completed %}
{% if user.lfgprofile.verified %}
Expand Down Expand Up @@ -101,7 +100,7 @@ <h1 class="text-center">Looking For Group</h1>
<div class="row mt-4">
<!-- Upper Division Table -->
<div class="col">
<h3>Preferred Division - Upper</h3>
<h3>Upper Division <small class="text-muted">(Passed COP3330)</small></h3>
<button type="button" class="btn btn-sm btn-info" disabled>
<i class="fa-solid fa-user"></i> Participants <span class="badge badge-light">{{ lfg_upper_count }}</span>
<span class="sr-only">number of lower division participants</span>
Expand Down Expand Up @@ -147,7 +146,7 @@ <h3>Preferred Division - Upper</h3>
<div class="row">
<!-- Lower Division Table -->
<div class="col">
<h3>Preferred Division - Lower</h3>
<h3>Lower Division <small class="text-muted">(Has not passed COP3330)</small></h3>
<button type="button" class="btn btn-sm btn-info" disabled>
<i class="fa-solid fa-user"></i> Participants <span class="badge badge-light">{{ lfg_lower_count }}</span>
<span class="sr-only">number of lower division participants</span>
Expand Down
6 changes: 3 additions & 3 deletions src/lfg/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def dashboard(request):
context['divisions'] = {division[0]:division[1] for division in LFGProfile.DIVISION}
# Gather LFG profiles by division
context['lfg_upper'] = cache.get_or_set(
'lfg_dash_users_upper', LFGProfile.objects.filter(active=True).filter(division=1), CACHE_TIMEOUT)
'lfg_dash_users_upper', LFGProfile.objects.filter(active=True).filter(user__profile__passed_cop3330=True), CACHE_TIMEOUT)
context['lfg_lower'] = cache.get_or_set(
'lfg_dash_users_lower', LFGProfile.objects.filter(active=True).filter(division=2), CACHE_TIMEOUT)
'lfg_dash_users_lower', LFGProfile.objects.filter(active=True).filter(user__profile__passed_cop3330=False), CACHE_TIMEOUT)
# LFG Profile counts
context['lfg_upper_count'] = context['lfg_upper'].count()
context['lfg_lower_count'] = context['lfg_lower'].count()
Expand Down Expand Up @@ -159,7 +159,7 @@ def manage_profile(request):
lfg_profile = profile_form.save(commit=False)

# Discord username change: profile must be reverified and reactivated
if 'discord_username' in profile_form.changed_data or 'discord_discriminator' in profile_form.changed_data:
if 'discord_username' in profile_form.changed_data:
if lfg_profile.verified:
lfg_profile.verified = False
if lfg_profile.active:
Expand Down
Loading