def action_hash(self, ids): try: for i in ids: set_hash(i) flash('Hashing requested for %s objects.' % (len(ids)), 'info') except Exception as ex: flash('Failed to delete models. %s' % (str(ex)), 'error')
def submit(submitter, source, group=None, filename=None, suffix=None, cves=[], metadata={}, entry=None, approval='REQUESTED'): config.LOGGER.info('Submitting: %s' % ( ', '.join(['%s:%s' % (k, v) for (k, v) in locals().items()]))) submission = Submission() submission.source = source submission.group = group submission.filename = filename if suffix: submission.format = suffix.title() submission.cves = cves if entry and entry.cves: for cve in entry.cves: if cve not in entry.cves: submission.cves.append(cve) submission.metadata = metadata submission.submitter = submitter if entry: submission.entry = entry submission.approval = approval submission.validate() submission.save() set_hash(submission) # ensure index stats are refreshed indexmon.refresh()
def after_model_change(self, form, model, is_created): if bool(form.request_hashing.data): model.entry = None set_hash(model) super(SubmissionView, self).after_model_change(form, model, is_created)