Ejemplo n.º 1
0
 def capture_data(self):
     """
     Grap the information from the window's text field and save the candidate information based on candidate_uid.
     """
     # open the 'database'
     db = dict(DataManagement.read_candidate_data())
     # and find candidate based on uid
     uid = self.candidate_uid
     candidate = db[uid]
     # capture data from fields
     candidate.pscid = self.text_pscid.get()
     candidate.status = self.text_status.get()
     candidate.firstname =  self.text_firstname.get()
     candidate.lastname = self.text_lastname.get()
     candidate.phone = self.text_phone.get()
     # save data
     DataManagement.save_candidate_data(db)
import candidate
import lib.datamanagement as datamanagement


#GUI:  Setting up a list of candidate
#print '\nGUI:  ENTERING DATA FOR MULTIPLE CANDIDATES'
#TODO add duplicate control by checking for name+phone number
candidatedb = {}

candidatedata = candidate.Candidate('Billy', 'Roberts', '451-784-9856', otherphone='514-874-9658')
candidatedb[candidatedata.uid] = candidatedata

candidatedata = candidate.Candidate('Sue', 'Allen', '451-874-9632')
candidatedb[candidatedata.uid] = candidatedata

candidatedata = candidate.Candidate('Alan', 'Parson', '451-874-8965')
candidatedb[candidatedata.uid] = candidatedata

candidatedata = candidate.Candidate('Pierre', 'Tremblay', '547-852-9745')
candidatedb[candidatedata.uid] = candidatedata

candidatedata = candidate.Candidate('Alain', 'Jeanson', '245-874-6321')
candidatedb[candidatedata.uid] = candidatedata

candidatedata = candidate.Candidate('Marc', 'St-Pierre', '412-897-9874')
candidatedb[candidatedata.uid] = candidatedata

datamanagement.save_candidate_data(candidatedb)

#TESTED
DataManagement.save_study_data(studydb)
studyvisit = visit.VisitSetup(2, "V1", "V0", 10, 2)
studydb[studyvisit.uid] = studyvisit
DataManagement.save_study_data(studydb)
studyvisit = visit.VisitSetup(3, "V2", "V1", 20, 10)
studydb[studyvisit.uid] = studyvisit
DataManagement.save_study_data(studydb)

# create a list of candidate
# saving (DataManagement.save_candidate_data(candidatedb)) after each candidate is really not necessary
# firstname, lastname, phone, uid=None, visitset = None, status = None, pscid=None, **kwargs
# but this mimics the way the application wil work
candidatedb = {}
candidatedata = candidate.Candidate("Billy", "Roberts", "451-784-9856", otherphone="514-874-9658")
candidatedb[candidatedata.uid] = candidatedata
DataManagement.save_candidate_data(candidatedb)

candidatedata = candidate.Candidate("Sue", "Allen", "451-874-9632", None, None, None, 1234567)
candidatedb[candidatedata.uid] = candidatedata
DataManagement.save_candidate_data(candidatedb)

candidatedata = candidate.Candidate("Alan", "Parson", "451-874-8965")
candidatedb[candidatedata.uid] = candidatedata
DataManagement.save_candidate_data(candidatedb)

candidatedata = candidate.Candidate("Pierre", "Tremblay", "547-852-9745")
candidatedb[candidatedata.uid] = candidatedata
DataManagement.save_candidate_data(candidatedb)

candidatedata = candidate.Candidate("Alain", "Jeanson", "245-874-6321")
candidatedb[candidatedata.uid] = candidatedata