da2a11adf9
This reverts commit 0494a36681
.
21 lines
625 B
Python
Executable file
21 lines
625 B
Python
Executable file
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()
|