def create_applicant(self): applicant = Applicant(title=self.regis_data['title'], first_name=self.regis_data['first_name'], last_name=self.regis_data['last_name'], email=self.regis_data['email']) password = applicant.random_password() applicant.save() registration = Registration(applicant=applicant, first_name=applicant.first_name, last_name=applicant.last_name) registration.random_and_save() return applicant, password
def create_applicant(self): applicant = Applicant( title=self.regis_data['title'], first_name=self.regis_data['first_name'], last_name=self.regis_data['last_name'], email=self.regis_data['email'] ) password = applicant.random_password() applicant.save() registration = Registration( applicant=applicant, first_name=applicant.first_name, last_name=applicant.last_name ) registration.random_and_save() return applicant, password
def test_activation_key_verification(self): applicant = Applicant(first_name='สมชาย', last_name='ใจดี', email='*****@*****.**') applicant.save() keys = [] # try with 3 registrations for i in range(3): registration = Registration(applicant=applicant, first_name='s', last_name='c') registration.random_and_save() keys.append(registration.activation_key) for k in keys: self.assertTrue(applicant.verify_activation_key(k)) self.assertFalse(applicant.verify_activation_key('1234567')) for k in keys: self.assertFalse(applicant.verify_activation_key('1'+k))
def main(): f = codecs.open(result_filename,encoding='utf8') lines = f.readlines() c = 0 c1 = 0 for l in lines: items = l.strip().split(',') if len(items)==7: nat_id, title, first_name, last_name, email, password, major = items try: a = Applicant.objects.get(national_id=nat_id) except: a = Applicant(national_id=nat_id, title=title, first_name=first_name, last_name=last_name, email=email) a.random_password() print 'created applicant for', nat_id c1 += 1 a.has_additional_result = True if len(password)>10: a.additional_hashed_password = password else: a.set_password(password) a.save() old_results = AdditionalResult.objects.filter(applicant=a, round_number=round_number).all() if len(old_results)==0: additional_result = AdditionalResult(applicant=a) else: additional_result = old_results[0] additional_result.name = major additional_result.round_number = round_number additional_result.save() c += 1 print "Imported %d applicants (%d created)" % (c,c1)
def main(): f = codecs.open(result_filename, encoding='utf8') lines = f.readlines() c = 0 c1 = 0 for l in lines: items = l.strip().split(',') if len(items) == 7: nat_id, title, first_name, last_name, email, password, major = items try: a = Applicant.objects.get(national_id=nat_id) except: a = Applicant(national_id=nat_id, title=title, first_name=first_name, last_name=last_name, email=email) a.random_password() print 'created applicant for', nat_id c1 += 1 a.has_additional_result = True if len(password) > 10: a.additional_hashed_password = password else: a.set_password(password) a.save() old_results = AdditionalResult.objects.filter( applicant=a, round_number=round_number).all() if len(old_results) == 0: additional_result = AdditionalResult(applicant=a) else: additional_result = old_results[0] additional_result.name = major additional_result.round_number = round_number additional_result.save() c += 1 print "Imported %d applicants (%d created)" % (c, c1)