From 068ab664333987a0eb0ee3b82a9fa3c4385d0965 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 6 Mar 2011 18:05:55 +0530 Subject: [PATCH] works. now changing bp models.. --- itf/api/views.py | 11 ++++++--- itf/app/models.py | 46 +++++++++++++++++++++++++++++++++++ itf/app/views.py | 4 +-- itf/erang_organised/models.py | 6 ++--- itf/settings.py | 10 ++++++++ itf/static/js/erang/erang.js | 3 +++ itf/static/js/itf/widgets.js | 17 +++++++++++-- 7 files changed, 87 insertions(+), 10 deletions(-) diff --git a/itf/api/views.py b/itf/api/views.py index 5798d8f..0fc8a14 100644 --- a/itf/api/views.py +++ b/itf/api/views.py @@ -280,8 +280,12 @@ def getAddItemForm(request): if hasattr(widget, "choices"): choices = [] for c in widget.choices: + if c[0] == '': + id = 0 + else: + id = c[0] choices.append({ - 'id': c[0], + 'id': id, 'title': c[1] }) else: @@ -298,6 +302,8 @@ def getAddItemForm(request): return render_to_json_response(response) actions.register(getAddItemForm) + +@login_required_json def addItem(request): response = json_response({}) data = json.loads(request.POST['data']) @@ -312,10 +318,9 @@ def addItem(request): else: response['errors'] = form.errors return render_to_json_response(response) - - actions.register(addItem) + def getTemplate(data, tmpl_name): path = join(settings.PROJECT_PATH, "templates", data['module'], data['model'], tmpl_name + ".html") return open(path).read().strip() diff --git a/itf/app/models.py b/itf/app/models.py index cbd9631..6d77066 100644 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -2,7 +2,9 @@ from django.db import models import operator from django.db.models import Q from ox.text import smartSplit +from ox.django.fields import DictField from django.core.paginator import Paginator, InvalidPage, EmptyPage +from django.contrib.contenttypes.models import ContentType def splitSearch(string): ret = [] @@ -112,7 +114,51 @@ def getField(fields, name): return False +class ModelsModel(models.Model): + model = models.ForeignKey(ContentType) + friendly_name = models.CharField(max_length=256) + friendly_name_singular = models.CharField(max_length=256, blank=True, null=True) + info = models.TextField(blank=True) + sort_options = models.ManyToManyField("ModelSort", blank=True, null=True) +# filter_fields = DictField(blank=True) + is_visible = models.BooleanField(default=True) + @property + def module(self): + return self.model.app_label + + def __unicode__(self): + return self.friendly_name + + def get_dict(self): +# sort_options = map(lambda x: {'key': x.key, 'text': x.text}, self.sort_options.all()) + return { + 'module': self.module, + 'model': self.model.model, + 'info': self.info, + 'friendly_name': self.friendly_name, + 'friendly_name_singular': self.friendly_name_singular, + 'fk_filters': self.model.model_class().fk_filters, + 'fts_fields': self.model.model_class().fts_fields, + 'sort_options': map(lambda x: {'key': x.key, 'text': x.text}, self.sort_options.all()) + } + + +class ModelSort(models.Model): + key = models.CharField(max_length=64) + text = models.CharField(max_length=512) + + def __unicode__(self): + return "%s: %s" % (self.key, self.text,) + +class ModelExtraButton(models.Model): + icon = models.CharField(max_length=64) + mouseover = models.CharField(max_length=512, blank=True, null=True) + dialog_text = models.TextField() + model = models.ForeignKey(ModelsModel) + + def __unicode__(self): + return self.mouseover def site_config(): with open(settings.SITE_CONFIG) as f: diff --git a/itf/app/views.py b/itf/app/views.py index 37151be..45a16d9 100644 --- a/itf/app/views.py +++ b/itf/app/views.py @@ -14,7 +14,7 @@ def index(request): return render_to_response('index.html', context) -''' + def site_json(request): data = { 'site': { @@ -22,4 +22,4 @@ def site_json(request): } } return render_to_json_response(data) -''' + diff --git a/itf/erang_organised/models.py b/itf/erang_organised/models.py index 8d405d1..18cd738 100644 --- a/itf/erang_organised/models.py +++ b/itf/erang_organised/models.py @@ -28,10 +28,10 @@ def comments_notify(sender, **kwargs): content = comment.comment erang_id = comment.content_object.id comment_id = comment.id - url = "http://theatreforum.in/erang/?issue_id=%d" % (erang_id) +# url = "http://theatreforum.in/erang/?issue_id=%d" % (erang_id) admin_url = "http://theatreforum.in/admin/comments/comment/%d/" % (comment_id) - message = "Page: %s \n Name: %s \n Email: %s \n Comment: %s\n\n Moderate: %s" % (url, name, email, content, admin_url) - send_mail("New comment on E-Rang", message, "do_not_reply@theatreforum.in", ["erang@theatreforum.in", "sanjaybhangar@gmail.com", "sharvari@theatreforum.in"]) + message = "Name: %s \n Email: %s \n Comment: %s\n\n Moderate: %s" % (name, email, content, admin_url) + send_mail("New comment on Theatreforum.in", message, "do_not_reply@theatreforum.in", ["erang@theatreforum.in", "sanjaybhangar@gmail.com", "sharvari@theatreforum.in"]) return True comment_was_posted.connect(comments_notify) diff --git a/itf/settings.py b/itf/settings.py index 0ac167e..3b47e53 100644 --- a/itf/settings.py +++ b/itf/settings.py @@ -37,6 +37,14 @@ DATABASE_USER = 'root' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'LOCATION': '127.0.0.1:11211', + } +} + ERANG_SUBSCRIBE_URL = "http://a.organisedmail.com/nok.x?s=dGhlYXRyZWZvcnVt&ctid=YWRjZWUzOGVjMGYyZGUwNmYyOWFkZTk5ZWYyMjNjMjQ&emaddr=" # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -131,6 +139,8 @@ INSTALLED_APPS = ( 'scriptbank', 'bestpractices', 'tagging', + 'app', + 'api', # 'solango', 'multilingual', # 'multilingual.flatpages', diff --git a/itf/static/js/erang/erang.js b/itf/static/js/erang/erang.js index 06d1727..631ce72 100644 --- a/itf/static/js/erang/erang.js +++ b/itf/static/js/erang/erang.js @@ -1,5 +1,6 @@ $(document).ready(function() { var hash = location.hash; + if (hash.indexOf("subscribe") != -1) { $('#subscribe').animate({'backgroundColor': '#ffff00'}, 500, function() { $('#subscribe').animate({'backgroundColor': '#fff'}, 500, function() { @@ -12,6 +13,8 @@ $(document).ready(function() { }); } + $('#id_honeypot').parents('tr').hide(); + $('input, textarea').each(function() { var hasPlaceholder = $(this).attr("data-placeholder") == undefined ? false : true; if (hasPlaceholder) { diff --git a/itf/static/js/itf/widgets.js b/itf/static/js/itf/widgets.js index ac8ed3b..4ed95b5 100644 --- a/itf/static/js/itf/widgets.js +++ b/itf/static/js/itf/widgets.js @@ -80,8 +80,21 @@ Ox.ItfBox = function(options, self) { 'id': field.name, 'width': 256 }); - // $items.push($input); + //$items.push($input); break; + + case 'textarea': + var $input = new Ox.Input({ + 'type': field.widget, + 'id': field.name, + 'label': field.label, + 'width': 384, + 'height': 200, + 'labelWidth': 128 + }); + $items.push($input); + break; + default: // alert("default: " + field.label); var $input = new Ox.Input({ @@ -310,7 +323,7 @@ Ox.ItfBox = function(options, self) { Ox.ItfList = function(options, self) { var self = self || {}; var opts = $.extend({ - 'scrollbarVisible': false, + 'scrollbarVisible': true, 'hasComments': true }, options); var that = new Ox.TextList(opts, self);