from lib decorators import render_to from problematic models import Pr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from lib.decorators import render_to
from problematic.models import Problem
from problematic.forms import SearchForm
def filter(qs, form):
if form.cleaned_data['client']:
qs = qs.filter(client=form.cleaned_data['client'])
if form.cleaned_data['user']:
qs = qs.filter(technican=form.cleaned_data['user'])
if form.cleaned_data['type']:
qs = qs.filter(type=form.cleaned_data['type'])
if form.cleaned_data['status']:
qs = qs.filter(type=form.cleaned_data['status'])
return qs
@render_to("index.html")
def open_problems(request):
problems = Problem.objects.filter(close_date__isnull=False)
if request.method == 'POST':
form = SearchForm(request.POST)
if form.is_valid():
problems = filter(Problem.objects.all(), form)
assert False, problems
else:
return {'problems': problems, 'form': form}
form = SearchForm()
return {'problems': problems, 'form': form}