summaryrefslogtreecommitdiff
path: root/lib/grappelli/views
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2012-09-22 22:27:04 -0400
committerluxagraf <sng@luxagraf.net>2012-09-22 22:27:04 -0400
commitefb623af0bcb47d510501c282e1326b11343a29c (patch)
tree3a35fb19f5eba3b219c65277a5fb712cbe9604ac /lib/grappelli/views
parent0b481fd7931c2ae20ca21f89a87f2ba6a6c01e10 (diff)
site reorg
Diffstat (limited to 'lib/grappelli/views')
-rw-r--r--lib/grappelli/views/__init__.py0
-rw-r--r--lib/grappelli/views/generic.py53
-rw-r--r--lib/grappelli/views/related.py51
3 files changed, 0 insertions, 104 deletions
diff --git a/lib/grappelli/views/__init__.py b/lib/grappelli/views/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/lib/grappelli/views/__init__.py
+++ /dev/null
diff --git a/lib/grappelli/views/generic.py b/lib/grappelli/views/generic.py
deleted file mode 100644
index 0c2b72a..0000000
--- a/lib/grappelli/views/generic.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# coding: utf-8
-
-from django.shortcuts import render_to_response
-from django.http import Http404, HttpResponse
-from django.template import Context, Template
-
-from django.contrib.contenttypes.models import ContentType
-from django.utils.html import strip_tags, fix_ampersands, escape
-from django.utils.encoding import force_unicode
-from django.utils.safestring import mark_safe
-
-JSON_TEMPLATE = u"[{% for obj in objects %}{contentTypeId:'{{ obj.content_type_id }}',contentTypeText:'{{ obj.content_type_text }}',objectId:'{{ obj.object_id }}',objectText:'{{ obj.object_text|urlencode }}'}{% if not forloop.last %},{% endif %}{% endfor %}]"
-
-def get_obj(content_type_id, object_id):
-
- content_type = ContentType.objects.get(pk=content_type_id)
- try:
- obj = content_type.get_object_for_this_type(pk=object_id)
- except:
- obj = None
- content_type_text = unicode(content_type)
-
- if obj:
- object_text = unicode(obj)
- else:
- object_text = "Not Found"
-
- return {
- 'content_type_text': content_type_text,
- 'content_type_id': content_type_id,
- 'object_text':strip_tags(object_text),
- 'object_id': object_id
- }
-
-def generic_lookup(request):
-
- if request.method == 'GET':
- objects = []
- if request.GET.has_key('content_type') and request.GET.has_key('object_id'):
- obj = get_obj(request.GET['content_type'], request.GET['object_id'])
- objects = (obj, )
- elif request.GET.has_key('lookup'):
- objs = eval(request.GET['lookup'])
- for obj in objs:
- objects.append(get_obj(obj[0], obj[1]))
- if objects:
- t = Template(JSON_TEMPLATE)
- c = Context({'objects': objects})
- return HttpResponse(t.render(c), mimetype='text/plain; charset=utf-8')
-
-
-
-
diff --git a/lib/grappelli/views/related.py b/lib/grappelli/views/related.py
deleted file mode 100644
index 81622ab..0000000
--- a/lib/grappelli/views/related.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# coding: utf-8
-
-from django.http import HttpResponse
-from django.db import models
-
-def related_lookup(request):
-
- if request.method == 'GET':
- if request.GET.has_key('object_id') and request.GET.has_key('app_label') and request.GET.has_key('model_name'):
- object_id = request.GET.get('object_id')
- app_label = request.GET.get('app_label')
- model_name = request.GET.get('model_name')
- if object_id:
- try:
- model = models.get_model(app_label, model_name)
- obj = model.objects.get(pk=object_id)
- obj_text = unicode(obj)
- except:
- obj_text = "Not Found"
- else:
- obj_text = ""
- else:
- obj_text = "Error"
- else:
- obj_text = "Error"
-
- return HttpResponse(obj_text, mimetype='text/plain; charset=utf-8')
-
-
-def m2m_lookup(request):
- obj_text = []
- if request.method == 'GET':
- if request.GET.has_key('object_id') and request.GET.has_key('app_label') and request.GET.has_key('model_name'):
- object_ids = request.GET.get('object_id').split(',')
- app_label = request.GET.get('app_label')
- model_name = request.GET.get('model_name')
-
- for obj_id in object_ids:
- try:
- model = models.get_model(app_label, model_name)
- obj = model.objects.get(pk=obj_id)
- obj_text.append(unicode(obj))
- except:
- obj_text.append("Not Found")
- else:
- obj_text.append("Error")
- else:
- obj_text.append("Error")
- obj_text = ", ".join(obj_text)
-
- return HttpResponse(obj_text, mimetype='text/plain; charset=utf-8')