示例#1
0
def create(request):

    if request.method=='GET':
        return render(request, 'visits/createVisits.html', {'visitForm':VisitForm()})
    
    #POST
    visitsForm = VisitForm(data=request.POST)
    if not visitsForm.is_valid():
        return render(request, 'visits/createVisits.html', {'visitForm':visitsForm})
    
    visitsForm.save()
    
    return redirect(reverse('visits:visits'))
示例#2
0
def create(request):

    if request.method == 'GET':
        if Demand.objects.all().count() == 0:
            Demand.objects.create(type='雲端')
            Demand.objects.create(type='大數據')
            Demand.objects.create(type='智慧製造')
            Demand.objects.create(type='物聯網')
            Demand.objects.create(type='系統開發')
            Department.objects.create(name='資管')
            Department.objects.create(name='資工')
            Department.objects.create(name='資通')
            Teacher.objects.create(name='唐元亮')
        return render(request, 'visits/createVisits.html',
                      {'visitForm': VisitForm()})

    #POST
    visitsForm = VisitForm(data=request.POST)
    if not visitsForm.is_valid():
        return render(request, 'visits/createVisits.html',
                      {'visitForm': visitsForm})

    visitsForm.save()

    return redirect(reverse('visits:visits'))
示例#3
0
def create(request):

    if request.method == "GET":
        if Demand.objects.all().count() == 0:
            Demand.objects.create(type="雲端")
            Demand.objects.create(type="大數據")
            Demand.objects.create(type="智慧製造")
            Demand.objects.create(type="物聯網")
            Demand.objects.create(type="系統開發")
            Department.objects.create(name="資管")
            Department.objects.create(name="資工")
            Department.objects.create(name="資通")
            Teacher.objects.create(name="唐元亮")
        return render(request, "visits/createVisits.html", {"visitForm": VisitForm()})

    # POST
    visitsForm = VisitForm(data=request.POST)
    if not visitsForm.is_valid():
        return render(request, "visits/createVisits.html", {"visitForm": visitsForm})

    visitsForm.save()

    return redirect(reverse("visits:visits"))
示例#4
0
文件: views.py 项目: jpat/Travlr
def add_trip(request):
    if request.method == 'POST':
        form = VisitForm(request.POST)

        if form.is_valid():
            visit = form.save(commit=False)
            visit.user = request.user
            visit.save()
            form.save_m2m()
            return HttpResponseRedirect(reverse('thanks'))

    else:
        form = VisitForm()
    return render_to_response('visits/add_trip.html', {'form': form}, context_instance=RequestContext(request))
示例#5
0
def getVisit(request, visitID):
    visit = VisitModel.objects.get(id=visitID)
    visit = VisitForm(instance=visit)
    return render(request, 'visits/visit.html', {'visitForm': visit})