Exemplo n.º 1
0
def addListingPageView(request):
    if request.method == 'POST':

        new_listing = Listing()

        new_listing.job_title = request.POST.get('job_title')
        new_listing.contracts = request.POST.get('contract_length')
        new_listing.city = request.POST.get('city')
        new_listing.compensation = request.POST.get('compensation')
        new_listing.company_website = request.POST.get('company_website')
        new_listing.listing_id = (random.randint(
            209, 10000))  # had to manually input an id FIX ME: AUTOFILL PK

        new_listing.save()

        listing_data = Listing.objects.all()

        context = {'all_listings': listing_data, 'new_listing': new_listing}
        return render(request, 'organization/viewlisting.html', context)
    else:
        return HttpResponse("NOT FOUND")