def services_view(request, slug=None, project_slug=None): SERVICE_PHOTO_POSITIONS = [1, 2, 6] all_services = Service.objects.filter(activity=True).order_by("-priority") current_service = Service.objects.get(slug=slug) service_projects = Project.objects.filter(activity=True, services=current_service) # if project_slug: # main_project = projects.filter(slug=project_slug) # active_queryset = main_project # else: # active_queryset = projects # video = main_project.projects.all().order_by('-priority') project_photos = service_projects.values_list("project__photo") photos = zip(SERVICE_PHOTO_POSITIONS, [photo[0] for photo in project_photos]) related_projects = get_related_projects(None, current_service.pk, None) return { "projects": service_projects, "current_service": current_service, "services": all_services, "photos": photos, "related_projects": related_projects, "menu": "services", }
def view_project(request, slug=None): project = Project.objects.get(slug=slug) photo = project.project.all().order_by("-priority") video = project.projects.all().order_by("-priority") try: related_projects = get_related_projects(project.clients.pk, project.services.pk, project.pk) except: related_projects = None return { "photo": photo, "video": video, "project": project, "related_projects": related_projects, "menu": "projects", }