Exemple #1
0
def priorities_get(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["prior"]
    print(data)
    dt = choose_date.Choose_date()
    st = dt.chooseDate()
    camp_slot = ''
    cis = check_in_status.Check_in_status()
    if json.loads(data)["data"][0]["date_id"] == "1":
        camp_slot = json.loads(st)["data"][0]["camp_time_slots1"]
    elif json.loads(data)["data"][0]["date_id"] == "2":
        camp_slot = json.loads(st)["data"][0]["camp_time_slots2"]
    elif json.loads(data)["data"][0]["date_id"] == "3":
        camp_slot = json.loads(st)["data"][0]["camp_time_slots3"]
    st_get = cis.getCheckInStatus('{"data" :[{"camp_time_slots":"' +
                                  camp_slot + '"}]}')
    print(camp_slot)
    front_end_str111 = '{"data" :[{"camp_time_slots":"' + camp_slot + '"}]}'
    try:
        pr = priorities.Priorities()
        st = pr.getCustomerPriorities(front_end_str111)
    except Exception as e:
        st = e
    return HttpResponse(st, content_type="application/type")
 def test_max(self):
     prio = p.Priorities()
     prio.setdict({"a": 2, "b": 4, "c": 7})
     self.assertEqual(prio.max(), 7)
     prio.scaleweight("c", 0.2)
     self.assertEqual(prio.max(), 4)
     prio.scaleweight("a", 5)
     self.assertEqual(prio.max(), 10)
 def test_min(self):
     prio = p.Priorities()
     prio.setdict({"a": 2, "b": 4, "c": 10})
     self.assertEqual(prio.min(), 2)
     prio.scaleweight("a", 5)
     self.assertEqual(prio.min(), 4)
     prio.scaleweight("c", 0.2)
     self.assertEqual(prio.min(), 2)
Exemple #4
0
def priorities_set_submit(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["prior"]
    print(data)
    pr = priorities.Priorities()
    st = pr.updateCustomerPriorities(data)
    print(st)
    return HttpResponse(st, content_type="application/type")
Exemple #5
0
def priorities_get_guar_ssn(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["prior"]
    print(data)
    pr = priorities.Priorities()
    st = pr.getId(data)
    print(st)
    return HttpResponse(st, content_type="application/type")
 def test_isempty(self):
     prio = p.Priorities()
     self.assertFalse(bool(prio.dict))
     self.assertEqual(len(prio.dict), 0)
     self.assertTrue(prio.isempty())
     prio.setweight("apples", 7)
     self.assertTrue(bool(prio.dict))
     self.assertEqual(len(prio.dict), 1)
     self.assertFalse(prio.isempty())
 def test_getweight(self):
     prio = p.Priorities()
     prio.setweight("some", 3)
     self.assertEqual(prio.getweight("some"), 3)
     prio.scaleweight("some", 2)
     self.assertEqual(prio.getweight("some"), 6)
     exc = e.IllegalNegativeException
     self.assertRaises(exc, prio.scaleweight, "some", -2)
     self.assertEqual(prio.getweight("some"), 6)
 def test_setweight(self):
     prio = p.Priorities()
     prio.setweight("apples", 10)
     self.assertEqual(prio.dict["apples"], 10)
     prio.setweight("apples", 38)
     self.assertEqual(prio.dict["apples"], 38)
     prio.setweight("pears", 38)
     self.assertEqual(prio.dict["apples"], 38)
     self.assertEqual(prio.dict["pears"], 38)
 def test_scaleweight(self):
     prio = p.Priorities()
     prio.setweight("apples", 7)
     prio.setweight("pears", 2)
     self.assertEqual(prio.dict["apples"], 7)
     self.assertEqual(prio.dict["pears"], 2)
     prio.scaleweight("apples", 3)
     self.assertEqual(prio.dict["apples"], 21)
     self.assertEqual(prio.dict["pears"], 2)
     prio.scaleweight("bananas", 4.1)
     self.assertEqual(prio.dict["bananas"], 4.1)
     exc = e.IllegalNegativeException
     self.assertRaises(exc, prio.scaleweight, "pears", -2)
Exemple #10
0
 def tryfill(self):
     c = self.conf
     r = c.restr
     for iday in range(0, self.ndays):
         for ishift in range(0, self.nshiftsperday):
             # only fill if empty (i.e. not pre-defined)
             if self.arr[iday][ishift] == "":
                 # we assume at first that all staff members are available
                 # we also assume that we work at minimum staff
                 kpersons = r.dict["minpersonspershift"]
                 kquali = 1
                 # kquali = r.randrange(minqualipershift,
                 #                      maxqualipershift + 1)
                 kreg = max(0, kpersons - kquali)
                 # first generate favorites and vetoes arrays
                 prio = p.Priorities()
                 if iday >= 1:
                     onedayago = ((self.arr[iday - 1][ishift]).split(
                         c.str_sep))
                     for employee in onedayago:
                         # person only favorite
                         #   if not in all last (maxdaysinrow) days,
                         #   else vetoed.
                         if self.isinalllastndays(employee, iday,
                                                  r.dict["maxdaysinrow"]):
                             prio.setweight(employee, 0)
                         elif self.isinalllastndays(
                                 employee, iday,
                             (r.dict["maxdaysinrow"] - 1)):
                             prio.setweight(employee, c.favwgtdimin)
                         elif self.isinexactlyalllastndays(
                                 employee, iday, 2):
                             prio.setweight(employee, c.favwgtaugm)
                         elif self.isinexactlyalllastndays(
                                 employee, iday, 1):
                             prio.setweight(employee, c.favwgtaugm)
                         else:
                             prio.setweight(employee, c.favwgt)
                     for employee in (self.qualified + self.regular):
                         lastshiftname = getlastshiftname(
                             employee, self.arr, iday, ishift, self.conf)
                         if lastshiftname != c.shiftnames[ishift]:
                             # Scale weight down if would be shift change
                             lastday = self.getlastday(employee, iday)
                             if lastday >= 0 and iday - lastday == 1:
                                 prio.scaleweight(employee, c.sclshiftjump)
                             else:
                                 prio.scaleweight(employee, c.sclshiftchng)
                 for i in range(0, kquali):
                     # weighted averaging:
                     rnd = pickwithpriorities(self.qualified, prio)
                     # this one-shift-of-person-per-day rule
                     # is implicitly assumed here
                     # (without using the integer defined above)
                     nfails = 0
                     while not self.wouldbeok(rnd, iday, ishift):
                         nfails += 1
                         if nfails > c.maxnfails:
                             return 1
                         rnd = pickwithpriorities(self.qualified, prio)
                     oldstr = self.arr[iday][ishift]
                     self.arr[iday][ishift] = addtoshift(
                         rnd, oldstr, self.conf)
                 for i in range(0, kreg):
                     # weighted averaging:
                     rnd = pickwithpriorities(self.regular, prio)
                     nfails = 0
                     # this one-shift-of-person-per-day rule
                     # is implicitly assumed here
                     # (without using the integer defined above)
                     while not self.wouldbeok(rnd, iday, ishift):
                         nfails += 1
                         if nfails > c.maxnfails:
                             return 2
                         rnd = pickwithpriorities(self.regular, prio)
                     oldstr = self.arr[iday][ishift]
                     self.arr[iday][ishift] = addtoshift(
                         rnd, oldstr, self.conf)
     return 0
Exemple #11
0
import sys
import json
import ast
sys.path.append("Python/User_Stories")
import priorities

front_end_str1 = json.dumps(
    {"data": [{
        "camp_time_slots": "2017-02-12 00:00:00.000000"
    }]})
#front_end_str2 = json.dumps({"data" :[{"applicant_name_not_together_with":"GOHIL, JEMIN"}]})
#front_end_str3 = json.dumps({"data" :
#	[{"applicant_id":"1","name" : "GOHIL, JEMIN", "applicant_name_together_with":"KOHLI, VIRAT","applicant_id_together_with":"5","applicant_name_not_together_with":"NONE","applicant_id_not_together_with":"NONE"},
#	{"applicant_id":"2","name" : "BASAVANAHALLI, KATHIK", "applicant_name_together_with":"NONE","applicant_id_together_with":"NONE","applicant_name_not_together_with":"GOHIL, JEMIN","applicant_id_not_together_with":"3"}
#	]})
#
pr = priorities.Priorities()
st = pr.getCustomerPriorities(front_end_str1)

#st = pr.getId(front_end_str2)

#st = pr.updateCustomerPriorities(front_end_str3)
print(st)
 def test_init(self):
     prio = p.Priorities()
     # prio.dict should be initialized empty, but do exist
     self.assertTrue(bool(prio))
     self.assertFalse(bool(prio.dict))
 def test_setdict(self):
     d = {"a": 3, "c": 5, "b": 7}
     prio = p.Priorities()
     prio.setdict(d)
     self.assertEqual(d, prio.dict)