Standardize user image + minor bugs
This commit is contained in:
parent
5147980d43
commit
208a4e4ef7
23 changed files with 608 additions and 540 deletions
18
judge/migrations/0185_rename_org_profile_colum.py
Normal file
18
judge/migrations/0185_rename_org_profile_colum.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.18 on 2024-04-12 05:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("judge", "0184_contest_rate_limit"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name="organizationprofile",
|
||||
old_name="users",
|
||||
new_name="profile",
|
||||
),
|
||||
]
|
|
@ -481,7 +481,7 @@ class Friend(models.Model):
|
|||
|
||||
|
||||
class OrganizationProfile(models.Model):
|
||||
users = models.ForeignKey(
|
||||
profile = models.ForeignKey(
|
||||
Profile,
|
||||
verbose_name=_("user"),
|
||||
related_name="last_visit",
|
||||
|
@ -500,22 +500,26 @@ class OrganizationProfile(models.Model):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def remove_organization(self, users, organization):
|
||||
organizationprofile = self.objects.filter(
|
||||
users=users, organization=organization
|
||||
def remove_organization(self, profile, organization):
|
||||
organization_profile = self.objects.filter(
|
||||
profile=profile, organization=organization
|
||||
)
|
||||
if organizationprofile.exists():
|
||||
organizationprofile.delete()
|
||||
if organization_profile.exists():
|
||||
organization_profile.delete()
|
||||
|
||||
@classmethod
|
||||
def add_organization(self, users, organization):
|
||||
self.remove_organization(users, organization)
|
||||
new_organization = OrganizationProfile(users=users, organization=organization)
|
||||
new_organization.save()
|
||||
def add_organization(self, profile, organization):
|
||||
self.remove_organization(profile, organization)
|
||||
new_row = OrganizationProfile(profile=profile, organization=organization)
|
||||
new_row.save()
|
||||
|
||||
@classmethod
|
||||
def get_most_recent_organizations(self, users):
|
||||
return self.objects.filter(users=users).order_by("-last_visit")[:5]
|
||||
def get_most_recent_organizations(cls, profile):
|
||||
queryset = cls.objects.filter(profile=profile).order_by("-last_visit")[:5]
|
||||
queryset = queryset.select_related("organization").defer("organization__about")
|
||||
organizations = [op.organization for op in queryset]
|
||||
|
||||
return organizations
|
||||
|
||||
|
||||
@receiver([post_save], sender=User)
|
||||
|
|
|
@ -242,6 +242,7 @@ class OrganizationList(TitleMixin, ListView, OrganizationBase):
|
|||
super(OrganizationList, self)
|
||||
.get_queryset()
|
||||
.annotate(member_count=Count("member"))
|
||||
.defer("about")
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue