def edit_job(job_id): """ Edit a job's name and/or notes """ job = scheduler.get_job(job_id) if job is None: raise werkzeug.exceptions.NotFound('Job not found') # Edit name if 'job_name' in flask.request.form: name = flask.request.form['job_name'].strip() if not name: raise werkzeug.exceptions.BadRequest('name cannot be blank') job._name = name logger.info('Set name to "%s".' % job.name(), job_id=job.id()) # Edit notes if 'job_notes' in flask.request.form: notes = flask.request.form['job_notes'].strip() if not notes: notes = None job._notes = notes logger.info('Updated notes.', job_id=job.id()) return '%s updated.' % job.job_type()
def edit_job(job_id): """ Edit a job's name and/or notes """ job = scheduler.get_job(job_id) if job is None: raise werkzeug.exceptions.NotFound("Job not found") # Edit name if "job_name" in flask.request.form: name = flask.request.form["job_name"].strip() if not name: raise werkzeug.exceptions.BadRequest("name cannot be blank") job._name = name logger.info('Set name to "%s".' % job.name(), job_id=job.id()) # Edit notes if "job_notes" in flask.request.form: notes = flask.request.form["job_notes"].strip() if not notes: notes = None job._notes = notes logger.info("Updated notes.", job_id=job.id()) return "%s updated." % job.job_type()
def edit_job(job_id): """ Edit a job's name and/or notes """ job = scheduler.get_job(job_id) if job is None: raise werkzeug.exceptions.NotFound('Job not found') if not utils.auth.has_permission(job, 'edit'): raise werkzeug.exceptions.Forbidden() # Edit name if 'job_name' in flask.request.form: name = flask.request.form['job_name'].strip() if not name: raise werkzeug.exceptions.BadRequest('name cannot be blank') job._name = name job.emit_attribute_changed('name', job.name()) # update form data so updated name gets used when cloning job if 'form.dataset_name.data' in job.form_data: job.form_data['form.dataset_name.data'] = name elif 'form.model_name.data' in job.form_data: job.form_data['form.model_name.data'] = name else: # we are utterly confused raise werkzeug.exceptions.BadRequest('Unable to edit job type %s' % job.job_type()) logger.info('Set name to "%s".' % job.name(), job_id=job.id()) # Edit notes if 'job_notes' in flask.request.form: notes = flask.request.form['job_notes'].strip() if not notes: notes = None job._notes = notes logger.info('Updated notes.', job_id=job.id()) return '%s updated.' % job.job_type()