def post(self, prospect_id=None, operation=None, key=None): prospect = db.get_prospect_from_prospect_id(prospect_id) prospect_note_form = ProspectNoteForm().get_form(self.request.POST) if prospect_note_form.validate(): prospect_note = None if operation == "add": prospect_note = ProspectNote() if operation == "edit": note_key = ndb.Key(urlsafe=key) prospect_note = note_key.get() prospect_note.prospect = prospect.key prospect_note_form.populate_obj(prospect_note) google_user = users.get_current_user() prospect_note.user = google_user prospect_note.put() # re calculate notes stats prospect.calculate_notes_stats() self.redirect("/admin/prospects/" + prospect.prospect_id) else: # validation failed self.render_details(prospect, prospect_note_form=prospect_note_form)
def post(self, prospect_id=None): prospect = db.get_prospect_from_prospect_id(prospect_id) prospect_employment_tags_form = ProspectEmploymentTagsForm().get_form( self.request.POST) if prospect_employment_tags_form.validate(): if prospect_employment_tags_form['employment_tags'].data is None: prospect.employment_tags = [] else: prospect_employment_tags_form.populate_obj(prospect) prospect.put() prospect_note = ProspectNote() prospect_note.prospect = prospect.key google_user = users.get_current_user() prospect_note.user = google_user prospect_note.note_type = 'admin' prospect_tags_string = "" for tag in prospect.employment_tags: prospect_tags_string += tag + ', ' # chop the last comma prospect_tags_string = prospect_tags_string[:-2] # escape underscores for markdown prospect_tags_string = prospect_tags_string.replace('_', '\_') if not prospect_tags_string: prospect_note.body = "Deleted employment tags" else: prospect_note.body = 'Updated employment tags to: ' + prospect_tags_string prospect_note.put() self.redirect('/admin/prospects/' + prospect.prospect_id)
def create_prospect_email_note(self, prospect, campaign, email_text): prospect_note = ProspectNote() prospect_note.prospect = prospect.key prospect_note.campaign = campaign.key google_user = users.get_current_user() prospect_note.user = google_user prospect_note.note_type = 'email' prospect_note.body = email_text prospect_note.put()
def post(self, prospect_id=None): prospect = db.get_prospect_from_prospect_id(prospect_id) prospect_employment_tags_form = ProspectEmploymentTagsForm().get_form(self.request.POST) if prospect_employment_tags_form.validate(): if prospect_employment_tags_form["employment_tags"].data is None: prospect.employment_tags = [] else: prospect_employment_tags_form.populate_obj(prospect) prospect.put() prospect_note = ProspectNote() prospect_note.prospect = prospect.key google_user = users.get_current_user() prospect_note.user = google_user prospect_note.note_type = "admin" prospect_tags_string = "" for tag in prospect.employment_tags: prospect_tags_string += tag + ", " # chop the last comma prospect_tags_string = prospect_tags_string[:-2] # escape underscores for markdown prospect_tags_string = prospect_tags_string.replace("_", "\_") if not prospect_tags_string: prospect_note.body = "Deleted employment tags" else: prospect_note.body = "Updated employment tags to: " + prospect_tags_string prospect_note.put() self.redirect("/admin/prospects/" + prospect.prospect_id)
def post(self, prospect_id=None, operation=None, key=None): prospect = db.get_prospect_from_prospect_id(prospect_id) prospect_note_form = ProspectNoteForm().get_form(self.request.POST) if prospect_note_form.validate(): prospect_note = None if operation == 'add': prospect_note = ProspectNote() if operation == 'edit': note_key = ndb.Key(urlsafe=key) prospect_note = note_key.get() prospect_note.prospect = prospect.key prospect_note_form.populate_obj(prospect_note) google_user = users.get_current_user() prospect_note.user = google_user prospect_note.put() # re calculate notes stats prospect.calculate_notes_stats() self.redirect('/admin/prospects/' + prospect.prospect_id) else: # validation failed self.render_details(prospect, prospect_note_form=prospect_note_form)