diff --git a/ctl b/ctl index da1dcd63..4a8addb4 100755 --- a/ctl +++ b/ctl @@ -11,23 +11,21 @@ if [ "$action" = "init" ]; then BASE=`pwd` python3 -m venv --system-site-packages . - branch=`cat .git/HEAD | sed 's@/@\n@g' | tail -n1` - # Work around broken venv module in Ubuntu 16.04 / Debian 9 if [ ! -e bin/pip ]; then bin/python3 -m pip install -U --ignore-installed "pip<9" fi if [ ! -d static/oxjs ]; then - git clone --depth 1 -b $branch https://git.0x2620.org/oxjs.git static/oxjs + git clone --depth 1 https://git.0x2620.org/oxjs.git static/oxjs fi mkdir -p src if [ ! -d src/oxtimelines ]; then - git clone --depth 1 -b $branch https://git.0x2620.org/oxtimelines.git src/oxtimelines + git clone --depth 1 https://git.0x2620.org/oxtimelines.git src/oxtimelines fi for package in oxtimelines python-ox; do cd ${BASE} if [ ! -d src/${package} ]; then - git clone --depth 1 -b $branch https://git.0x2620.org/${package}.git src/${package} + git clone --depth 1 https://git.0x2620.org/${package}.git src/${package} fi cd ${BASE}/src/${package} ${BASE}/bin/python setup.py develop diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index e8673197..42bae588 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -713,8 +713,7 @@ { "id": "dateofcensorcertificate", "title": "Date of Censor Certificate", - "find": true, - "type": ["date"] + "type": "date" }, { "id": "certificationcentre", diff --git a/pandora/document/managers.py b/pandora/document/managers.py index 7c97b0f1..5491aa1d 100644 --- a/pandora/document/managers.py +++ b/pandora/document/managers.py @@ -70,11 +70,7 @@ def buildCondition(k, op, v, user, exclude=False, owner=None): key_type = get_key_type(k) facet_keys = models.Document.facet_keys if k == 'id': - if op == '&' and isinstance(v, list): - v = [ox.fromAZ(id_) for id_ in v] - k += get_operator(op) - else: - v = ox.fromAZ(v) + v = ox.fromAZ(v) q = Q(**{k: v}) if exclude: q = ~Q(id__in=models.Document.objects.filter(q)) diff --git a/pandora/item/managers.py b/pandora/item/managers.py index cd185441..d1aa6d0e 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -49,9 +49,6 @@ def parseCondition(condition, user, owner=None): key_type = (utils.get_by_id(settings.CONFIG['itemKeys'], k) or {'type': 'string'}).get('type') if isinstance(key_type, list): key_type = key_type[0] - type_is_list = True - else: - type_is_list = False key_type = { 'title': 'string', 'person': 'string', @@ -117,7 +114,7 @@ def parseCondition(condition, user, owner=None): if exclude: q = ~Q(id__in=models.Item.objects.filter(q)) return q - elif key_type == "string" or (key_type == 'date' and type_is_list): + elif key_type == "string": in_find = not k.startswith('public_id') if in_find: value_key = 'find__value' @@ -169,7 +166,7 @@ def parseCondition(condition, user, owner=None): else: q = Q(id=0) return q - elif key_type == 'date' and not type_is_list: + elif key_type == 'date': def parse_date(d): while len(d) < 3: d.append(1) diff --git a/pandora/oxdjango/managers.py b/pandora/oxdjango/managers.py index 560e2c55..c1a5edb7 100644 --- a/pandora/oxdjango/managers.py +++ b/pandora/oxdjango/managers.py @@ -10,7 +10,6 @@ def get_operator(op, type='str'): '<=': '__lte', '^': '__startswith', '$': '__endswith', - '&': '__in', }, 'istr': { '==': '__iexact', @@ -21,7 +20,6 @@ def get_operator(op, type='str'): '<=': '__lte', '^': '__istartswith', '$': '__iendswith', - '&': '__in', }, 'int': { '==': '', @@ -29,7 +27,6 @@ def get_operator(op, type='str'): '>=': '__gte', '<': '__lt', '<=': '__lte', - '&': '__in', } }[type].get(op, { 'str': '__contains', diff --git a/static/js/addItemDialog.js b/static/js/addItemDialog.js index 4bdef958..d2b2ec36 100644 --- a/static/js/addItemDialog.js +++ b/static/js/addItemDialog.js @@ -107,32 +107,7 @@ pandora.ui.addItemDialog = function(options) { pandora.api.getMediaUrlInfo({ url: input }, function(result) { - if (requslt.data.items.length) { - onInfo(result.data.items.map(getVideoInfo)); - } else { - $screen.stop(); - that.close(); - var error = Ox.Dialog({ - buttons: [ - {}, - Ox.Button({ - id: 'close', - title: Ox._('Close') - }).bindEvent({ - click: function() { - error.close(); - } - }) - ], - closeButton: true, - content: Ox.Element().css({padding: '32px'}).html('Import failed'), - height: 96, - keys: {escape: 'close'}, - removeOnClose: true, - title: Ox._('Import Error'), - width: 192 - }).open() - } + onInfo(result.data.items.map(getVideoInfo)); }); } } diff --git a/static/js/editDialog.js b/static/js/editDialog.js index f35747c0..6ad47d02 100644 --- a/static/js/editDialog.js +++ b/static/js/editDialog.js @@ -78,14 +78,14 @@ pandora.ui.editDialog = function() { pandora.api.find({ keys: keys, query: { - conditions: [ - { + conditions: ids.map(function(id) { + return { key: 'id', - operator: '&', - value: ids - } - ], - operator: '&' + operator: '==', + value: id + }; + }), + operator: '|' } }, function(result) { var data = {}, diff --git a/static/js/editDocumentsDialog.js b/static/js/editDocumentsDialog.js index 4d6b345f..2ae9e264 100644 --- a/static/js/editDocumentsDialog.js +++ b/static/js/editDocumentsDialog.js @@ -77,14 +77,14 @@ pandora.ui.editDocumentsDialog = function() { pandora.api.findDocuments({ keys: keys, query: { - conditions: [ - { + conditions: ids.map(function(id) { + return { key: 'id', - operator: '&', - value: ids - } - ], - operator: '&' + operator: '==', + value: id + }; + }), + operator: '|' } }, function(result) { var data = {}, diff --git a/static/js/infoView.indiancinema.js b/static/js/infoView.indiancinema.js index cb34ec87..8a0d7380 100644 --- a/static/js/infoView.indiancinema.js +++ b/static/js/infoView.indiancinema.js @@ -24,13 +24,7 @@ pandora.ui.infoView = function(data, isMixed) { listWidth = 0, margin = 16, // these may contain commas, and are thus separated by semicolons - specialListKeys = ['alternativeTitles', 'productionCompany'].concat( - pandora.site.itemKeys.filter(function(key) { - return key.type[0] == 'date' - }).map(function(key) { - return key.id; - }) - ), + specialListKeys = ['alternativeTitles', 'productionCompany'], nameKeys = pandora.site.itemKeys.filter(function(key) { return key.sortType == 'person'; }).map(function(key) { @@ -631,7 +625,6 @@ pandora.ui.infoView = function(data, isMixed) { function editMetadata(key, value) { if (value != data[key]) { - var itemKey = Ox.getObjectById(pandora.site.itemKeys, key); var edit = {id: isMultiple ? ui.listSelection : data.id}; if (key == 'alternativeTitles') { edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) { @@ -652,12 +645,12 @@ pandora.ui.infoView = function(data, isMixed) { : []; } else if (key == 'imdbId') { edit[key] = value.match(/\d{7}/)[0]; + } else if (key == 'dateofcensorcertificate') { + value = cleanupDate(value); + edit[key] = value; } else { edit[key] = value; } - if (itemKey && itemKey.type && itemKey.type[0] == 'date') { - edit[key] = edit[key].map(cleanupDate); - } pandora.api.edit(edit, function(result) { if (!isMultiple) { var src; @@ -724,14 +717,12 @@ pandora.ui.infoView = function(data, isMixed) { return '' + str + ''; } - function formatLink(value, key, linkValue) { - linkValue = linkValue || value - linkValue = Ox.isArray(linkValue) ? linkValue: [linkValue] - return (Ox.isArray(value) ? value : [value]).map(function(value, idx) { + function formatLink(value, key) { + return (Ox.isArray(value) ? value : [value]).map(function(value) { return key ? '' + value + '' + ) + '=' + pandora.escapeQueryValue(value) + '">' + value + '' : value; }).join(Ox.contains(specialListKeys, key) ? '; ' : ', '); } @@ -753,17 +744,7 @@ pandora.ui.infoView = function(data, isMixed) { var ret; if (key == 'year') { ret = formatLink(value, 'year'); - } else if ( - listKeys.indexOf(key) > -1 && Ox.getObjectById(pandora.site.itemKeys, key).type[0] == 'date' - ) { - ret = value.split('; ').map(function(date) { - date = cleanupDate(date) - return date ? formatLink(Ox.formatDate(date, - ['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length], - true - ), key, date) : ''; - }).join('; '); - } else if (['releasedate'].indexOf(key) > -1) { + } else if (['releasedate', 'dateofcensorcertificate'].indexOf(key) > -1) { value = cleanupDate(value); ret = value ? Ox.formatDate(value, ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length], diff --git a/static/js/infoView.js b/static/js/infoView.js index 9c18ff69..a1460148 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -30,13 +30,6 @@ pandora.ui.infoView = function(data, isMixed) { }).map(function(key){ return key.id; }), - specialListKeys = [].concat( - pandora.site.itemKeys.filter(function(key) { - return key.type[0] == 'date' - }).map(function(key) { - return key.id; - }) - ), posterKeys = nameKeys.concat(['title', 'year']), statisticsWidth = 128, @@ -371,37 +364,16 @@ pandora.ui.infoView = function(data, isMixed) { $('
').css({height: '16px'}).appendTo($statistics); - function cleanupDate(value) { - if (/\d{2}-\d{2}-\d{4}/.test(value)) { - value = Ox.reverse(value.split('-')).join('-') - } - if (/\d{4}i\/\d{2}\/\d{d}/.test(value)) { - value = value.split('/').join('-') - } - if (/\d{2}\/\d{2}\/\d{4}/.test(value)) { - value = Ox.reverse(value.split('/')).join('-') - } - return value - } - function editMetadata(key, value) { if (value != data[key]) { - var itemKey = Ox.getObjectById(pandora.site.itemKeys, key); var edit = {id: isMultiple ? ui.listSelection : data.id}; if (key == 'title') { edit[key] = value; } else if (listKeys.indexOf(key) >= 0) { edit[key] = value ? value.split(', ') : []; - } else if (specialListKeys.indexOf(key) > -1) { - edit[key] = value - ? Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities) - : []; } else { edit[key] = value ? value : null; } - if (itemKey && itemKey.type && itemKey.type[0] == 'date') { - edit[key] = edit[key].map(cleanupDate); - } pandora.api.edit(edit, function(result) { if (!isMultiple) { var src; @@ -453,40 +425,20 @@ pandora.ui.infoView = function(data, isMixed) { return '' + str + ''; } - - function formatLink(value, key, linkValue) { - linkValue = linkValue || value - linkValue = Ox.isArray(linkValue) ? linkValue: [linkValue] - return (Ox.isArray(value) ? value : [value]).map(function(value, idx) { + function formatLink(value, key) { + return (Ox.isArray(value) ? value : [value]).map(function(value) { return key - ? '' + value + '' + ? '' + value + '' : value; - }).join(Ox.contains(specialListKeys, key) ? '; ' : ', '); + }).join(', '); } function formatValue(key, value) { var ret; if (nameKeys.indexOf(key) > -1) { ret = formatLink(value.split(', '), 'name'); - } else if ( - listKeys.indexOf(key) > -1 && Ox.getObjectById(pandora.site.itemKeys, key).type[0] == 'date' - ) { - ret = value.split('; ').map(function(date) { - date = cleanupDate(date) - return date ? formatLink(Ox.formatDate(date, - ['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length], - true - ), key, date) : ''; - }).join('; '); } else if (listKeys.indexOf(key) > -1) { ret = formatLink(value.split(', '), key); - } else if (specialListKeys.indexOf(key) > -1) { - ret = formatLink( - Ox.decodeHTMLEntities(value).split('; ').map(Ox.encodeHTMLEntities), - key - ); } else if (['year', 'country'].indexOf(key) > -1) { ret = formatLink(value, key); } else { @@ -506,7 +458,6 @@ pandora.ui.infoView = function(data, isMixed) { function getValue(key, value) { return !value ? '' - : Ox.contains(specialListKeys, key) ? value.join('; ') : Ox.contains(listKeys, key) ? value.join(', ') : value; } diff --git a/update.py b/update.py index 40c2532b..e40f240b 100755 --- a/update.py +++ b/update.py @@ -121,11 +121,6 @@ def run_git(path, *args): def get_version(path): return run_git(path, 'rev-list', 'HEAD', '--count') -def get_branch(path=None): - if not path: - path = '.' - return get('cat', os.path.join(path, '.git/HEAD')).strip().split('/')[-1] - if __name__ == "__main__": base = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) @@ -259,38 +254,49 @@ if __name__ == "__main__": run('./pandora/manage.py', 'createcachetable') else: if len(sys.argv) == 1: - branch = get_branch() - development = branch == 'master' - elif len(sys.argv) == 3 and sys.argv[1] == 'switch': - branch = sys.argv[2] + release = get_release() + repos = release['repositories'] development = False else: - branch = 'master' + release = { + 'date': 'development' + } development = True os.chdir(base) current = '' new = '' + if development: + if get('git', 'symbolic-ref', 'HEAD').strip().split('/')[-1] != 'master': + print('update only possible if you are on master branch') + sys.exit(1) for repo in sorted(repos, key=lambda r: repos[r]['path']): path = os.path.join(base, repos[repo]['path']) if exists(path): os.chdir(path) - current_branch = get_branch(path) - if current_branch != branch: - run('git', 'checkout', branch) revno = get_version(path) if repo == 'pandora': pandora_old_revno = revno current += revno url = repos[repo]['url'] - print('Checking', repo) - run('git', 'pull') + if 'revision' in repos[repo]: + if revno != repos[repo]['revision']: + run('git', 'fetch') + run('git', 'checkout', repos[repo]['commit']) + else: + print('Checking', repo) + #run('git', 'checkout', 'master', '-q') + run('git', 'pull') revno = get_version(path) new += revno if repo == 'pandora': pandora_new_revno = revno else: os.chdir(os.path.dirname(path)) - run('git', 'clone', '--depth', '1', repos[repo]['url']) + if 'revision' in repos[repo]: + run('git', 'clone', repos[repo]['url']) + run_git(path, 'checkout', repos[repo]['commit']) + else: + run('git', 'clone', '--depth', '1', repos[repo]['url']) setup = os.path.join(base, repos[repo]['path'], 'setup.py') if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup): os.chdir(os.path.dirname(setup)) @@ -311,7 +317,7 @@ if __name__ == "__main__": 'BEGIN;\n-- Model missing for table: cache\nCOMMIT;' ]: print('Database has changed, please make a backup and run %s db' % sys.argv[0]) - elif branch != 'master': - print('pan.do/ra is at the latest release,\nyou can run "%s switch master" to switch to the development version' % sys.argv[0]) + elif not development: + print('pan.do/ra is at the latest release,\nyou can run "%s dev" to update to the development version' % sys.argv[0]) elif current != new: reload_notice(base) diff --git a/vm/pandora_install.sh b/vm/pandora_install.sh index 342010cd..a1f66fa0 100755 --- a/vm/pandora_install.sh +++ b/vm/pandora_install.sh @@ -4,7 +4,6 @@ PANDORA=${PANDORA-pandora} POSTGRES=${POSTGRES-local} RABBITMQ=${RABBITMQ-local} NGINX=${NGINX-local} -BRANCH=${BRANCH-stable} echo Installing pandora with user: $PANDORA getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA @@ -112,7 +111,6 @@ fi #pandora git clone https://git.0x2620.org/pandora.git /srv/pandora cd /srv/pandora -git checkout $BRANCH ./ctl init HOST=$(hostname -s)