def set_obj_attr(self): """ Create comments """ if self.dry_run or not self.value: return current_obj = self.row_converter.obj for description in self.value: if current_obj.access_control_list: current_user = get_current_user() assignee_types = [ acl.ac_role.name for person, acl in current_obj.access_control_list if person == current_user ] assignee_type = ','.join(assignee_types) comment = all_models.Comment( description=description, modified_by_id=get_current_user_id(), assignee_type=assignee_type) else: comment = all_models.Comment( description=description, modified_by_id=get_current_user_id()) db.session.add(comment) mapping = all_models.Relationship(source=current_obj, destination=comment) db.session.add(mapping) self.row_converter.comments.append(comment)
def set_obj_attr(self): """ Create comments """ if self.dry_run or not self.value: return current_obj = self.row_converter.obj for description in self.value: comment = all_models.Comment(description=description, modified_by_id=get_current_user_id()) db.session.add(comment) mapping = all_models.Relationship(source=current_obj, destination=comment) db.session.add(mapping)
def _handle_raw_data(self): """Pass raw values into column handlers for all cell in the row.""" row_headers = { attr_name: (idx, header_dict) for idx, (attr_name, header_dict) in enumerate(self.headers.iteritems()) } if self.object_class == all_models.Comment: self.obj = all_models.Comment(modified_by_id=get_current_user_id()) for attr_name in self.block_converter.handle_fields: if attr_name not in row_headers or self.is_delete: continue idx, header_dict = row_headers[attr_name] self.handle_raw_cell(attr_name, idx, header_dict)
def add_comment_about(proposal, reason, txt): """Create comment about proposal for reason with required text.""" if not isinstance(proposal.instance, comment.Commentable): return txt = txt or "" txt = txt.strip() if txt.startswith("<p>"): txt = txt[3:] if txt.endswith("</p>"): txt = txt[:-4] txt = txt.strip() comment_text = proposal.build_comment_text(reason, txt, proposal.proposed_by) created_comment = all_models.Comment( description=comment_text, modified_by_id=login.get_current_user_id(), initiator_instance=proposal) all_models.Relationship(source=proposal.instance, destination=created_comment)