def randomContact(): contact = Contact() contact.fname=randomString(10) contact.mname=randomString(10) contact.lname=randomString(10) contact.phone=randomString(10) contact.bday=str(random.randint(1,29))+"/"+str(random.randint(1,12))+"/"+str(1950+random.randint(0,60)) return contact
def getContact(self): """get contacts from fields in gui""" contact = Contact() try: contact.cid = self.cidEdit.text() contact.fname = self.fnameEdit.text() contact.mname = self.mnameEdit.text() contact.lname = self.lnameEdit.text() contact.phone = self.phoneEdit.text() contact.bday = self.bdayEdit.text() except Exception as e: QMessageBox.question(self, 'Error', str(e), QMessageBox.Ok, QMessageBox.Ok) return contact
def load(): cur = con.cursor() table = cur.execute(""" Select record.z_pk, record.zfirstname, record.zlastname, record.znickname, record.zbirthdayyear, record.zbirthdayyearless, record.zjobtitle, record.zorganization, record.zdisplayflags, note.ztext from zabcdrecord as record left join ZABCDNOTE as note on record.z_pk == note.zcontact where ZSORTINGFIRSTNAME not NULL;""") contacts = [] for row in table: contact_id = row[0] addresses = get_address(contact_id) emails = get_email(contact_id) tels = get_tel(contact_id) is_company = False if (row[8] == 1): is_company = True contact = Contact(forename=row[1], surename=row[2], nickname=row[3], is_company=is_company, company=row[7], addresses=addresses, emails=emails, tels=tels, note=row[9]) if (row[4]): bday = date(row[4], 1, 1) + timedelta(seconds=row[5]) contact.bday = "{}-{}-{}".format(bday.year, bday.month, bday.day) contacts.append(contact) return contacts