def save_email_addresses(addresses_field: Text): '''Save email addresses from Text widget''' text = addresses_field.get(1.0, END) addresses = [{'email': address.strip()} for address in text.split('\n')] Address.delete().where(True).execute() Address.insert_many(addresses).execute()
def load_email_addresses_from_file(field: Text): address_records = prepare_email_addresses() Address.delete().where(True).execute() field.delete(1.0, END) Address.insert_many(address_records).execute() load_addresses_to_field(field) save_email_addresses(field)
def delete(self, address_uuid): result = Address.delete().where( Address.user == auth.current_user, Address.uuid == address_uuid, ).execute() if result == 0: return None, NOT_FOUND return None, NO_CONTENT
def setup_method(self): Address.delete().execute()