Exemple #1
0
def check_ip(request):
    try:
        exp = Exp.objects(onlyKey=1)
    except DoesNotExist:
        exp = Exp()
        exp.save()

    _ip = request.POST["IP"]
    try:
        record = Record.objects(ip=_ip)
    except DoesNotExist:
        exp.count += 1
        exp.save()
        record = Record(ip=_ip, seqNo=exp.count)
        record.save()

    if record.time_end is None:
        return HttpResponse(status=200)
    else:
        return HttpResponse(status=400)
Exemple #2
0
def Exp_Profile(request):
    if request.method=="POST":
        form=ExpForm(request.POST,request.FILES)
        if form.is_valid():
            primary=form.cleaned_data['primary']
            secondary=form.cleaned_data['secondary']
            role=form.cleaned_data['role']
            designation=form.cleaned_data['secondary']
            exp=form.cleaned_data['exp']
            email=form.cleaned_data['email']
            ctc=form.cleaned_data['ctc']
            exp_ctc=form.cleaned_data['exp_ctc']
            reason_for_change=form.cleaned_data['reason_for_change']
            current_company=form.cleaned_data['current_company']
            docfile=form.cleaned_data['docfile']
            e=Exp()
            e.primary=primary
            e.secondary=secondary
            e.role=role
            e.designation= designation
            e.exp=exp
            e.ctc=ctc
            e.exp_ctc=exp_ctc
            e.reason_for_change=reason_for_change
            e.current_company=current_company
            e.email=email
            e.docfile=docfile
            e.save()
            success = "yes"
            from email.mime.text import MIMEText
            #attachment.add_header('Content-Disposition', 'attachment', filename=f) 
            success = "yes"
            subject="profile informayion"
            #url='http://127.0.0.1:8000/resetpwd/'
            url='http://127.0.0.1:8000/resetpwd/{0}'
            html_content='<a href="%s" > download</a>'% url
            body = preprocess_email_body(request,  html_content)
            email = EmailMessage(subject, body, to=[email])
            try:
              #email =EmailMultiAlternatives(subject,body,to=[email])
              email.attach(docfile.name, docfile.read(), docfile.content_type)
              content_subtype = "html"
              #email.attach_alternative(html_content, "text/html")
              #email.attach(attachment)
              email.send()
              #return render(request,"profile.html",locals())       
              success = "yes"
            except Exception as e:
              print e


            success="yes"
            return render (request,"expprofile.html",locals())
        else:
            error = "yes"
            print "34233333434", form.errors
    else:
        form=ExpForm()
    return render(request,"expprofile.html",{"form":form})