def artifact_list(request, job_number): """ Lists Artifacts for the Job with the given number. Only list Atrifacts which the logged-in user has access to, based on their role and the access type set on each Artifact. """ job = get_object_or_404(Job, number=int(job_number)) if not job.is_accessible_to_user(request.user): return permission_denied(request) user_profile = request.user.get_profile() queryset = Artifact.objects.accessible_to_user( request.user).filter(job=job) sort_headers = SortHeaders(request, LIST_HEADERS) return list_detail.object_list( request, queryset.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='artifact', template_name='artifacts/artifact_list.html', extra_context={ 'job': job, 'headers': list(sort_headers.headers()), })
def activity_list(request): """ Lists Activities. A number of filter criteria may be applied to restrict Activities displayed based on a number of factors. """ filter_form = ActivityFilterForm(request.GET) filters = filter_form.get_filters() sort_headers = SortHeaders(request, LIST_HEADERS, additional_params=filter_form.get_params()) if filters: queryset = Activity.objects.filter(**filters) else: queryset = Activity.objects.all() return list_detail.object_list( request, queryset.select_related().order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='activity', template_name='activities/activity_list.html', extra_context={ 'filter_form': filter_form, 'headers': list(sort_headers.headers()), })
def artifact_type_list(request): """ Lists Artifact Types. """ sort_headers = SortHeaders(request, LIST_HEADERS) return list_detail.object_list(request, ArtifactType.objects.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='artifact_type', template_name='artifact_types/artifact_type_list.html', extra_context={ 'headers': list(sort_headers.headers()), })
def client_list(request): """ Lists Clients. """ sort_headers = SortHeaders(request, LIST_HEADERS) return list_detail.object_list(request, Client.objects.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='client', template_name='clients/client_list.html', extra_context={ 'headers': list(sort_headers.headers()), })
def invoice_list(request): """ Lists Invoices. """ sort_headers = SortHeaders(request, LIST_HEADERS) queryset = Invoice.objects.with_job_details() \ .order_by(sort_headers.get_order_by()) return list_detail.object_list(request, queryset, paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='invoice', template_name='invoices/invoice_list.html', extra_context={ 'headers': list(sort_headers.headers()), })
def user_list(request): """ Lists Users. """ admin = User.objects.get(userprofile__role=UserProfile.ADMINISTRATOR_ROLE) sort_headers = SortHeaders(request, LIST_HEADERS) users = users_accessible_to_user(request.user) \ .select_related() \ .order_by(sort_headers.get_order_by()) return list_detail.object_list(request, users, paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='user', template_name='users/user_list.html', extra_context={ 'admin': admin, 'headers': list(sort_headers.headers()), })
def sql_report_list(request): """ Lists SQL Reports. Only list SQL Reports which the logged-in user has access to, based on their role and the access type set on each SQL Report. """ user_profile = request.user.get_profile() header_defs = LIST_HEADERS if user_profile.is_admin(): header_defs = LIST_HEADERS + ((u'Access', 'access'),) sort_headers = SortHeaders(request, header_defs) queryset = SQLReport.objects.accessible_to_user(request.user) return list_detail.object_list(request, queryset.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='sql_report', template_name='sql_reports/sql_report_list.html', extra_context={ 'user_profile': user_profile, 'headers': list(sort_headers.headers()), })
def artifact_list(request, job_number): """ Lists Artifacts for the Job with the given number. Only list Atrifacts which the logged-in user has access to, based on their role and the access type set on each Artifact. """ job = get_object_or_404(Job, number=int(job_number)) if not job.is_accessible_to_user(request.user): return permission_denied(request) user_profile = request.user.get_profile() queryset = Artifact.objects.accessible_to_user(request.user).filter(job=job) sort_headers = SortHeaders(request, LIST_HEADERS) return list_detail.object_list( request, queryset.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name="artifact", template_name="artifacts/artifact_list.html", extra_context={"job": job, "headers": list(sort_headers.headers())}, )
def activity_list(request): """ Lists Activities. A number of filter criteria may be applied to restrict Activities displayed based on a number of factors. """ filter_form = ActivityFilterForm(request.GET) filters = filter_form.get_filters() sort_headers = SortHeaders(request, LIST_HEADERS, additional_params=filter_form.get_params()) if filters: queryset = Activity.objects.filter(**filters) else: queryset = Activity.objects.all() return list_detail.object_list(request, queryset.select_related().order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='activity', template_name='activities/activity_list.html', extra_context={ 'filter_form': filter_form, 'headers': list(sort_headers.headers()), })
def sql_report_list(request): """ Lists SQL Reports. Only list SQL Reports which the logged-in user has access to, based on their role and the access type set on each SQL Report. """ user_profile = request.user.get_profile() header_defs = LIST_HEADERS if user_profile.is_admin(): header_defs = LIST_HEADERS + ((u'Access', 'access'), ) sort_headers = SortHeaders(request, header_defs) queryset = SQLReport.objects.accessible_to_user(request.user) return list_detail.object_list( request, queryset.order_by(sort_headers.get_order_by()), paginate_by=settings.ITEMS_PER_PAGE, allow_empty=True, template_object_name='sql_report', template_name='sql_reports/sql_report_list.html', extra_context={ 'user_profile': user_profile, 'headers': list(sort_headers.headers()), })