def getAcceptedCancelledApplicants(self,front_end_str):
		""" Read from csv only accepted applicants """

		front_end_dict = ast.literal_eval(front_end_str)
		front_end_data = front_end_dict['data'][0]

		data = self.getFromCsv('applicant.csv',front_end_data)

		apps = application_status.Application_status()
		new_data = apps.getApplicationStatus(front_end_str)

		new_data_check = ast.literal_eval(new_data)
		data_accepted = new_data_check['data']

		accepted_applicant_id = []
		for i in range(0,len(data_accepted)):
			if data_accepted[i]['application_status'] in (1,2):
				accepted_applicant_id.append(data_accepted[i]['applicant_id'])

		cancelled_data = []
		for i in range(0,len(data)):
			if data[i]['applicant_id'] in accepted_applicant_id:
				cancelled_data.append(data[i])

		return cancelled_data
	def getCheckInStatus(self,front_end_str):

		front_end_dict = ast.literal_eval(front_end_str)
		front_end_data = front_end_dict['data'][0]
		
		cf = common_functions.Common_functions()
		data = cf.getFromCsv('applicant.csv',front_end_data)

		apps = application_status.Application_status()
		new_data = apps.getApplicationStatus(front_end_str)

		new_data_check = ast.literal_eval(new_data)
		data_accepted = new_data_check['data']

		accepted_applicant_id = []
		for i in range(0,len(data_accepted)):
			if data_accepted[i]['application_status'] == 1:
				accepted_applicant_id.append(data_accepted[i]['applicant_id'])

		return_data = []
		for i in range(0,len(data)):
			if data[i]['applicant_id'] in accepted_applicant_id:
				return_data.append(data[i])

		if len(data) == 0:
			return_front_end_dict = '{ "data": [], "status":"success", "message":"No applicants registered" }'
		else:
			return_front_end_dict = '{ "data": ' + json.dumps(return_data) + ', "status":"success", "message":"All applicant''s information retrieved" }'

		return return_front_end_dict
	def test_getApplicationStatus(self):
		""" testing function getApplicationStatus """
		
		appl_st = application_status.Application_status()
		
		data = self.getFromCsv('test_data_registration.csv',{})
		return_front_end_dict = '{ "data": ' + json.dumps(data) + '}'
		
		for i range(0,len(data)):
			out1 = appl_st.getApplicationStatus(return_front_end_dict)
Ejemplo n.º 4
0
def application_status_send(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["vol_name"]
    try:
        a = application_status.Application_status()
        st = a.updateApplicationStatus(data)
    except Exception as e:
        st = e
    return HttpResponse(st, content_type="application/type")
Ejemplo n.º 5
0
def assignment_tribe(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["tribe"]
    dt = choose_date.Choose_date()
    st = dt.chooseDate()
    print(st)
    cis = application_status.Application_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"]
    front_end_str = '{"data" :[{"camp_time_slots":"' + camp_slot + '","no_of_tribes":"' + json.loads(
        data)["data"][0]["no_of_tribes"] + '"}]}'
    aob = assignment_of_tribes.Assignment_of_tribes()
    st = aob.readTribesData(front_end_str)
    return HttpResponse(st, content_type="application/type")
Ejemplo n.º 6
0
def test_js_get_appl(request):
    c = {}
    c.update(csrf(request))
    data = request.POST["vol_name"]
    try:
        dt = choose_date.Choose_date()
        st = dt.chooseDate()
        print(st)
        cis = application_status.Application_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.getApplicationStatus('{"data" :[{"camp_time_slots":"' +
                                          camp_slot + '"}]}')
        print(st_get)
    except Exception as e:
        st_get = e
        print(st_get)
    return HttpResponse(st_get, content_type="application/type")
	def test_updateApplicationStatus(self):
		appl_st = application_status.Application_status()
		appl_st.updateApplicationStatus()
Ejemplo n.º 8
0
import sys
import json
import ast
sys.path.append("Python/User_Stories")
import application_status

front_end_str1 = json.dumps(
    {"data": [{
        "camp_time_slots": "2017-01-08 00:00:00.000000"
    }]})
front_end_str2 = json.dumps({
    "data": [{
        "applicant_id": "1",
        "acceptance_packet": "0",
        "rejected_reason": "Date pending"
    }, {
        "applicant_id": "7",
        "acceptance_packet": "1",
        "rejected_reason": "Date pending 2"
    }]
})

apps = application_status.Application_status()
st = apps.getApplicationStatus(front_end_str1)

#st = apps.updateApplicationStatus(front_end_str2)
print(st)
    def printAcceptanceRejection(self, front_end_str):

        front_end_dict = ast.literal_eval(front_end_str)
        front_end_data = front_end_dict['data'][0]
        #print('front_end_data :',front_end_data)

        cf = common_functions.Common_functions()
        data = cf.getFromCsv('applicant.csv', front_end_data)
        #print(data)

        app = application_status.Application_status()
        data1 = app.getApplicationStatus(front_end_str)
        data2 = ast.literal_eval(data1)
        data3 = data2['data']
        #print("data2 :",data2)

        #print(data)
        #print("data3[0]['violations'] :",data3[0]["violations"])

        data[0]["violations"] = data3[0]["violations"]
        data[0]["application_status"] = data3[0]["application_status"]
        #print
        data[0]["camp_time_slots"] = data[0]["camp_time_slots"][:10]

        if data[0]["violations"][0] == "NO VIOLATIONS":
            file_print = "Textfiles/Templates/a_template.txt"
            path_name = "acception_letter"
        else:
            file_print = "Textfiles/Templates/r_template.txt"
            path_name = "rejection_letter"

        with open(file_print, "r") as myfile:
            template = myfile.readlines()
            temp = ''.join(template)

        k = 1
        Str = ''
        for j in range(0, len(data)):
            t = temp
            for i in data[j].keys():
                if ('*' + i + '*' in temp):
                    try:
                        t = t.replace('*' + i + '*', data[j][i])
                    except:
                        pass
            #print("--------------------------------")
            Str = ''
            for m in range(0, len(data[j]['violations'])):
                if m == 0:
                    Str = str(m + 1) + '. ' + data[j]['violations'][m]
                else:
                    Str = Str + '\n' + str(m +
                                           1) + '. ' + data[j]['violations'][m]
            #print(type(Str))
            t = t.replace("*violations*", Str)
            #print ("yes")

            #print(t)
        user = getpass.getuser()
        save_path = 'C:/Users/' + user + '/Documents/Gila_Breath_Camp'

        if not os.path.exists(save_path):
            os.makedirs(save_path)

        name_of_file = data[0]["applicant_first_name"] + "_" + data[0][
            "applicant_last_name"] + "_" + data[0][
                "applicant_id"] + "_" + path_name
        completeName = os.path.join(save_path, name_of_file + ".txt")
        text_file = open(completeName, "w")
        text_file.write(t)
        text_file.close()
        print(t)
        return (t)