From 4e534dba91f4bff128824ff24fdceeab7b95bc79 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 23 Oct 2011 03:30:09 +0200 Subject: [PATCH 1/3] remove unused admin stuff --- pandora/app/views.py | 1 + pandora/archive/admin.py | 3 - pandora/archive/forms.py | 27 --------- pandora/item/forms.py | 18 ------ requirements.txt | 1 - static/js/ajax_filtered_fields.js | 91 ------------------------------- 6 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 static/js/ajax_filtered_fields.js diff --git a/pandora/app/views.py b/pandora/app/views.py index 60f8f354..71decff8 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -91,3 +91,4 @@ def redirect_url(request, url): return redirect(url) else: return HttpResponse(''%json.dumps(url)) + diff --git a/pandora/archive/admin.py b/pandora/archive/admin.py index 93c8c3f1..573d21b9 100644 --- a/pandora/archive/admin.py +++ b/pandora/archive/admin.py @@ -3,7 +3,6 @@ from django.contrib import admin -from forms import FileAdminForm, InstanceAdminForm import models @@ -15,13 +14,11 @@ class FileAdmin(admin.ModelAdmin): def itemId(self, obj): return '%s'%(obj.item.itemId) - form = FileAdminForm admin.site.register(models.File, FileAdmin) class InstanceAdmin(admin.ModelAdmin): search_fields = ['path', 'volume__name', 'file__oshash'] - form = InstanceAdminForm admin.site.register(models.Instance, InstanceAdmin) diff --git a/pandora/archive/forms.py b/pandora/archive/forms.py index 04221754..0e2ac95b 100644 --- a/pandora/archive/forms.py +++ b/pandora/archive/forms.py @@ -1,4 +1,3 @@ -from ajax_filtered_fields.forms import ForeignKeyByLetter from django.conf import settings from django import forms @@ -6,29 +5,3 @@ import models from item.models import Item -ajax_filtered_js = ( - settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js", - settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js", - settings.STATIC_URL + 'js/jquery/jquery.js', - settings.STATIC_URL + 'js/ajax_filtered_fields.js', -) - - -class FileAdminForm(forms.ModelForm): - item = ForeignKeyByLetter(Item, field_name='itemId') - - class Meta: - model = models.File - - class Media: - js = ajax_filtered_js - - -class InstanceAdminForm(forms.ModelForm): - file = ForeignKeyByLetter(models.File, field_name='path') - - class Meta: - model = models.Instance - - class Media: - js = ajax_filtered_js diff --git a/pandora/item/forms.py b/pandora/item/forms.py index 664b728b..acad2478 100644 --- a/pandora/item/forms.py +++ b/pandora/item/forms.py @@ -1,20 +1,2 @@ -from ajax_filtered_fields.forms import AjaxManyToManyField, ForeignKeyByLetter from django.conf import settings -ajax_filtered_js = ( - settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js", - settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js", - settings.STATIC_URL + 'js/jquery/jquery.js', - settings.STATIC_URL + 'js/ajax_filtered_fields.js', -) -""" -class ItemAdminForm(forms.ModelForm): - imdb = ForeignKeyByLetter(models.ItemImdb, field_name='title') - oxdb = ForeignKeyByLetter(models.ItemOxdb, field_name='title') - - class Meta: - model = models.Item - - class Media: - js = ajax_filtered_js -""" diff --git a/requirements.txt b/requirements.txt index 71ee76bb..a083ef36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ -e bzr+http://code.0x2620.org/oxtimeline/#egg=oxtimeline simplejson chardet --e hg+https://django-ajax-filtered-fields.googlecode.com/hg/#egg=django-ajax-filtered-fields celery>2.1.1 django-celery>2.1.1 #django_extensions diff --git a/static/js/ajax_filtered_fields.js b/static/js/ajax_filtered_fields.js deleted file mode 100644 index 887348da..00000000 --- a/static/js/ajax_filtered_fields.js +++ /dev/null @@ -1,91 +0,0 @@ -ajax_filtered_fields = { - - request_url: "/ajax_filtered_fields/json_index/", - data_loaded: "data_loaded", - - _appendOption: function(obj, selector) { - // append a json data row as an option to the selector - var option = $(''); - option.attr({value: obj[0]}); - option.appendTo(selector); - return option; - }, - - _removeOptions: function(selector) { - // remove all options from selector - selector.children("option").each(function(i) { - $(this).remove(); - }); - }, - - getManyToManyJSON: function(element_id, app_label, object_name, - lookup_string, select_related) { - // manage the ManyToMany ajax request - var selector_from = $("#" + element_id + "_from"); - var selector_to = $("#" + element_id + "_to"); - - $("#" + element_id + "_input").val(""); - selector_from.attr("disabled", true); - selector_to.attr("disabled", true); - - this._removeOptions(selector_from); - - $.getJSON(this.request_url, { - app_label: app_label, - object_name: object_name, - lookup_string: lookup_string, - select_related: select_related}, - function(data){ - $.each(data, function(i, obj){ - var option_is_selected = selector_to.children("option[value='" + obj[0] + "']").length; - if (!option_is_selected) { - ajax_filtered_fields._appendOption(obj, selector_from); - }; - }); - SelectBox.init(element_id + "_from"); - selector_from.attr("disabled", false); - selector_to.attr("disabled", false); - selector_from.trigger(ajax_filtered_fields.data_loaded); - }); - }, - - getForeignKeyJSON: function(element_id, app_label, object_name, - lookup_string, select_related) { - // manage the ForeignKey ajax request - var selector = $("#" + element_id); - var hidden = $("#hidden-" + element_id); - - $("#" + element_id + "_input").val(""); - selector.attr("disabled", true); - - this._removeOptions(selector); - - $.getJSON(this.request_url, { - app_label: app_label, - object_name: object_name, - lookup_string: lookup_string, - select_related: select_related}, - function(data){ - var selection = hidden.val(); - ajax_filtered_fields._appendOption(new Array("", "---------"), selector); - $.each(data, function(i, obj){ - ajax_filtered_fields._appendOption(obj, selector); - }); - selector.children("option[value='" + selection + "']").attr("selected", "selected"); - selector.attr("disabled", false); - SelectBox.init(element_id); - ajax_filtered_fields.bindForeignKeyOptions(element_id); - selector.trigger(ajax_filtered_fields.data_loaded); - }); - }, - - bindForeignKeyOptions: function(element_id) { - // bind the dummy options to the hidden field that do the work - var selector = $("#" + element_id); - var hidden = $("#hidden-" + element_id); - selector.change(function(e) { - hidden.val($(this).val()); - }); - } - -}; From 2c378e46ea11c456cfe447cf62fa6cd9de9d97a3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 23 Oct 2011 03:37:58 +0200 Subject: [PATCH 2/3] remove outdated oxff integration --- static/js/pandora.local.js | 393 ------------------------------------- 1 file changed, 393 deletions(-) delete mode 100644 static/js/pandora.local.js diff --git a/static/js/pandora.local.js b/static/js/pandora.local.js deleted file mode 100644 index feadaca2..00000000 --- a/static/js/pandora.local.js +++ /dev/null @@ -1,393 +0,0 @@ -if(typeof(pandora.afterLaunch) == "undefined") - pandora.afterLaunch = []; - -//pandora.afterLaunch[0](); -pandora.afterLaunch.push(function() { - if (typeof(OxFF) == 'undefined') - return; - pandora.local = { - api: new OxFF(), - volumes: function(cb) { - var _this = this; - Ox.print('api.volumes'); - this.api.login(window, pandora.user.username); - Ox.print('api.now access'); - this.api.access(function(access) { - Ox.print('access callback', access); - if(!access) { - var dialogHeight = pandora.$document.height()/2, - dialogWidth = parseInt((dialogHeight - 48) * 0.75); - - var $dialog = new Ox.Dialog({ - buttons: [ - { - title: 'Close', - click: function() { - $dialog.close(); - delete $dialog; - } - } - ], - height: dialogHeight, - padding: 0, - title: "Pan.do/ra OxFF Local Archive", - width: dialogWidth - }) - .append("For this part of the page to work, you have to allow OxFF to send data to this site") - .open(); - } else { - _this.api.volumes(function(result) { - var data = JSON.parse(result); - cb(data); - }); - } - }); - }, - files: function(archive, cb) { - this.api.login(window, pandora.user.username); - if(!this.api.access()) - return false; - this.api.files(archive, function(result) { - var data = JSON.parse(result); - cb(data); - }); - return true; - }, - upload: function(options, done_cb, progress_cb) { - function wrap(cb) { - if(!cb) - return null; - return function(result) { - var data = JSON.parse(result); - cb(data); - } - } - this.api.upload(JSON.stringify(options), - wrap(done_cb), - wrap(progress_cb)); - return true; - }, - parsePath: function(path) { - var folder = path.split('/'); - folder.pop(); - if(folder.length==0) { - folder.push("rootfolder"); - } - //FIXME: this is also done on the backend but might require more sub options - if (folder[folder.length-1] == "Extras" || folder[folder.length-1] == "Versions") - folder.pop(); - folder = folder.join('/'); - return { - folder: folder, - name: path.substring(folder.length), - } - }, - loadVolumes: function() { - var _this = this; - Ox.print("load volumes"); - var $section = new Ox.CollapsePanel({ - id: 'volumes', - size: 'small', - title: 'Volumes' - }); - - pandora.$ui.sections.push($section); - // fixme: cleanup - pandora.local.volumes(function(data) { - Ox.print("got volumes", data); - var volumes = 0; - Ox.forEach(data, function(info, name) { - volumes ++; - Ox.print("add volume", name, info); - var status = info.available?"online":"offline"; - var $line = $('