Example #1
0
 def post(self, request, *args, **kwargs):
     form = AddForm(request.POST)
     if form.is_valid():
         clean_form = form.cleaned_data
         description = clean_form['description']
         if request.user.is_authenticated and not request.user.is_staff:
             resume = Resume(description=description, author=request.user)
             resume.save()
             return HttpResponseRedirect('/home')
         else:
             return HttpResponseForbidden()
     return HttpResponseForbidden()
Example #2
0
def index(request):
    path = request.get_full_path()
    #path='index?code=111&state='#test
    print path
    params = path.split('?')
    if (len(params) > 1):
        param = params[1].split('&')
        for p in param:
            key = p.split('=')[0]
            if key == 'code':
                code = p.split('=')[1]
        #print code
        data = wechatApi.wx.getOpenid(code)
        if ('openid' in data):
            openid = data['openid']
            user = Resume.objects.filter(openid=openid)
            if len(user) == 0:
                info = wechatApi.wx.getUserInfo(openid)
                print info
                province = info['province']
                city = info['city']
                nickname = info['nickname']
                headimgurl = info['headimgurl']
                nation = info['country']
                r = Resume(name=nickname,
                           openid=openid,
                           province=province,
                           city=city,
                           avatar=headimgurl,
                           nation=nation,
                           state=0)
                r.save()
            else:
                print 'user already exist'
            resume = Resume.objects.filter(openid=openid)[0]
        else:
            #request.session['id'] = 2#test
            id = request.session.get('id', False)
            resume = Resume.objects.filter(id=id)[0]
        id = resume.id
        province = resume.province
        city = resume.city
        avatar = resume.avatar
        name = resume.name
        request.session['id'] = id
        return render_to_response('home.html', {
            'province': province,
            'city': city,
            'avatar': avatar,
            'name': name
        })
    else:
        return HttpResponseRedirect("/error")
Example #3
0
 def post(self, request, *args, **kwargs):
     if not request.user.is_authenticated:
         raise PermissionDenied
     form = ResumeForm(data=request.POST)
     if form.is_valid():
         description = form.cleaned_data['description']
         user = User.objects.get(id=request.user.id)
         new_resume = Resume(author=user, description=description)
         new_resume.save()
         return redirect("/home")
     else:
         return render(request, self.template_name, {"form": form})
Example #4
0
 def post(self, request, *args, **kwargs):
     form = DescriptionForm(request.POST)
     description = ""
     if form.is_valid():
         description = form.cleaned_data["description"]
     user = request.user
     if user.is_authenticated and not user.is_staff:
         resume = Resume(description=description, author=user)
         with open("file.txt", "w") as f:
             f.write(str(user.username) + str(description))
         resume.save()
         return redirect("/home")
     else:
         return HttpResponseForbidden('<h1>403 Forbidden</h1>',
                                      content_type='text/html')
Example #5
0
    def post(self, request, *args, **kwargs):
        if not request.user.is_authenticated or request.user.is_staff:
            raise PermissionDenied

        Resume(author=request.user,
               description=request.POST.get("description")).save()
        return redirect("/home")
Example #6
0
 def get_object(self, queryset=None):
     resume = ''
     try:
         resume = Resume.get_user_company(self.request.user)
         # resume = self.request.user.resume
     except:
         pass
     return resume
Example #7
0
 def post(self, request, *args, **kwargs):
     f = MyForm(data=request.POST)
     user = request.user
     context = {'resumes': self.all_resumes, 'vacancies': self.all_vacancies, 'is_staff': request.user.is_staff,
                'form': f, }
     if not user.is_authenticated:
         raise PermissionDenied
     if f.is_valid():
         description = f.cleaned_data['description']
         if user.is_staff:
             v = Vacancy(description=description, author=user)
             v.save()
         else:
             r = Resume(description=description, author=user)
             r.save()
     # redirect('/')
     return render(request, 'menu/home.html', context=context)
Example #8
0
def applysync(request):
    data = {}

    if request.method == 'POST':
        logger.debug(str(request.POST))

        fact_id = request.POST.get('factory_id')
        empolyee_name = request.POST.get('name')
        job_position = request.POST.get('job_postion')
        factory = Factory.objects.get(id=fact_id)

        resume = Resume(apply_factory=factory)
        resume.name = empolyee_name
        resume.apply_job = job_position

        resume.save()

        return HttpResponse(200)
    def post(self, request, *args, **kwargs):
        form = ResumeForm(request.POST)

        if form.is_valid():
            clean_data = form.cleaned_data
            description = clean_data["description"]
            if request.user.is_authenticated:
                if not request.user.is_staff:
                    new_res = Resume(description=description,
                                     author=request.user)
                    new_res.save()
                    del new_res
                    return redirect("/home")
                else:
                    return HttpResponseForbidden()
            else:
                return redirect("/home")

        return HttpResponseForbidden()
Example #10
0
 def post(self, request):
     form = NewResumeForm(request.POST)
     if form.is_valid():
         request_user = self.request.user
         form_data = form.cleaned_data
         if request_user.is_authenticated and not request_user.is_staff:
             Resume(description=form_data['description'],
                    author=request_user) \
                 .save()
             return HttpResponseRedirect(self.success_url)
         return HttpResponseForbidden()
     return HttpResponseBadRequest()
Example #11
0
def new_resume(request):
    if request.method == 'POST':
        form = ResumeForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            applicant = form.cleaned_data['applicant']
            output_format = form.cleaned_data['output_format']
            template = form.cleaned_data['template']
            #style = form.cleaned_data['style']
            r = Resume(owner=request.user,
                       name=name,
                       applicant=applicant,
                       output_format=output_format,
                       template=template)
            r.save()
            if request.session['isWizard']:
                request.session['isWizard'] = False
            return HttpResponseRedirect('/resume/')
    else:
        form = ResumeForm()
    return render(request, 'resume/resume_form.html', {'form': form})
Example #12
0
    def post(self, request, *args, **kwargs):
        data = [request.POST.get('description'), request.POST.get('title')]

        if data:
            if my_is_staff(request.user):
                Vacancy(author=request.user)
                Vacancy.objects.create(title=data[1], description=data[0], create_data=datetime.now(), author=request.user)
                return redirect('/vacancy/')
            else:
                try:
                    my_resume = Resume.objects.get(author=request.user)
                except Resume.DoesNotExist:
                    my_resume = Resume(author=request.user)
                my_resume.title = data[1]
                my_resume.description = data[0]
                my_resume.create_data = datetime.now()
                my_resume.save()
                return redirect('/resume/')
        else:
            return HttpResponseBadRequest()
Example #13
0
 def test_default_text(self):
     resume = Resume()
     self.assertEqual(resume.display_name, '')
Example #14
0
 def setUp(self):
     self.student = Student.objects.create()
     self.resume = Resume(student=self.student)