예제 #1
0
 def update_skills():
     # f**k capitals
     tag_list = request.POST.get("skills_text").lower().split(",")
     for tag in tag_list:
         if tag and tag != "":
             # f*****g excess whitespace man
             tag = tag_clean(tag)
             skill, created = Skill.objects.get_or_create(name=tag)
             profile.skills.add(skill)
     psf = ProfileSkillsForm(request.POST)
     if psf.is_valid():
         skills_list = Skill.objects.filter(id__in=psf.cleaned_data.get("skills"))
         for skill in skills_list:
             profile.skills.add(skill)
     profile.save()
     messages.success(request, "Skills updated.")
예제 #2
0
 def update_skills():
     #f**k capitals
     tag_list = request.POST.get('skills_text').lower().split(',')
     for tag in tag_list:
         if tag and tag != '':
             #f*****g excess whitespace man
             tag = tag_clean(tag)
             skill, created = Skill.objects.get_or_create(name=tag)
             profile.skills.add(skill)
     psf = ProfileSkillsForm(request.POST)
     if psf.is_valid():
         skills_list = Skill.objects.filter(
             id__in=psf.cleaned_data.get('skills'))
         for skill in skills_list:
             profile.skills.add(skill)
     profile.save()
     messages.success(request, 'Skills updated.')
예제 #3
0
def search(request):
    if request.method == "POST":
        searchform = SearchForm(request.POST)
        if searchform.is_valid():
            query = searchform.data.get('query')
            query_list = query.lower().split(',')
            if len(query_list) > 1:
                try:
                    qs = [
                        list(
                            chain(*[
                                skill.profile_set.all()
                                for skill in Skill.objects.filter(
                                    name__contains=tag_clean(qry))
                            ])) for qry in query_list
                    ]
                    results = list(set(qs[0]).intersection(*qs))
                except Exception, e:
                    results = None
            else:
                try:
                    results = list(
                        chain(
                            Skill.objects.get(name__contains=query_list[0]).
                            profile_set.all()))
                except Exception, e:
                    if e.__class__ == Skill.MultipleObjectsReturned:
                        results = list(
                            chain(*[
                                skill.profile_set.all()
                                for skill in Skill.objects.filter(
                                    name__contains=query_list[0])
                            ]))
                    else:
                        results = None
            searchform = SearchForm({'query': query})
예제 #4
0
def search(request):
    if request.method == "POST":
        searchform = SearchForm(request.POST)
        if searchform.is_valid():
            query = searchform.data.get('query')
            query_list = query.lower().split(',')
            if len(query_list) > 1:
                try:
                    qs = [list(chain(*[skill.profile_set.all() for skill in Skill.objects.filter(name__contains=tag_clean(qry))])) for qry in query_list]
                    results = list(set(qs[0]).intersection(*qs))
                except Exception, e:
                    results = None
            else:
                try:
                    results = list(chain(Skill.objects.get(name__contains=query_list[0]).profile_set.all()))
                except Exception, e:
                    if e.__class__ == Skill.MultipleObjectsReturned:
                        results = list(chain(*[skill.profile_set.all() for skill in Skill.objects.filter(name__contains=query_list[0])]))
                    else:
                        results = None
            searchform = SearchForm({'query':query})