Cloned DMOJ
This commit is contained in:
parent
f623974b58
commit
49dc9ff10c
513 changed files with 132349 additions and 39 deletions
17
judge/utils/tickets.py
Normal file
17
judge/utils/tickets.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models import Q
|
||||
|
||||
from judge.models import Problem
|
||||
from judge.utils.problems import editable_problems
|
||||
|
||||
|
||||
def own_ticket_filter(profile_id):
|
||||
return Q(assignees__id=profile_id) | Q(user_id=profile_id)
|
||||
|
||||
|
||||
def filter_visible_tickets(queryset, user, profile=None):
|
||||
if profile is None:
|
||||
profile = user.profile
|
||||
return queryset.filter(own_ticket_filter(profile.id) |
|
||||
Q(content_type=ContentType.objects.get_for_model(Problem),
|
||||
object_id__in=editable_problems(user, profile))).distinct()
|
Loading…
Add table
Add a link
Reference in a new issue