def project_search(request): q = request.GET.get('q', '') form = ProjectSearchForm() q = q.strip() if request.method == "POST": form = ProjectSearchForm(request.POST) if form.is_valid(): q = form.cleaned_data['q'].strip() else: q = None if q is None: projects = Project.objects.none() else: query = ~Q(state=Project.DELETED) projects = api._get_projects(query, mode="active", request_user=request.user) table = get_user_projects_table(projects, user=request.user, prefix="my_projects_") if request.method == "POST": table.caption = _('SEARCH RESULTS') else: table.caption = _('ALL PROJECTS') return ListViewExtra.as_view( queryset=projects, template_name='im/projects/project_list.html', extra_context={ 'form': form, 'is_search': True, 'q': q, 'table': table })(request)
def project_search(request): q = request.GET.get('q', '') form = ProjectSearchForm() q = q.strip() if request.method == "POST": form = ProjectSearchForm(request.POST) if form.is_valid(): q = form.cleaned_data['q'].strip() else: q = None if q is None: projects = Project.objects.none() else: accepted = request.user.projectmembership_set.filter( state__in=ProjectMembership.ACCEPTED_STATES).values_list('project', flat=True) projects = Project.objects.search_by_name(q) projects = projects.filter(Project.o_state_q(Project.O_ACTIVE)) projects = projects.exclude(id__in=accepted).select_related( 'application', 'application__owner', 'application__applicant') table = get_user_projects_table(projects, user=request.user, prefix="my_projects_") if request.method == "POST": table.caption = _('SEARCH RESULTS') else: table.caption = _('ALL PROJECTS') return object_list(request, projects, template_name='im/projects/project_list.html', extra_context={ 'form': form, 'is_search': True, 'q': q, 'table': table })
def project_search(request): q = request.GET.get('q', '') form = ProjectSearchForm() q = q.strip() if request.method == "POST": form = ProjectSearchForm(request.POST) if form.is_valid(): q = form.cleaned_data['q'].strip() else: q = None if q is None: projects = Project.objects.none() else: accepted = request.user.projectmembership_set.filter( state__in=ProjectMembership.ACCEPTED_STATES).values_list( 'project', flat=True) projects = Project.objects.search_by_name(q) projects = projects.filter(Project.o_state_q(Project.O_ACTIVE)) projects = projects.exclude(id__in=accepted).select_related( 'application', 'application__owner', 'application__applicant') table = get_user_projects_table(projects, user=request.user, prefix="my_projects_") if request.method == "POST": table.caption = _('SEARCH RESULTS') else: table.caption = _('ALL PROJECTS') return object_list( request, projects, template_name='im/projects/project_list.html', extra_context={ 'form': form, 'is_search': True, 'q': q, 'table': table })
def project_search(request): q = request.GET.get('q', '') form = ProjectSearchForm() q = q.strip() if request.method == "POST": form = ProjectSearchForm(request.POST) if form.is_valid(): q = form.cleaned_data['q'].strip() else: q = None if q is None: projects = ProjectApplication.objects.none() else: accepted_projects = request.user.projectmembership_set.filter( ~Q(acceptance_date__isnull=True)).values_list('project', flat=True) projects = ProjectApplication.objects.search_by_name(q) projects = projects.filter(~Q(project__last_approval_date__isnull=True)) projects = projects.exclude(project__in=accepted_projects) table = tables.UserProjectApplicationsTable(projects, user=request.user, prefix="my_projects_") if request.method == "POST": table.caption = _('SEARCH RESULTS') else: table.caption = _('ALL PROJECTS') RequestConfig(request, paginate={"per_page": settings.PAGINATE_BY}).configure(table) return object_list( request, projects, template_name='im/projects/project_list.html', extra_context={ 'form': form, 'is_search': True, 'q': q, 'table': table })
def project_search(request): q = request.GET.get('q', '') form = ProjectSearchForm() q = q.strip() if request.method == "POST": form = ProjectSearchForm(request.POST) if form.is_valid(): q = form.cleaned_data['q'].strip() else: q = None if q is None: projects = Project.objects.none() else: query = ~Q(state=Project.DELETED) projects = api._get_projects(query, mode="active", request_user=request.user) table = get_user_projects_table(projects, user=request.user, prefix="my_projects_") if request.method == "POST": table.caption = _('SEARCH RESULTS') else: table.caption = _('ALL PROJECTS') return object_list(request, projects, template_name='im/projects/project_list.html', extra_context={ 'form': form, 'is_search': True, 'q': q, 'table': table })