Beispiel #1
0
def applyLink(request):
    if request.method == "POST" and request.POST:
        # 如果是POST,接收用户输入
        link_form = LinkForm(request.POST)
        # 表单验证
        if link_form.is_valid():
            link_form.save()
            return HttpResponse("申请成功,请稍后我将尽快审核")
    else:
        link_form = LinkForm()
    locs = {
        "link_form": link_form,
    }
    return render(request, 'blog/LinkApply.html', locs)
Beispiel #2
0
def admin_add_link(request):

    if users.is_current_user_admin():
        if request.method == 'GET':
            form = LinkForm()

        elif request.method == 'POST':
            form = LinkForm(request.POST)
            if form.is_valid():
                link = form.save()
                link.put()
            return HttpResponseRedirect('/admin')
        return render_to_response('admin/edit.html',
                                  dictionary={
                                      'form': form,
                                      'type': 'Add Link',
                                  },
                                  context_instance=RequestContext(request))
    else:
        return HttpResponseRedirect('/')
Beispiel #3
0
def admin_add_link(request):

    if users.is_current_user_admin():
        if request.method == 'GET':
            form = LinkForm()
        
        elif request.method == 'POST':
            form = LinkForm(request.POST)  
            if form.is_valid():
                link = form.save()
                link.put()
            return HttpResponseRedirect('/admin')
        return render_to_response('admin/edit.html',
                                      dictionary={ 'form':form,
                                                    'type': 'Add Link',
                                                     },
                                      context_instance=RequestContext(request)
                                    )
    else:
        return HttpResponseRedirect('/')