Commit bea65988 authored by pm22d12's avatar pm22d12
Browse files

add https protocol options

parent 992acb7f
......@@ -14,7 +14,6 @@ urlpatterns = [
url(r'^createdownload/(?P<download_id>\S+)$', views.create_and_edit_download, name='createdownload'),
url(r'^(?P<xml_filename>\S+)/(?P<download_id>\S+)/define_test_file$', views.define_test_file, name='define_test_file'),
url(r'^(?P<xml_filename>\S+)/(?P<download_id>\S+)/protocol_option$', views.define_test_file, name='define_test_file'),
url(r'^(?P<xml_filename>\S+)/(?P<download_id>\S+)/save_test_file$', views.save_test_file, name='save_test_file'),
url(r'^(?P<download_id>\S+)/testlog$', views.display_test_log, name='testlog'),
url(r'^(?P<download_id>\S+)/synchrolog$', views.display_synchro_log, name='synchrolog'),
......
......@@ -360,13 +360,18 @@ def save_data_source(file_data, submitted_data):
dummy = etree.SubElement(parent_loc, "password")
parent_loc.password = submitted_data['passwd_remote']
if not submitted_data['protocol_option']:
protocol_options = ""
for opt in downloader_django.common.constants.PROTOCOL_OPTIONS:
value = submitted_data['protocol_option_' + opt]
if value:
protocol_options += "'" + opt + "': '" + value + "',"
if protocol_options == "":
if parent_loc.find("protocol_option") is not None:
parent_loc.remove(parent_loc.protocol_option)
elif parent_loc.protocol == "Https":
if parent_loc.find("protocol_option") is None:
dummy = etree.SubElement(parent_loc, "protocol_option")
parent_loc.protocol_option = submitted_data['protocol_option']
parent_loc.protocol_option = protocol_options[:-1]
else:
if parent_loc.find("login") is not None:
parent_loc.remove(parent_loc.login)
......
......@@ -14,7 +14,7 @@ from django.shortcuts import render
from django.template import RequestContext
from django.utils.translation import ugettext as _
from downloader_django.common.constants import LOGGER_DEFAULT_FILE_NAME, LOGGER_SYNCHRO_FILE_NAME, \
from downloader_django.common.constants import LOGGER_DEFAULT_FILE_NAME, LOGGER_SYNCHRO_FILE_NAME, PROTOCOL_OPTIONS, \
EXTENSION_DISABLED, EXTENSION_BAD, EXTENSION_TEST, EXTENSION_ACTIVE
from downloader_django.common.downloaderUtil import get_workspace_dir_name
from downloader_django.apps.downloader_admin.util import downloaderXml, synchro, testFile
......@@ -154,7 +154,7 @@ def editdownload(request, xml_filename):
return render(
request,
'adminview/editdownload.html',
{'file_data': file_data, 'file_name': xml_filename, 'error': ""},
{'file_data': file_data, 'file_name': xml_filename, 'error': "", 'protocol_options': PROTOCOL_OPTIONS},
)
except XMLSyntaxError as e:
error = e
......
......@@ -25,3 +25,5 @@ RABBITMQ_TIMEOUT = 5
DOWNLOADER_TASKS = 'downloader.worker.celery_tasks.'
XSD_DIR = os.path.join(os.path.dirname(__file__), "../static/xsd")
PROTOCOL_OPTIONS = ['FileExtractor', 'Redirector']
......@@ -43,16 +43,16 @@ msgid "port_remote.help"
msgstr "Port number (only if not the default port)"
msgid "user_remote.help"
msgstr "user name (default anonymous)"
msgstr "User name (default anonymous)"
msgid "passwd_remote.help"
msgstr "password (default anonymous)"
msgstr "Password (default anonymous)"
msgid "repos_remote.help"
msgstr "Base repository data path to crawl"
msgid "protocol_option.help"
msgstr "additional options for https protocol (FileExtractor, Redirector...)"
msgstr "Additional options for https protocol (FileExtractor, Redirector...)"
#: ====== tab Date extraction
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
{% load static %} {% load i18n %}
{% load xml_data_tags %} {% load static %} {% load i18n %}
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
......@@ -192,36 +192,38 @@
</div>
</div>
<div id="protocoloptioncontrol">
<div class="control-group">
<label for="protocol_option" class="control-label">Https protocol option</label>
<div id="protocoloptionscontrol">
<!--<form action="" class="form-horizontal" enctype="multipart/form-data" method="post">-->
{% csrf_token %}
<div class="control-group" style="white-space: normal;margin-bottom:0px;margin-top:0px;">
<label for="protocol_options" class="control-label" style="white-space: normal;">Https protocol options</label>
<div class="controls">
<input rel="tooltip" data-placement="right"
data-original-title="{% trans 'protocol_option.help' %}" class="input-xxlarge"
type="text" id="protocol_option" name="protocol_option"
value="{{ file_data.data_source.location.protocol_option }}" />
<div class="input-prepend input-xxlarge" style="white-space: normal;margin-bottom:0px;margin-top:0px;">
<span class="add-on" style="width: 120px;border-radius: 3px 0 0 0;"><b>Option</b></span>
<input rel="tooltip" data-placement="left"
data-original-title="{% trans 'protocol_option.help' %}"
class="input-xxlarge" style="width: 410px;font-weight: bold;border-radius: 0 3px 0 0;"
type="text" id="protocol_option" name="protocol_option"
value="Value" disabled="disabled" />
</div>
</div>
</div>
<!--
<form action="{% url 'dladmin:listdownload' %}{{ file_name }}/{{ file_data.attrib.id }}/protocol_option"
method="post" class="form-horizontal">
{% csrf_token %}
<label for="protocol_option" class="control-label">Https protocol option</label>
<input rel="tooltip" data-placement="right"
data-original-title="{% trans 'protocol_option.help' %}" class="input-xxlarge"
type="text" id="protocol_option" name="protocol_option"
value="{{ file_data.data_source.location.protocol_option }}" />
<button type="submit" class="btn btn-sm btn-success pull-right">
<i class="glyphicon-expand icon-white"></i>&nbsp;&nbsp;expand
</button>
</form>
-->
{% for opt in protocol_options %}
<div class="control-group" style="white-space: normal;margin-bottom:0px;margin-top:0px">
<div class="controls">
<div class="input-prepend input-xxlarge" style="white-space: normal;;margin-bottom:0px;margin-top:0px">
<span class="add-on" style="width: 120px;border-radius: 0 0 0 0;border-top-width: 0;"> {{ opt }}</span>
<input rel="tooltip" data-placement="left"
data-original-title="{% trans 'protocol_option.help' %}"
class="input-xxlarge" style="width: 410px;border-radius: 0 0 0 0;border-top-width: 0;"
type="text" id="protocol_option_{{ opt }}" name="protocol_option_{{ opt }}"
value="{% get_protocol_option file_data.data_source.location.protocol_option opt %}" />
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Step 2 : Data================================================================== -->
......@@ -1095,9 +1097,9 @@
------------------------------------------------------------------------------>
{% include 'assets/scripts.html' %}
<script type="text/javascript">
/*
// urls utils
*/
var BASE_URL = "{% url 'dladmin:listdownload' %}";
$(function() {
......@@ -1205,14 +1207,14 @@
var repos_remote = false;
var repos_local = false;
var date_regexp = false;
var tree_date_format = false;
var number = getLocalTypeValue();
var tree_date_format = false;
var number = getLocalTypeValue();
server_remote = getServerRemote();
repos_remote = getReposRemote();
repos_local = getReposLocal();
date_regexp = getDateRegexp();
tree_date_format = getTreeDateFormat();
tree_date_format = getTreeDateFormat();
if (isTypeRemoteFtpChecked()) {
if (!server_remote) {
......@@ -1228,14 +1230,14 @@
valid = false;
}
if (!date_regexp) {
valid = false;
}
if (!date_regexp) {
valid = false;
}
if (!tree_date_format) {
if (!(number == _SPOOL_)) {
valid = false;
}
if (!tree_date_format) {
if (!(number == _SPOOL_)) {
valid = false;
}
}
return valid;
......@@ -1257,7 +1259,7 @@
var repos_remote = false;
var repos_local = false;
var date_regexp = false;
var tree_date_format = false;
var tree_date_format = false;
var loop_delay = getLoopDelayValue();
var listing_delay = getListingDelayValue();
var number = getLocalTypeValue();
......@@ -1285,10 +1287,10 @@
valid = false;
}
if (!tree_date_format) {
if (!(number == _SPOOL_)) {
valid = false;
}
if (!tree_date_format) {
if (!(number == _SPOOL_)) {
valid = false;
}
}
if (loop_delay > listing_delay) {
......@@ -1325,8 +1327,7 @@
if (isTypeRemoteFtpChecked()) {
if (!server_remote) {
missingValue = addMissingValue(missingValue,
SERVER_REMOTE_LABEL);
missingValue = addMissingValue(missingValue,SERVER_REMOTE_LABEL);
}
}
......@@ -1343,11 +1344,10 @@
DATE_REGEXP_LABEL);
}
if (!tree_date_format) {
if (!tree_date_format) {
if (!(number == _SPOOL_)) {
missingValue = addMissingValue(missingValue,
TREE_DATE_FORMAT_LABEL);
}
missingValue = addMissingValue(missingValue, TREE_DATE_FORMAT_LABEL);
}
}
alertMissedMandatoryValue(missingValue);
......@@ -1485,9 +1485,9 @@
}
if (number == _HTTPS_) {
displayprotocoloptioncontrol();
displayprotocoloptionscontrol();
} else {
hideprotocoloptioncontrol();
hideprotocoloptionscontrol();
}
if (number == _FTP_) {
......@@ -1533,12 +1533,12 @@
$('#serverdatachecker').fadeOut(500);
}
function displayprotocoloptioncontrol() {
$('#protocoloptioncontrol').fadeIn().show();
function displayprotocoloptionscontrol() {
$('#protocoloptionscontrol').fadeIn().show();
}
function hideprotocoloptioncontrol() {
$('#protocoloptioncontrol').fadeOut(500);
function hideprotocoloptionscontrol() {
$('#protocoloptionscontrol').fadeOut(500);
}
function displayftpdatachecker() {
......@@ -1658,6 +1658,8 @@
$("#max_activated_flow_err").fadeOut(500);
}
}
</script>
<script type="text/javascript">
......@@ -1935,5 +1937,36 @@
});
});
</script>
<script type="text/javascript">
/*
fileid = getContextId(_NONE_, fileid);
var requesturl = BASE_URL + filename + "/" + getRealId(fileid) + "/reload_from_file";
$('#redownload_form'+fileid).submit(function(e){
e.preventDefault();
$form = $(this)
var formData = new FormData(this);
$.ajax({
url: requesturl,
type: 'POST',
data: formData,
success: function (response) {
$('.error').remove();
updateReloadStatus(fileid, response.result, response.message);
},
cache: false,
contentType: false,
processData: false
});
e.stopImmediatePropagation();
});
return false;
*/
</script>
</body>
</html>
......@@ -5,6 +5,8 @@ from django.conf import settings
from django import template
from django.utils.safestring import mark_safe
from downloader_django.common.constants import PROTOCOL_OPTIONS
register = template.Library()
......@@ -83,6 +85,16 @@ def get_destination(list):
return ""
@register.simple_tag
def get_protocol_option(protocol_options, key):
options= eval('{' + protocol_options + '}')
if key in options:
return options[key]
else:
return ""
@register.simple_tag
def get_status_test(list):
print('test (status) = ', list)
......@@ -220,5 +232,3 @@ def get_active_queues(context):
select_queue = f'<option value="" selected = "selected">- - - - - - - - - - - - - - - - </option>' \
+ select_queue
return mark_safe(select_queue)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment