Initial subdomain implementation

This commit is contained in:
cuom1999 2023-01-23 20:36:44 -06:00
parent dea24f7f71
commit 1628e63084
17 changed files with 194 additions and 46 deletions

View file

@ -71,7 +71,7 @@ class Comment(MPTTModel):
order_insertion_by = ["-time"]
@classmethod
def most_recent(cls, user, n, batch=None):
def most_recent(cls, user, n, batch=None, organization=None):
queryset = (
cls.objects.filter(hidden=False)
.select_related("author__user")
@ -79,6 +79,9 @@ class Comment(MPTTModel):
.order_by("-id")
)
if organization:
queryset = queryset.filter(author__in=organization.members.all())
problem_access = CacheDict(
lambda code: Problem.objects.get(code=code).is_accessible_by(user)
)

View file

@ -33,6 +33,7 @@ class Organization(models.Model):
max_length=128,
verbose_name=_("organization slug"),
help_text=_("Organization name shown in URL"),
unique=True,
)
short_name = models.CharField(
max_length=20,
@ -339,6 +340,16 @@ class Profile(models.Model):
ret.add(self.username)
return ret
def can_edit_organization(self, org):
if not self.user.is_authenticated:
return False
profile_id = self.id
return (
org.admins.filter(id=profile_id).exists()
or org.registrant_id == profile_id
or self.user.is_superuser
)
class Meta:
permissions = (
("test_site", "Shows in-progress development stuff"),