Format
This commit is contained in:
parent
1595063463
commit
1ca0d51f67
7 changed files with 41 additions and 41 deletions
|
@ -179,9 +179,7 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
||||||
queryset.select_related("author__user")
|
queryset.select_related("author__user")
|
||||||
.filter(hidden=False)
|
.filter(hidden=False)
|
||||||
.defer("author__about")
|
.defer("author__about")
|
||||||
.annotate(
|
.annotate(revisions=Count("versions", distinct=True))
|
||||||
revisions=Count("versions", distinct=True)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
queryset = self.object.comments
|
queryset = self.object.comments
|
||||||
|
@ -211,7 +209,7 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
||||||
queryset = self._get_queryset(target_comment)
|
queryset = self._get_queryset(target_comment)
|
||||||
comment_count = self.object.comments.filter(parent=None, hidden=False).count()
|
comment_count = self.object.comments.filter(parent=None, hidden=False).count()
|
||||||
context["target_comment"] = -1
|
context["target_comment"] = -1
|
||||||
if (target_comment != None):
|
if target_comment != None:
|
||||||
context["target_comment"] = target_comment.id
|
context["target_comment"] = target_comment.id
|
||||||
|
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
|
|
|
@ -159,9 +159,7 @@ def get_comments(request, limit=10):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
profile = request.profile
|
profile = request.profile
|
||||||
queryset = queryset.annotate(
|
queryset = queryset.annotate(
|
||||||
my_vote=FilteredRelation(
|
my_vote=FilteredRelation("votes", condition=Q(votes__voter_id=profile.id)),
|
||||||
"votes", condition=Q(votes__voter_id=profile.id)
|
|
||||||
),
|
|
||||||
).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0)))
|
).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0)))
|
||||||
|
|
||||||
new_offset = offset + min(len(queryset), limit)
|
new_offset = offset + min(len(queryset), limit)
|
||||||
|
@ -179,8 +177,8 @@ def get_comments(request, limit=10):
|
||||||
"comment_count": comment_count,
|
"comment_count": comment_count,
|
||||||
"comment_parent_none": parent_none,
|
"comment_parent_none": parent_none,
|
||||||
"target_comment": target_comment,
|
"target_comment": target_comment,
|
||||||
"comment_more": comment_count - new_offset
|
"comment_more": comment_count - new_offset,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return HttpResponse(comment_html)
|
return HttpResponse(comment_html)
|
||||||
|
|
|
@ -15,14 +15,17 @@ __all__ = [
|
||||||
|
|
||||||
course_directory_file = ""
|
course_directory_file = ""
|
||||||
|
|
||||||
|
|
||||||
class CourseListMixin(object):
|
class CourseListMixin(object):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Course.objects.filter(is_open="true").values()
|
return Course.objects.filter(is_open="true").values()
|
||||||
|
|
||||||
|
|
||||||
class CourseList(ListView):
|
class CourseList(ListView):
|
||||||
model = Course
|
model = Course
|
||||||
template_name = "course/list.html"
|
template_name = "course/list.html"
|
||||||
queryset = Course.objects.filter(is_public=True).filter(is_open=True)
|
queryset = Course.objects.filter(is_public=True).filter(is_open=True)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CourseList, self).get_context_data(**kwargs)
|
context = super(CourseList, self).get_context_data(**kwargs)
|
||||||
available, enrolling = [], []
|
available, enrolling = [], []
|
||||||
|
@ -34,4 +37,3 @@ class CourseList(ListView):
|
||||||
context["available"] = available
|
context["available"] = available
|
||||||
context["enrolling"] = enrolling
|
context["enrolling"] = enrolling
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,9 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
|
||||||
def _get_entire_queryset(self):
|
def _get_entire_queryset(self):
|
||||||
organization = self.organization or self.request.organization
|
organization = self.organization or self.request.organization
|
||||||
if organization:
|
if organization:
|
||||||
queryset = Submission.objects.filter(contest_object__organizations=organization)
|
queryset = Submission.objects.filter(
|
||||||
|
contest_object__organizations=organization
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
queryset = Submission.objects.all()
|
queryset = Submission.objects.all()
|
||||||
use_straight_join(queryset)
|
use_straight_join(queryset)
|
||||||
|
|
Loading…
Reference in a new issue