コード例 #1
0
ファイル: mixins.py プロジェクト: the-open/commonslibrary
 def get_context_data(self, **kwargs):
     context = super().get_context_data()
     context['latest_resource'] = Resource.get_latest(self.request.user)
     context['most_liked_resource'] = Resource.get_most_liked(self.request.user)
     context['most_tried_resource'] = Resource.get_most_tried(self.request.user)
     context['most_published'] = Organisation.get_most_published_this_week()
     context['latest_resources'] = Resource.objects.approved(
         self.request.user,
     ).order_by(
         '-created_at',
     )[:12]
     return context
コード例 #2
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data()
     context['carousel_resources'] = Resource.get_carousel_resources(
         self.request.user)
     context['latest_resource'] = Resource.get_latest(self.request.user)
     most_tried_resource = Resource.get_most_tried(
         self.request.user).first()
     context['most_tried'] = most_tried_resource
     kwargs = {'user': self.request.user}
     if most_tried_resource:
         kwargs.update({'exclude': most_tried_resource.id})
     context['most_liked'] = Resource.get_most_liked(**kwargs).first()
     context['most_published'] = Organisation.get_most_published_this_week()
     return context