remove unused admin stuff

This commit is contained in:
j 2011-10-23 03:30:09 +02:00
parent ea52870db6
commit 4e534dba91
6 changed files with 1 additions and 140 deletions

View file

@ -91,3 +91,4 @@ def redirect_url(request, url):
return redirect(url)
else:
return HttpResponse('<script>document.location.href=%s;</script>'%json.dumps(url))

View file

@ -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)

View file

@ -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

View file

@ -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
"""

View file

@ -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

View file

@ -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>' + obj[1] + '</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());
});
}
};