Compare commits

..

2 commits

Author SHA1 Message Date
j
ce234bdea5 fix document import 2018-11-05 20:27:03 +00:00
j
272810b9c2 fix install 2018-11-05 20:26:47 +00:00
5 changed files with 24 additions and 12 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python3
import re
import os import os
from os.path import join, abspath, basename, dirname from os.path import join, abspath, basename, dirname
@ -45,11 +45,14 @@ os.symlink(basename(target), t)
for root, folders, files in os.walk(join(base, 'scripts')): for root, folders, files in os.walk(join(base, 'scripts')):
for f in files: for f in files:
if f.endswith('.pyc'):
continue
src = join(root, f) src = join(root, f)
target = src.replace(base, '/srv/pandora') target = src.replace(base, '/srv/pandora')
rel_src = os.path.relpath(src, dirname(target)) rel_src = os.path.relpath(src, dirname(target))
if os.path.exists(target) or os.path.islink(target): if os.path.exists(target) or os.path.islink(target):
os.unlink(target) os.unlink(target)
print(rel_src, target)
os.symlink(rel_src, target) os.symlink(rel_src, target)
if os.path.exists('__init__.py'): if os.path.exists('__init__.py'):

View file

@ -2,7 +2,7 @@
pandora.ui.importDocumentsDialog = function() { pandora.ui.importDocumentsDialog = function() {
var dialogHeight = 100, var dialogHeight = 128 + 16,
dialogWidth = 512 + 16, dialogWidth = 512 + 16,
formWidth = getFormWidth(), formWidth = getFormWidth(),
@ -10,8 +10,9 @@ pandora.ui.importDocumentsDialog = function() {
$content = Ox.Element(), $content = Ox.Element(),
value, value,
$input = [ $input = [
Ox.TextArea({ Ox.Input({
labelWidth: 96, type: 'textarea',
height: 128,
width: 512 width: 512
}).css({ }).css({
margin: '8px' margin: '8px'
@ -35,7 +36,7 @@ pandora.ui.importDocumentsDialog = function() {
} }
}), }),
$button = Ox.Button({ $button = Ox.Button({
disabled: true, disabled: false,
id: 'import', id: 'import',
title: Ox._('Import URLs') title: Ox._('Import URLs')
}) })
@ -73,10 +74,16 @@ pandora.ui.importDocumentsDialog = function() {
pandora.api.importDocuments({ pandora.api.importDocuments({
urls: urls urls: urls
}, function(result) { }, function(result) {
Ox.Request.clearCache()
if (result.data.taskId) { if (result.data.taskId) {
pandora.wait(result.data.taskId, function(result) { pandora.wait(result.data.taskId, function(result) {
that.close(); that.close();
if (pandora.user.ui.section == 'documents' && !pandora.user.ui.document.length) {
pandora.$ui.list.reloadList()
} else {
pandora.URL.push('/documents/grid/created')
} }
})
} else { } else {
that.options({content: 'Failed'}); that.options({content: 'Failed'});
} }

View file

@ -27,7 +27,7 @@ pandora.localInit = function() {
$item = Ox.MenuButton({ $item = Ox.MenuButton({
items: [ items: [
].concat(pandora.user.level == 'admin' ? [ ].concat(pandora.user.level == 'admin' ? [
] : [], [ ] : [], pandora.user.level == 'gurest' ? [] : [
{id: 'import_documents', title: 'Import Documents...'}, {id: 'import_documents', title: 'Import Documents...'},
]), ]),
style: 'rounded', style: 'rounded',
@ -37,7 +37,7 @@ pandora.localInit = function() {
}).css(css).bindEvent({ }).css(css).bindEvent({
click: function(data) { click: function(data) {
if (data.id == 'import_documents') { if (data.id == 'import_documents') {
pandora.ui.importDocumentsDialog().open() pandora.ui.importDocumentsDialog().open();
} }
}, },
}), }),

View file

@ -8,5 +8,6 @@ base = os.path.dirname(__file__)
@task(queue="encoding") @task(queue="encoding")
def import_documents(urls): def import_documents(urls):
for url in urls: for url in urls:
if url.startswith('http'): url = url.strip()
if url and url.startswith('http'):
subprocess.call(['/srv/pandora/bin/python', os.path.join(base, 'add_website_as_pdf.py'), url]) subprocess.call(['/srv/pandora/bin/python', os.path.join(base, 'add_website_as_pdf.py'), url])

View file

@ -2,14 +2,15 @@
from __future__ import division, print_function, absolute_import from __future__ import division, print_function, absolute_import
from oxdjango.decorators import login_required_json from oxdjango.decorators import login_required_json
from oxdjango.shortcuts import render_to_json_response from oxdjango.shortcuts import render_to_json_response, json_response
from oxdjango.api import actions from oxdjango.api import actions
from .tasks import import_documents from .tasks import import_documents
@login_required_json @login_required_json
def importDocuments(request, data): def importDocuments(request, data):
t = tasks.import_documents.delay(urls=data['urls']) response = json_response({})
t = import_documents.delay(urls=data['urls'])
response['data']['taskId'] = t.task_id response['data']['taskId'] = t.task_id
return render_to_json_response(response) return render_to_json_response(response)
actions.register(importDocuments) actions.register(importDocuments)