Esempio n. 1
0
 def helper1(request, plan_key, start, end, cities, elem):
     p = Plan(owner=request.user, key=plan_key, source=source, budget=budget)
     p.save()
     d = DateInPlan(start=start, end=end, plan=p)
     d.save()
     for c in cities:
         c = c.split(',')
         city = c[0].strip()
         state = c[1].strip()
         obj = City.objects.get(city=city, state = state)
         weight.append(obj)
         cp = CityInPlan(city=obj, plan=p, owner=request.user)
         cp.save()
     return weight
Esempio n. 2
0
 def helper2(request, plan_key, start, end, cities, elem):
     elem = elem[0]
     dp = DateInPlan.objects.get(plan=elem)
     if start.date() > dp.start:
         dp.start = start
     if end.date() < dp.end:
         dp.end = end
     dp.save()
     for c in cities:
         c = c.split(',')
         city = c[0].strip()
         state = c[1].strip()
         obj = City.objects.get(city=city, state=state)
         weight.append(obj)
         cp = CityInPlan(city=obj, plan=elem, owner=request.user)
         cp.save()
     return weight
Esempio n. 3
0
 def helper1(request, plan_key, start, end, cities, elem):
     p = Plan(owner=request.user,
              key=plan_key,
              source=source,
              budget=budget)
     p.save()
     d = DateInPlan(start=start, end=end, plan=p)
     d.save()
     for c in cities:
         c = c.split(',')
         city = c[0].strip()
         state = c[1].strip()
         obj = City.objects.get(city=city, state=state)
         weight.append(obj)
         cp = CityInPlan(city=obj, plan=p, owner=request.user)
         cp.save()
     return weight
Esempio n. 4
0
 def helper2(request, plan_key, start, end, cities, elem):
     elem = elem[0]
     dp = DateInPlan.objects.get(plan=elem)
     if start.date() > dp.start:
         dp.start = start
     if end.date() < dp.end:
         dp.end = end
     dp.save()
     for c in cities:
         c = c.split(',')
         city = c[0].strip()
         state = c[1].strip()
         obj = City.objects.get(city=city, state = state)
         weight.append(obj)
         cp = CityInPlan(city=obj, plan=elem, owner=request.user)
         cp.save()
     return weight