Created
July 10, 2014 09:08
-
-
Save divyanshikathuria/cc4622d83916922f8307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from models import TaDa | |
from forms import TaDaForm | |
from django.db.models import Sum | |
def tada_form(request): | |
ob= TaDa.objects.filter(id=1).values('departure_time_from_tcc','arrival_time_at_site', | |
'departure_time_from_site','arrival_time_at_tcc', | |
'tada_amount','start_test_date','end_test_date', | |
'testing_site','testing_staff') | |
form = TaDaForm(initial = { 'tada_amount': '10' }) | |
return render( request, 'suspence/tada_form.html', { 'form' : form } ) | |
def tada_result(request): | |
if 'Submit' in request.GET: | |
departure_time_from_tcc = request.GET['departure_time_from_tcc'] | |
arrival_time_at_site = request.GET['arrival_time_at_site'] | |
departure_time_from_site= request.GET['departure_time_from_site'] | |
arrival_time_at_tcc= request.GET['arrival_time_at_tcc'] | |
tada_amount= request.GET['tada_amount'] | |
start_test_date=request.GET['start_test_date'] | |
end_test_date= request.GET['end_test_date'] | |
testing_site= request.GET['testing_site'] | |
testing_staff= request.GET['testing_staff'] | |
obj= TaDa(departure_time_from_tcc =departure_time_from_tcc ,arrival_time_at_site=arrival_time_at_site, | |
departure_time_from_site=departure_time_from_site,arrival_time_at_tcc=arrival_time_at_tcc, | |
tada_amount=tada_amount,start_test_date=start_test_date,end_test_date=end_test_date, | |
testing_site=testing_site,testing_staff=testing_staff) | |
obj.save() | |
obj1= TaDa.objects.filter(suspence_id=1).values('departure_time_from_tcc','arrival_time_at_site', | |
'departure_time_from_site','arrival_time_at_tcc', | |
'tada_amount','start_test_date','end_test_date', | |
'testing_site','testing_staff') | |
total = TaDa.objects.filter(suspence_id=1).aggregate(Sum('tada_amount')).get('tada_amount__sum', 0.00) | |
return render(request, 'suspence/tada_result.html', { 'obj': obj1, 'total cost': 'total'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment