def revoke_ballot(self, db_user: User, db_review: ReviewEdit): """ Revokes/Undo the implications of any successfull reviewed element :param db_user: :param db_review: :return: """ db_review = DBDiscussionSession.query(ReviewEdit).get(db_review.uid) db_review.set_revoked(True) DBDiscussionSession.query(LastReviewerEdit).filter_by( review_uid=db_review.uid).delete() db_value = DBDiscussionSession.query(ReviewEditValue).filter_by( review_edit_uid=db_review.uid) content = db_value.first().content db_value.delete() # delete forbidden textversion DBDiscussionSession.query(TextVersion).filter_by( content=content).delete() db_review_canceled = ReviewCanceled( author=db_user.uid, review_data={key_edit: db_review.uid}) DBDiscussionSession.add(db_review_canceled) DBDiscussionSession.flush() transaction.commit() return True
def revoke_ballot(self, db_user: User, db_review: ReviewMerge): """ Revokes/Undo the implications of any successfull reviewed element :param db_user: :param db_review: :return: """ db_review = DBDiscussionSession.query(ReviewMerge).get(db_review.uid) db_review.set_revoked(True) db_pgroup_merged = DBDiscussionSession.query( PremiseGroupMerged).filter_by(review_uid=db_review.uid).all() replacements = DBDiscussionSession.query( StatementReplacementsByPremiseGroupMerge).filter_by( review_uid=db_review.uid).all() undo_premisegroups(db_pgroup_merged, replacements) DBDiscussionSession.query(LastReviewerMerge).filter_by( review_uid=db_review.uid).delete() DBDiscussionSession.query(ReviewMergeValues).filter_by( review_uid=db_review.uid).delete() DBDiscussionSession.query( StatementReplacementsByPremiseGroupMerge).filter_by( review_uid=db_review.uid).delete() db_review_canceled = ReviewCanceled( author=db_user.uid, review_data={key_merge: db_review.uid}) DBDiscussionSession.add(db_review_canceled) DBDiscussionSession.flush() transaction.commit() return True
def __cancel_ongoing_duplicates_decision(db_review: ReviewDuplicate, db_user: User): """ Cancel an ongoing vote of the duplications queue :param db_review: ReviewDuplicate :param db_user: User """ DBDiscussionSession.query(ReviewDuplicate).get(db_review.uid).set_revoked(True) DBDiscussionSession.query(LastReviewerDelete).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'duplicate': db_review.uid}, was_ongoing=True)
def __revoke_old_optimizations_decision(db_review, db_user): """ :param db_review: :param db_user: :return: """ logger('review_history_helper', str(db_review.uid)) __revoke_decision_and_implications(ReviewOptimization, LastReviewerOptimization, db_review.uid) return ReviewCanceled(author=db_user.uid, review_data={'optimization': db_review.uid})
def __cancel_ongoing_splits_decision(db_review: ReviewSplit, db_user: User): """ Cancel an ongoing vote of the splits queue :param db_review: ReviewSplit :param db_user: User """ DBDiscussionSession.query(ReviewSplit).get(db_review.uid).set_revoked(True) DBDiscussionSession.query(LastReviewerSplit).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(PremiseGroupSplitted).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'split': db_review.uid}, was_ongoing=True)
def __cancel_ongoing_merges_decision(db_review: ReviewMerge, db_user: User): """ Cancel an ongoing vote of the merges queue :param db_review: ReviewOptimization :param db_user: User """ DBDiscussionSession.query(ReviewMerge).get(db_review.uid).set_revoked(True) DBDiscussionSession.query(LastReviewerMerge).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(PremiseGroupMerged).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'merge': db_review.uid}, was_ongoing=True)
def __cancel_ongoing_edits_decision(db_review: ReviewEdit, db_user: User): """ Cancel an ongoing vote of the edits queue :param db_review: ReviewOptimization :param db_user: User """ DBDiscussionSession.query(ReviewEdit).filter_by(uid=db_review.uid).delete() DBDiscussionSession.query(LastReviewerEdit).filter_by(review_uid=db_review.uid).first().set_revoked(True) DBDiscussionSession.query(ReviewEditValue).filter_by(review_edit_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'edit': db_review.uid}, was_ongoing=True)
def __cancel_ongoing_optimizations_decision(db_review: ReviewOptimization, db_user: User): """ Cancel an ongoing vote of the optimizations queue :param db_review: ReviewOptimization :param db_user: User :return: """ DBDiscussionSession.query(ReviewOptimization).get(db_review.uid).set_revoked(True) DBDiscussionSession.query(LastReviewerOptimization).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'optimization': db_review.uid}, was_ongoing=True)
def __revoke_old_duplicates_decision(db_review, db_user): """ :param db_review: :param db_user: :return: """ logger('review_history_helper', str(db_review.uid)) db_review = DBDiscussionSession.query(ReviewDuplicate).get(db_review.uid) db_review.set_revoked(True) __rebend_objects_of_duplicate_review(db_review) return ReviewCanceled(author=db_user.uid, review_data={'duplicate': db_review.uid})
def revoke_ballot(self, db_user: User, db_review: ReviewDelete): """ Revokes/Undo the implications of any successfull reviewed element :param db_user: :param db_review: :return: """ revoke_decision_and_implications(ReviewDelete, LastReviewerDelete, db_review.uid) db_review_canceled = ReviewCanceled(author=db_user.uid, review_data={key_delete: db_review.uid}) DBDiscussionSession.add(db_review_canceled) DBDiscussionSession.flush() transaction.commit() return True
def revoke_ballot(self, db_user: User, db_review: ReviewDuplicate): """ Revokes/Undo the implications of any successfull reviewed element :param db_user: :param db_review: :return: """ db_review = DBDiscussionSession.query(ReviewDuplicate).get(db_review.uid) db_review.set_revoked(True) self.__rebend_objects_of_review(db_review) db_review_canceled = ReviewCanceled(author=db_user.uid, review_data={key_duplicate: db_review.uid}) DBDiscussionSession.add(db_review_canceled) DBDiscussionSession.flush() transaction.commit() return True
def __revoke_old_merges_decision(db_review, db_user): """ :param db_review: :param db_user: :return: """ logger('review_history_helper', str(db_review.uid)) db_review = DBDiscussionSession.query(ReviewMerge).get(db_review.uid) db_review.set_revoked(True) db_pgroup_merged = DBDiscussionSession.query(PremiseGroupMerged).filter_by(review_uid=db_review.uid).all() replacements = DBDiscussionSession.query(StatementReplacementsByPremiseGroupMerge).filter_by(review_uid=db_review.uid).all() __undo_premisegroups(db_pgroup_merged, replacements) DBDiscussionSession.query(LastReviewerSplit).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(ReviewSplitValues).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(StatementReplacementsByPremiseGroupMerge).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'merges': db_review.uid})
def __revoke_old_edits_decision(db_review, db_user): """ :param db_review: :param db_user: :return: """ logger('review_history_helper', str(db_review.uid)) db_review = DBDiscussionSession.query(ReviewEdit).get(db_review.uid) db_review.set_revoked(True) DBDiscussionSession.query(LastReviewerEdit).filter_by(review_uid=db_review.uid).delete() db_value = DBDiscussionSession.query(ReviewEditValue).filter_by(review_edit_uid=db_review.uid) content = db_value.first().content db_value.delete() # delete forbidden textversion DBDiscussionSession.query(TextVersion).filter_by(content=content).delete() return ReviewCanceled(author=db_user.uid, review_data={'edit': db_review.uid})
def cancel_ballot(self, db_user: User, db_review: ReviewDelete): """ Cancels any ongoing vote :param db_user: current user :param db_review: any element from a review queue :return: """ DBDiscussionSession.query(ReviewDelete).get(db_review.uid).set_revoked(True) DBDiscussionSession.query(LastReviewerDelete).filter_by(review_uid=db_review.uid).delete() db_review_canceled = ReviewCanceled(author=db_user.uid, review_data={key_delete: db_review.uid}, was_ongoing=True) DBDiscussionSession.add(db_review_canceled) DBDiscussionSession.flush() transaction.commit() return True
def __revoke_old_splits_decision(db_review, db_user): """ :param db_review: :param db_user: :return: """ logger('review_history_helper', str(db_review.uid)) db_review = DBDiscussionSession.query(ReviewSplit).get(db_review.uid) db_review.set_revoked(True) db_pgroup_splitted = DBDiscussionSession.query(PremiseGroupSplitted).filter_by(review_uid=db_review.uid).all() replacements = DBDiscussionSession.query(StatementReplacementsByPremiseGroupSplit).filter_by(review_uid=db_review.uid).all() disable_args = [arg.uid for arg in DBDiscussionSession.query(ArgumentsAddedByPremiseGroupSplit).filter_by(review_uid=db_review.uid).all()] __undo_premisegroups(db_pgroup_splitted, replacements) __disable_arguments_by_id(disable_args) DBDiscussionSession.query(LastReviewerMerge).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(ReviewMergeValues).filter_by(review_uid=db_review.uid).delete() DBDiscussionSession.query(StatementReplacementsByPremiseGroupSplit).filter_by(review_uid=db_review.uid).delete() return ReviewCanceled(author=db_user.uid, review_data={'splits': db_review.uid})