def get_student_carousel_items(student, degree=None, show_animation_videos=False): profile = student.get_profile(degree) carousel_items = profile['carousel_items'].all() # If this is an animation student, remove the first two carousel items if they are vimeo videos if show_animation_videos == False and get_students(degree_filters=dict(programme__in=['animation', 'visualcommunication'])).filter(id=student.id).exists(): for i in range(2): try: first_carousel_item = carousel_items[0] if first_carousel_item and first_carousel_item.embedly_url: carousel_items = carousel_items[1:] except IndexError: pass return carousel_items
def get_students(self, school=None, programme=None, orderby="first_name"): q = models.Q(in_show=True) if self.year: q &= models.Q(graduation_year=self.year) if school: q &= models.Q(school=school) if programme: q &= models.Q(programme=programme) else: programmes = self.get_programmes() if programmes: q &= models.Q(programme__in=programmes) # If this is the 2015 visual communication show, make that the first carousel item is an embed if self.year == '2015' and 'visualcommunication' in self.get_programmes(): q &= models.Q(carousel_items__sort_order=0) & models.Q(carousel_items__embedly_url__startswith='http') return rca_utils.get_students(degree_q=q).order_by(orderby).distinct()