blob: d0bac1b553fdfab496825a3db0c48113bf79e697 [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 hide_left_bar = True %}
{% extends g.theme.master %}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% block title %}{{importer.source}} Project Importer{% endblock %}
{% block header %}{{importer.source}} Project Importer{% endblock %}
{% block extra_css %}
{{ super() }}
<style type="text/css">
#project-import-form #project-fields input {
width: 88%;
}
.hidden { display: none; }
</style>
{% endblock %}
{% block extra_js %}
{{ super() }}
<script type="text/javascript">
var timers = {};
function delay(callback, ms) {
clearTimeout(timers[callback]);
timers[callback] = setTimeout(callback, ms);
}
var manual = false;
function suggest_name() {
var $project_shortname = $('#project_shortname');
if (!manual) {
$project_shortname.val($('#project_name').val().replace(/\s/g, '').toLowerCase());
}
$project_shortname.trigger('change');
}
function check_names() {
var data = {};
$('#project-import-form input').each(function() {
data[$(this).attr('name')] = $(this).val();
});
$.getJSON('check_names', data, function(result) {
$('#project_name_error').addClass('hidden');
$('#project_shortname_error').addClass('hidden');
for(var field in result) {
$('#'+field+'_error').text(result[field]).removeClass('hidden');
}
});
}
function update_url() {
$('#url-fragment').text($('#project_shortname').val());
}
$(function() {
$('#project_name').bind('change keyup', suggest_name);
$('#project_shortname').bind('change keyup', function(event) {
if (event.type == 'keyup') {
manual = true;
}
update_url();
delay(check_names, 500);
});
});
</script>
{% endblock %}
{% block content %}
<form id="project-import-form" method="POST" action="process" enctype="multipart/form-data">
<input type="hidden" id="neighborhood" name="neighborhood" value="{{importer.neighborhood.name}}"/>
<fieldset id="project-fields">
{% block project_fields %}
<div class="grid-6" style="clear:left">
<label>Project Name</label>
</div>
<div class="grid-10">
<input id="project_name" name="project_name" value="{{c.form_values['project_name']}}"/>
<div id="project_name_error" class="error{% if not c.form_errors['project_name'] %} hidden{% endif %}">
{{c.form_errors['project_name']}}
</div>
</div>
<div class="grid-6" style="clear:left">
<label>{{config.site_name}} URL Name</label>
</div>
<div class="grid-10">
<input id="project_shortname" name="project_shortname" value="{{c.form_values['project_shortname']}}"/>
<div id="project_shortname_error" class="error{% if not c.form_errors['project_shortname'] %} hidden{% endif %}">
{{c.form_errors['project_shortname']}}
</div>
<div id="project-url">
http://{{request.environ['HTTP_HOST']}}{{importer.neighborhood.url()}}<span id="url-fragment">{{c.form_values['project_shortname']}}</span>
</div>
</div>
{% endblock %}
</fieldset>
<fieldset id="tool-fields">
{% if c.form_errors['tools'] %}
<div class="error">{{c.form_errors['tools']}}</div>
{% endif %}
{% for name, tool_importer in importer.tool_importers.iteritems() %}
<div class="tool">
<img src="{{ tool_importer.tool_icon(g.theme, 48) }}" alt="{{ tool_importer.tool_label }} icon">
<label>
<input name="tools" value="{{name}}" type="checkbox"{% if not c.form_errors or name in c.form_values['tools'] %} checked="checked"{% endif %}/>
{{tool_importer.tool_label}}
</label>
{% for option_name, option_label in tool_importer.tool_option.iteritems() %}
<label>
<input name="tool_option" value="{{option_name}}" type="checkbox"{% if not c.form_errors or name in c.form_values['tool_option'] %} checked="checked"{% endif %}/>
{{option_label}}
</label>
{% endfor %}
{{tool_importer.tool_description}}
</div>
{% endfor %}
</fieldset>
<div style="margin:5px">
You'll receive an email after each tool import finishes.
Import time varies depending on the amount of data being imported.
{% if config['doc.url.importers.{}'.format(importer.source) ] %}
<br/><br/>
For more information on what will be imported and post-import configuration,
please see the <a href="{{ config['doc.url.importers.{}'.format(importer.source) ] }}">{{importer.source}} import documentation</a>.
{% endif %}
</div>
<input type="submit" value="Import"/>
{{lib.csrf_token()}}
</form>
{% endblock %}