def project_list(request): responder = CustomJSONResponder() responder.expose_fields = Project.Rest.expose_fields projects = [] for p in Project.objects.all(): if request.user.has_perm('informer.change_project', object=p): projects.append(p) c = { 'user': request.user, 'data': responder.render(projects), } return render_to_response('informer/project_list.html', c)
def shot_logs(request, project_name, shot_name): p = get_object_or_404(Project, name=project_name) if not request.user.has_perm('informer.change_project', object=p): return HttpResponseForbidden(PROJECT_DENIED) shot = get_object_or_404(Shot, project=p, name=shot_name) if not request.user.has_perm('informer.change_shot', object=shot): return HttpResponseForbidden(SHOT_DENIED) responder = CustomJSONResponder() responder.expose_fields = Log.Rest.expose_fields c = { 'user': request.user, 'project': p, 'shot': shot, 'data': responder.render(shot.log_set.all()), } return render_to_response('informer/shot_detail_logs.html', c)
def project_print(request, project_name): p = get_object_or_404(Project, name=project_name) if not request.user.has_perm('informer.change_project', object=p): return HttpResponseForbidden(PROJECT_DENIED) responder = CustomJSONResponder() responder.expose_fields = Shot.Rest.expose_fields shots = [] for s in Shot.objects.filter(project=p).order_by('name'): if request.user.has_perm('informer.change_shot', object=s): shots.append(s) c = { 'user': request.user, 'project': p, 'shots': shots, } return render_to_response('informer/project_print.html', c)