Exemplo n.º 1
0
def active_user(request, token):
    try:
        username = token_confirm.confirm_validate_token(token)
    except:
        return HttpResponse(u'sorry')
    try:
        user = User.objects.get(username=username)
    except User.DoesNotExist:
        return HttpResponse(u'sorry,retry')
    user.is_active = True
    user.save()
    confirm = u'success!!'
    return HttpResponseRedirect('/account/login', {'confirm': confirm})
Exemplo n.º 2
0
def Register(request):
    global username, password, email
    if request.method == 'POST':
        form = CustomUserCreationForm(request.POST)
    if form.is_valid():
        #new_user = form.save()
        username, password, email = form['username'], form['password'], form[
            'email']
        user = User.objects.create(username=username,
                                   password=password,
                                   email=email,
                                   is_active=False)
        user.set_password(password)
        user.save()
        token = token_confirm.generate_validate_token(username)
        #active_key = base64.encodestring(username)
        #send email to the register email
        message = "\n".join([
            u'{0},welcome'.format(username), u'',
            '/'.join(['account/activate', token])
        ])
        send_mail(u'information', message, None, [form['email']])
        #user = auth.authenticate(username=username,password=password)
        #auth.login(request,user)
        return HttpResponse(u"login in your email for verfication。")
    else:
        form = CustomUserCreationForm()
    return render(request, 'register.html', {'form': form})
Exemplo n.º 3
0
def insert(request):
    pid1=int(request.GET['t1'])
    pname1=request.GET['t2']
    pcost1=float.(request.GET['t3'])
    pmfd1=request.GET[t4']
    pexpdt=request.GET['t5']
    f=product(pid=pid1,pname=pname1,pcost=pcost1,pmfd=pmfd1,pexpdt=pexpdt1)
    f.save()
    return HttpResponse("data insertded successfully")
Exemplo n.º 4
0
def main_page(request):
    output= '''
    <html>
    <head><tittle>%s</tittle></head>
    <body>
    <h1>%s,/h1><p>%s</p>
    </body>
    </html>
    '''%(
        'Django bookmarks'
        'Welcome to quickmark',
        ' Here you can store and share bookmarks!'
        )
    return HttpResponse (output)
Exemplo n.º 5
0
def index(request):
	return HttpResponse("sunck is a good man")
Exemplo n.º 6
0
def addstudents(request):
	grade = Grades.objects2.get(pk=1)
	stu   = Students.Create('liudehua',True,25,'明天会更好',grade)
	stu.save()
	return HttpResponse('已经添加一位学生基本信息到数据库成功!!!')
Exemplo n.º 7
0
def home(request):
    return HttpResponse('homepage')
Exemplo n.º 8
0
def products(request):
    return HttpResponse('products')
Exemplo n.º 9
0
def contact(request):
    return HttpResponse('contactpage')