Example #1
0
 def handle_commit_participant(self, req_post):
     logging.info("Hit 'commit_participant'")
     ref_id = self.ref_id
     session = self.session
     assert req_post['claim'] == ref_id
     claim = session.query(Claim).filter_by(ref_id=ref_id).first()
     claim_id = claim.ref_id
     self.set_claim_form(claim)
     form = ParticipantCreate(req_post)
     self.set_participant_form_no_navigator_choices(form)
     form.participant_choice.data = "None"
     form.participant_choice.choices = [("None", "None")]
     form.validate()
     if form.errors:
         logging.warning("Participant Create Errors: {0}".format(repr(form.errors)))
         self.participant_form = form
         self.element_form = InactiveElementEdit(None)
         self.set_hidden_fields(claim_id, req_post['participant'], NOELEMENT)
     else:
         form = ParticipantEdit(self.request.POST)
         participant = Participant()
         new_ref_id = request_uid(self.session)
         transaction.commit()  # maybe not needed
         participant.ref_id = new_ref_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)
         participant.claim_id = ref_id
         parts, part_links, _ = get_participants(self.session, ref_id)
         parts[participant.ref_id] = participant
         self.participant_form = form
         property_key = expand_curie(form.participation_property.data)
         property_term = session.query(Property).filter_by(ref_id=property_key).one()
         part_links[participant.ref_id] = property_term
         self.set_participant_form(participant, parts)
         self.set_participant_form(participant, parts)
         self.element_form = ElementCreateOnly()
         self.element_form.expression_type.data = "None"
         self.element_form.expression_type.choices = expression_type_choice(session)
         session.add(participant)
         transaction.commit()
         self.update_graph(claim, parts, part_links)
         self.set_hidden_fields(claim_id, new_ref_id, NOELEMENT)
         logging.info("Exiting commit participant")
Example #2
0
 def handle_create_participant(self):
     ref_id = self.ref_id
     session = self.session
     claim = session.query(Claim).filter_by(ref_id=ref_id).first()
     assert isinstance(claim, Claim)
     self.set_claim_form(claim)
     self.set_claim_form_choices(self.claim_form)
     form = ParticipantCreate(None)
     self.element_form = InactiveElementEdit(None)
     if claim.narrative:
         form.type.data = "individual"
     else:
         form.type.data = "class"
     form.ref_id = 'UNASSIGNED'
     parts, part_links, active = get_participants(self.session, ref_id)
     self.participant_form = self.finish_participant_form(form, parts)  # ?
     self.update_graph(claim, parts, part_links)
     self.set_hidden_fields(claim.ref_id, NOPARTICIPANT, NOELEMENT)
Example #3
0
 def handle_form_g_e_t_request(self):
     ref_id = self.ref_id
     logging.info("GET request")
     if ref_id:
         claim = self.session.query(Claim).filter_by(ref_id=ref_id).one()
         self.set_claim_form(claim)
         parts, part_links, active = get_participants(self.session, ref_id)
         if parts:
             active_element = get_head_element(self.session, active)
             self.set_participant_form(active, parts)
             if active_element:
                 choices = element_choices(self.session, active)
                 self.set_element_form(active_element, choices)
                 self.set_hidden_fields(claim.ref_id, active.ref_id, str(active_element.element_id))
             else:
                 self.element_form = InactiveElementEdit(None)
                 self.set_hidden_fields(claim.ref_id, active.ref_id, NOELEMENT)
             if part_links:
                 self.update_graph(claim, parts, part_links)
         else:
             form = ParticipantCreate(None)
             form.ref_id = 'UNASSIGNED'
             if active:
                 form.type.data = active.type
             else:
                 form.type.data = 'UNASSIGNED'  # should guess from claim
             self.participant_form = self.finish_participant_form(form, parts)  # ?
             self.element_form = InactiveElementEdit(None)
             self.set_hidden_fields(claim.ref_id, NOPARTICIPANT, NOELEMENT)
     else:  # GET for claim edit w/o ref_id means create a new claim
         self.claim_form = ClaimCreate(None)
         self.set_claim_form_choices(self.claim_form)
         inactive_participant_form = InactiveParticipantEdit(None)
         inactive_element_form = InactiveElementEdit(None)
         self.participant_form = inactive_participant_form
         self.element_form = inactive_element_form
         self.set_hidden_fields(NOCLAIM, NOPARTICIPANT, NOELEMENT)