(self, assessment)
Remove captures and local captures upon assessment deletion
Remove captures and local captures upon assessment deletion
Remove captures and local captures upon assessment deletion
def delete_captures(self, assessment):
        """
        Remove captures and local captures upon assessment deletion
        """
        cascaded_captures = Capture.query.filter_by(
            assessment=assessment.name).all()

        for capture in cascaded_captures:
            try:
                os.remove("uploads/{}.png".format(capture.screenshot))
                os.remove(
                    "uploads/small_{}.png".format(capture.screenshot))
            except:
                pass
        try:
            # Cascade delete for Assessment
            Capture.query.filter_by(assessment=assessment.name).delete()
            AccessLog.query.filter_by(assessment=assessment.name).delete()
            GenericCollector.query.filter_by(assessment=assessment.name).delete()
        except Exception as err:
            app.logger.warn(err)

        try:
            db.session.commit()
        except Exception as err:
            app.logger.warn(err)
def delete_captures ( self , assessment ) : cascaded_captures = Capture . query . filter_by ( assessment = assessment . name ) . all ( ) for capture in cascaded_captures : try : os . remove ( "uploads/{}.png" . format ( capture . screenshot ) ) os . remove ( "uploads/small_{}.png" . format ( capture . screenshot ) ) except : pass try : # Cascade delete for Assessment Capture . query . filter_by ( assessment = assessment . name ) . delete ( ) AccessLog . query . filter_by ( assessment = assessment . name ) . delete ( ) GenericCollector . query . filter_by ( assessment = assessment . name ) . delete ( ) except Exception as err : app . logger . warn ( err ) try : db . session . commit ( ) except Exception as err : app . logger . warn ( err )