blob: ecd41daea73cfec0a24ebeaa1d9ce7da80d0e680 [file] [log] [blame]
{#-
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-#}
{% set page="task_manager" %}
{% set sidebar_rel = '../' %}
{% extends 'allura:templates/site_admin.html' %}
{% block extra_css %}
<style>
#content_base form {
margin: 1em;
}
#content_base form > div {
margin-bottom: 1em;
}
#content_base form > div > *{
display: inline-block;
vertical-align: top;
}
#content_base form > div input,
#content_base form > div textarea,
#content_base form > .input {
display: block;
width: 300px;
}
#content_base form > div label {
width: 100px;
}
#content_base .error {
width: 300px;
background: none;
border: none;
color: #f00;
margin: 0;
padding: 0 0 0 .8em;
}
#content_base pre.doc {
clear: left;
}
#content_base .note {
font-size: small;
font-style: italic;
}
</style>
{% endblock %}
{% macro error(field) %}
{% if form_errors.get(field) %}
<span class="error">{{form_errors.get(field)}}</span>
{% endif %}
{% endmacro %}
{% block content %}
<h2>New Task</h2>
<form method="POST" action="create" id="newtask">
<div>
<label>Task Name *</label>
<div class="input">
<input name="task" value="{{form_values.get('task', '')}}" />
<span class="note">Dotted python path to task callable</span>
</div>
{{error('task')}}
</div>
<div>
<label>c.user</label>
<div class="input">
<input name="user" value="{{form_values.get('user', '')}}" />
<span class="note">Username</span>
</div>
{{error('user')}}
</div>
<div>
<label>c.project/c.app</label>
<div class="input">
<input name="path" value="{{form_values.get('path', '')}}" />
<span class="note">e.g. /p/allura or /p/allura/git</span>
</div>
{{error('path')}}
</div>
<div>
<label>Task args/kwargs</label>
<div class="input">
<textarea name="task_args" rows="4">{{form_values.get('task_args', '{\n "args": [],\n "kwargs": {}\n}')}}</textarea>
</div>
{{error('task_args')}}
</div>
<input type="submit" /><br/>
<pre class="doc"></pre>
{{lib.csrf_token()}}
</form>
{% endblock %}
{% block extra_js %}
<script>
$(function() {
var $task = $('input[name=task]');
$task.blur(function() {
$.get("task_doc", {task_name: $task.val()}, function(data) {
$task.parent().siblings('.error').remove();
$('pre.doc').empty();
if (data.error) {
$task.parent().after('<span class="error">' + data.error + '</span>');
}
if (data.doc) {
$('pre.doc').html(data.doc);
}
});
});
if ($task.val().trim() !== '') {
$task.blur();
}
});
</script>
{% endblock %}