Exemple #1
0
def advanced_search(request):
    user_group = check_user_group(request)
    empty = True
    form = AdvancedSearchForm(data = request.POST or None)
    tutors = []
    post = False
    if request.method == "POST":
        post = True
        if form.is_valid():
            first = form.cleaned_data['first_name']
            last = form.cleaned_data['last_name']
            school = form.cleaned_data['school']
            subj = form.cleaned_data['subject']
            proficient_area = form.cleaned_data['proficient_area']
            fees = form.cleaned_data['fees']
            experience = form.cleaned_data['experience']
            days = form.cleaned_data['days']
            cgpa = form.cleaned_data['cgpa']
            if first is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(user__first_name__icontains=first)).distinct()
            if last is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(user__last_name__icontains=last)).distinct()
            if school is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(school__school__icontains=school)).distinct()
            if subj is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(subject__title__icontains=subj)).distinct()
            if days is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(days__day__icontains=days)).distinct()
            if experience is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(experience__icontains=experience)).distinct()
            if proficient_area is not "":
                empty = False
                tutors += Tutor.objects.filter(Q(proficient_areas__icontains=proficient_area)).distinct()
            if fees is not None:
                empty = False
                tutors += Tutor.objects.filter(fees_per_hour <= fees).distinct()
            if cgpa is not None:
                empty = False
                tutors += Tutor.objects.filter(cgpa >= cgpa).distinct()

    return render_to_response('tuition/advanced_search.html',
                              {'user_group': user_group, 'current_home': "current", 'tutors':tutors, 'post':post, 'empty':empty, 'form':form},
                              context_instance=RequestContext(request))

        
    

## Advanced search with specified fields...
## googlemap location preference
## tuition service
## change the model to add subjects as per schools...check if the subject entered is valid and add it to the subjects available database.
## dynamic creation of check-boxes when school is added
# each school associated with courses.
# then each tutor associated with each school.
Exemple #2
0
def advanced():
    search_form = AdvancedSearchForm()
    if search_form.validate_on_submit():
        if search_form.title:
            cursor = g.conn.execute(text("""
      WITH FullTable AS
      (SELECT P.purl, P.title, P.model, P.number_of_citations, R.programming_language, K.keyword, A.first_name,
      A.last_name, I.type, I.name, I.country, I.city, I.street, I.street_number, I.zip, R.rdate_published, P.date_published
      FROM Papers P
      LEFT OUTER JOIN Published_On PO ON P.purl = PO.purl
      LEFT OUTER JOIN Repositories R ON PO.url = R.url
      LEFT OUTER JOIN Is_Related_To IRT ON PO.purl = IRT.purl
      LEFT OUTER JOIN Keywords K ON IRT.keyword = K.keyword
      LEFT OUTER JOIN Published_By PB ON P.purl = PB.purl
      LEFT OUTER JOIN Authors A ON PB.aid = A.aid
      LEFT OUTER JOIN Works_At WA ON WA.aid = A.aid
      LEFT OUTER JOIN Institutions I ON I.iid = WA.iid)
      SELECT DISTINCT FT.title, FT.purl, FT.programming_language, FT.rdate_published
      FROM FullTable FT
      WHERE
      upper(FT.title) LIKE '%%' || :title || '%%' AND
      upper(FT.model) LIKE '%%' || :model || '%%' AND
      FT.date_published >= :pdate AND 
      FT.number_of_citations >= :citations AND
      upper(FT.first_name) LIKE '%%' || :first || '%%' AND
      upper(FT.last_name) LIKE '%%' || :last || '%%' AND
      upper(FT.name) LIKE '%%' || :institution || '%%' AND
      FT.type IN :insttype AND
      upper(FT.country) LIKE '%%' || :instcountry || '%%' AND
      upper(FT.city) LIKE '%%' || :instcity || '%%' AND
      upper(FT.zip) LIKE '%%' || :instzip || '%%' AND
      upper(FT.street) LIKE '%%' || :inststreet || '%%' AND
      upper(FT.street_number) LIKE '%%' || :instno || '%%';
      """), title=search_form.title.data.upper(), model=search_form.model.data.upper(),
            pdate=str(
                search_form.published_year.data if search_form.published_year.data else 1900) + '01' + '01',
            citations=search_form.minimum_citations.data if search_form.minimum_citations.data else 0,
            prog=search_form.repo_programming_language.data.upper(),
            rdate=str(
                search_form.repo_published_year.data if search_form.repo_published_year.data else 1900) + '01' + '01',
            first=search_form.author_first_name.data.upper(),
            last=search_form.author_last_name.data.upper(), institution=search_form.inst_name.data.upper(),
            insttype=tuple(search_form.inst_type.data.split(' ')),
            instcountry=search_form.inst_country.data.upper(), instcity=search_form.inst_city.data.upper(),
            instzip=search_form.inst_zip.data.upper(),
            inststreet=search_form.inst_street.data.upper(), instno=search_form.inst_street_no.data.upper())
        results = []
        for r in cursor:
            if (search_form.repo_programming_language.data != '' and
                    (not r.programming_language or
                    r.programming_language.upper() != search_form.repo_programming_language.data.upper())):
                continue
            if (search_form.repo_published_year.data is not None and
                    (not r.rdate_published or
                    r.rdate_published.year < search_form.repo_published_year.data)):
                continue
            results.append({'title': r.title, 'purl': utils.encode_url(r.purl)})
        return render_template('advancedsearch.html', results=results)
    return render_template('advanced.html', form=search_form)
def advancedSearch():
  form = AdvancedSearchForm()
  
  if request.method == 'POST':
    if form.validate() == False:
      return render_template('advancedSearch.html', form=form)
    else:   
      return "[1] Create a new user [2] sign in the user [3] redirect to the user's profile"
  
  elif request.method == 'GET':
    return render_template('advancedSearch.html', form=form)   
Exemple #4
0
def advanced_search(request, template="forum/advanced_search.html"):
    t = None
    if request.GET:
        f = AdvancedSearchForm(request.GET)
        if f.is_valid():
            t = Thread.objects.all()
            if f.cleaned_data['searchtext']:
                stext = f.cleaned_data['searchtext']
                t = t.filter(Q(post__text__contains=stext) | Q(title__contains=stext))
            if f.cleaned_data['user']:
                t = t.filter(post__author__username__exact=f.cleaned_data['user'])
            if f.cleaned_data['solved']:
                t = t.filter(solved=True)
            t = t.distinct()[:30]
    else:
        f = AdvancedSearchForm()
    return render_to_response(template, {
        "threads": t,
        "form": f,
        }, context_instance=RequestContext(request))
Exemple #5
0
def advanced_search():
    title = 'Advanced Search'
    advancedsearchform = AdvancedSearchForm()

    return render_template('advanced_search.html', title = title, advancedsearchform = advancedsearchform, loggedin = validate_login(), is_admin = validate_admin())