From b8876ba0231d1e36258e214b9a99c0b799adf795 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sat, 28 May 2022 02:29:25 -0500 Subject: [PATCH] Make admin members --- judge/models/profile.py | 4 ++++ judge/views/organization.py | 7 ++----- templates/top-users.html | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/judge/models/profile.py b/judge/models/profile.py index fe8ce17..251101d 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -112,6 +112,10 @@ class Organization(models.Model): def get_contests_url(self): return reverse("organization_contests", args=(self.id, self.slug)) + def save(self, *args, **kwargs): + self.members.add(*self.admins.all()) + super(Organization, self).save(*args, **kwargs) + class Meta: ordering = ["name"] permissions = ( diff --git a/judge/views/organization.py b/judge/views/organization.py index 289118b..42426f2 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -151,11 +151,8 @@ class OrganizationList(TitleMixin, ListView, OrganizationBase): def get_context_data(self, **kwargs): context = super(OrganizationList, self).get_context_data(**kwargs) - context["my_organizations"] = set() - - for organization in context["organizations"]: - if self.can_edit_organization(organization) or self.is_member(organization): - context["my_organizations"].add(organization) + if self.request.profile: + context["my_organizations"] = self.request.profile.organizations.all() return context diff --git a/templates/top-users.html b/templates/top-users.html index fac55ec..35197ee 100644 --- a/templates/top-users.html +++ b/templates/top-users.html @@ -7,7 +7,7 @@ {% for user in top_rated %} {{loop.index}} - {{link_user(user)}} + {{link_user(user)}} {{user.rating}} {% endfor %}