def get_access_label(user, project): access = Access.objects.filter(user=user, project=project).first() access = access or Access(access=Access.NO_ACCESS, user=user, project=project) label = access.get_access_display() return label
def project_info(request, uid): user = request.user project = Project.objects.filter(uid=uid).first() # Show counts for the project. counts = get_counts(project) # Who has write access write_access = auth.is_writable(user=user, project=project) if user.is_authenticated: access = Access.objects.filter(user=user, project=project).first() else: access = Access(access=Access.NO_ACCESS) access = access or Access(access=Access.NO_ACCESS) context = dict(project=project, active="info", write_access=write_access, access=access) context.update(counts) return render(request, "project_info.html", context)
def get_access(user, project): access = Access.objects.filter(user=user, project=project).first() access = access or Access( access=Access.NO_ACCESS, user=user, project=project) return access