예제 #1
0
def posting(request):
    # A HTTP POST?
    if request.method == 'POST':
        form = PostingForm(request.POST)
        request_dict={}
        # Have we been provided with a valid form?
        if form.is_valid():
            posting_rank=form.cleaned_data['rank'];
            possible_ranks=Posting.objects.filter(rank=posting_rank);
            if possible_ranks:
              print "Rank Error!";
            else:
              form.save(commit=True)

            # Now call the index() view.
            # The user will be shown the homepage.
            return index(request)
        else:
          # The supplied form contained errors - just print them to the terminal.
            print form.errors
    else:
        # If the request was not a POST, display the form to enter details.
        form = PostingForm()

    # Bad form (or form details), no form supplied...
    # Render the form with error messages (if any).
    return render(request, 'admin_portal/[Temp] templates and css/change_posting.html', {'form': form})
예제 #2
0
파일: views.py 프로젝트: JakeBeaver/website
def create(request):
	if request.POST:
		form = PostingForm(request.POST)
		if form.is_valid() and request.user.is_authenticated():
			obj = form.save(commit=False)
			obj.username = request.user
			obj.save()
	return HttpResponseRedirect('/')
예제 #3
0
def new_posting(request, template_name="jobs/new_posting.html"):
    """
    Interface to create a new job posting.  A GET request will present
    an empty form.  A POST request will allow previewing and submitting
    the job posting.
    """
    if request.method == 'POST':
        form = PostingForm(request.POST)
        if 'submit' in request.POST and form.is_valid():
            posting = form.save()
            send_new_posting_notification(posting)
            return HttpResponseRedirect(posting.get_edit_url())

        if form.is_valid():
            preview = form.save(commit=False) # create a dummy posting instance
            return render_to_response(template_name, {'form': form,
                'preview': preview}) 
    else:
        form = PostingForm()

    return render_to_response(template_name, {'form': form})
예제 #4
0
def post(request):
    if request.POST:
        form = PostingForm(request.POST)
        if form.is_valid():
            posting = form.save(request.user)
            return render_to_response("postings/posting_form_reply.html",{
                "posting": posting,
                "content_type": form.cleaned_data["content_type"],
                "object_id": form.cleaned_data["object_id"],
            }, context_instance=RequestContext(request))
        else:
            return HttpResponse(status=400, content="Form was not valid")
    return HttpResponseRedirect(request.META.get('HTTP_REFERER','/'))