def choose_participant_form(self, participant, post, parts):
     """Initialize the edit form that displays the participant."""
     form = ParticipantEdit(post)
     form.ref_id = participant.ref_id
     form.participation_property.data = make_curie(participant.participation_property)
     form.type.data = participant.type
     self.participant_form = self.finish_participant_form(form, parts)
 def handle_update_participant(self, req_post):
     logging.info("Hit 'update_participant'")
     claim_id = req_post['claim']
     assert claim_id == self.ref_id, "claim_id {0}, ref_id {1}".format(claim_id, self.ref_id)
     session = self.session
     claim = session.query(Claim).filter_by(ref_id=claim_id).one()
     self.set_claim_form(claim)
     participant_id = req_post['participant_choice']
     participant = get_participant(session, participant_id)
     parts, part_links, _ = get_participants(session, claim_id)
     form = ParticipantEdit(req_post)
     form.ref_id = participant_id
     form = self.finish_participant_form(form, parts)
     form.validate()
     if form.errors:
         active_element = get_head_element(session, participant)
         self.choose_element_form(req_post,
                                  active_element,
                                  element_choices(session, participant))
     else:
         logging.info("participant_choice: {0}".format(participant_id))
         participant.type = form.type.data
         participant.label = form.label.data
         participant.publication_taxon = form.publication_taxon.data
         participant.publication_anatomy = form.publication_anatomy.data
         participant.publication_substrate = form.publication_substrate.data
         participant.publication_text = form.publication_text.data
         participant.participation_property = expand_curie(form.participation_property.data)
     self.participant_form = form
     element_id = req_post['element']
     element = get_pelement(session, element_id)
     self.set_element_form(element, element_choices(session, participant))
     self.update_graph(claim, parts, part_links)
     self.set_hidden_fields(claim_id, participant_id, element_id)
 def set_participant_form(self, participant, parts):
     """Initialize the edit form that displays the participant."""
     form = ParticipantEdit(None, participant)
     assert form
     assert participant
     form.ref_id = participant.ref_id
     form.participation_property.data = make_curie(participant.participation_property)
     self.participant_form = self.finish_participant_form(form, parts)
     return self.participant_form
 def handle_abort_participant(self, req_post):
     session = self.session
     claim_id = req_post['claim']
     assert claim_id == self.ref_id, "claim_id {0}, ref_id {1}".format(claim_id, self.ref_id)
     claim = self.session.query(Claim).filter_by(ref_id=claim_id).one()
     self.set_claim_form(claim)
     parts, part_links, _ = get_participants(session, claim_id)
     participant_id = req_post['participant']
     participant = self.session.query(Participant).filter_by(ref_id=participant_id).first()
     form = ParticipantEdit(req_post)
     form.ref_id = participant_id
     self.participant_form = self.finish_participant_form(form, parts)
     if participant:
         head_element = get_head_element(session, participant)
         self.set_element_form(head_element,
                               element_choices(session, participant))
         if head_element:
             self.set_hidden_fields(claim_id, participant_id, head_element.id)
         else:
             self.set_hidden_fields(claim_id, participant_id, NOELEMENT)
     else:
         self.element_form = InactiveElementEdit()
         self.set_hidden_fields(claim_id, NOPARTICIPANT, NOELEMENT)