Пример #1
0
def edit(job_slug = None):
    if request.method == 'POST':

        if request_wants_json():
            job = json.dumps(request.json)
        else:
            job = jobops.convert_form_to_job(request.form)

        message = jobops.validate_job(job)

        if message is None:
            if job_slug is None:
                job['slug'] = slugify(job['name'],jobops.get_job_keys())
            else:
                job['slug'] = job_slug
            jobops.save_job(job)

            if request_wants_json():
                return "OK"
            else:
                return redirect(url_for('index'))
        else:
            return message


    else:
        sources = list_plugins()
        if job_slug:
            job = jobops.get_job(job_slug)
            if job:
                job.time = datetime.datetime.fromtimestamp(job.time).strftime(DATE_FORMAT)
                job.tags = ','.join(job.tags)

            return render_template('edit.html', sources=sources, job=job)
        else:
            return render_template('edit.html', sources=sources, job=None)
Пример #2
0
def about():
    return render_template('about.html', version=VERSION, plugins=', '.join(list_plugins()))