Esempio n. 1
0
  def load_contacts(self):
    reader = self.get_reader("Contacts.csv")
    for line in reader:
      d = {}
      d['email'] = line['Email Address']
      d['job_title'] = line['Title']
      for col in ['First Name', 'Last Name', 'Department']:
        d[col.lower().replace(" ", "_")] = line[col]

      for k in ['Street', 'City', 'State', 'Country']:
        d["address_" + k.lower()] = line["Primary Address %s" % k]

      contact = Contact(**d)

      contact.creator_id = choice(self.users).uid
      contact.owner_id = choice(self.users).uid

      account = self.accounts_map.get(line['Account Name'])
      if account:
        contact.account = account

      self.db.session.add(contact)