Esempio n. 1
0
def queryh_update(request, pk):
    """Hostel query update view for user who added the query."""
    queryu = get_object_or_404(QueryH, pk=pk)
    form = QueryFormH(request.POST or None, instance=queryu)
    if form.is_valid():
        form.save()
        return redirect('home')
    return render(request, 'vtr/update_form.html', {'form': form})
Esempio n. 2
0
def add_queryH(request):
    """Hostel query add view."""
    if request.method == 'POST':
        query_form = QueryFormH(request.POST, request.FILES)
        if query_form.is_valid():
            query = query_form.save(commit=False)
            query.user = request.user
            query.save()
            query_form.save_m2m()
            if UserProfileF.objects.filter(user=request.user.id):
                return indexf(request)
            else:
                return redirect(hostelQ)
        else:
            print query_form.errors

    else:
        query_form = QueryFormH()
    return render(request, 'hostel/add_query.html', {'query_form': query_form},)