works. now changing bp models..

This commit is contained in:
Sanj 2011-03-06 18:05:55 +05:30
parent 1fd9684064
commit 068ab66433
7 changed files with 87 additions and 10 deletions

View File

@ -280,8 +280,12 @@ def getAddItemForm(request):
if hasattr(widget, "choices"): if hasattr(widget, "choices"):
choices = [] choices = []
for c in widget.choices: for c in widget.choices:
if c[0] == '':
id = 0
else:
id = c[0]
choices.append({ choices.append({
'id': c[0], 'id': id,
'title': c[1] 'title': c[1]
}) })
else: else:
@ -298,6 +302,8 @@ def getAddItemForm(request):
return render_to_json_response(response) return render_to_json_response(response)
actions.register(getAddItemForm) actions.register(getAddItemForm)
@login_required_json
def addItem(request): def addItem(request):
response = json_response({}) response = json_response({})
data = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
@ -312,10 +318,9 @@ def addItem(request):
else: else:
response['errors'] = form.errors response['errors'] = form.errors
return render_to_json_response(response) return render_to_json_response(response)
actions.register(addItem) actions.register(addItem)
def getTemplate(data, tmpl_name): def getTemplate(data, tmpl_name):
path = join(settings.PROJECT_PATH, "templates", data['module'], data['model'], tmpl_name + ".html") path = join(settings.PROJECT_PATH, "templates", data['module'], data['model'], tmpl_name + ".html")
return open(path).read().strip() return open(path).read().strip()

View File

@ -2,7 +2,9 @@ from django.db import models
import operator import operator
from django.db.models import Q from django.db.models import Q
from ox.text import smartSplit from ox.text import smartSplit
from ox.django.fields import DictField
from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.contrib.contenttypes.models import ContentType
def splitSearch(string): def splitSearch(string):
ret = [] ret = []
@ -112,7 +114,51 @@ def getField(fields, name):
return False 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(): def site_config():
with open(settings.SITE_CONFIG) as f: with open(settings.SITE_CONFIG) as f:

View File

@ -14,7 +14,7 @@ def index(request):
return render_to_response('index.html', context) return render_to_response('index.html', context)
'''
def site_json(request): def site_json(request):
data = { data = {
'site': { 'site': {
@ -22,4 +22,4 @@ def site_json(request):
} }
} }
return render_to_json_response(data) return render_to_json_response(data)
'''

View File

@ -28,10 +28,10 @@ def comments_notify(sender, **kwargs):
content = comment.comment content = comment.comment
erang_id = comment.content_object.id erang_id = comment.content_object.id
comment_id = comment.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) 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) message = "Name: %s \n Email: %s \n Comment: %s\n\n Moderate: %s" % (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"]) send_mail("New comment on Theatreforum.in", message, "do_not_reply@theatreforum.in", ["erang@theatreforum.in", "sanjaybhangar@gmail.com", "sharvari@theatreforum.in"])
return True return True
comment_was_posted.connect(comments_notify) comment_was_posted.connect(comments_notify)

View File

@ -37,6 +37,14 @@ DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. 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. 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=" 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: # Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@ -131,6 +139,8 @@ INSTALLED_APPS = (
'scriptbank', 'scriptbank',
'bestpractices', 'bestpractices',
'tagging', 'tagging',
'app',
'api',
# 'solango', # 'solango',
'multilingual', 'multilingual',
# 'multilingual.flatpages', # 'multilingual.flatpages',

View File

@ -1,5 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
var hash = location.hash; var hash = location.hash;
if (hash.indexOf("subscribe") != -1) { if (hash.indexOf("subscribe") != -1) {
$('#subscribe').animate({'backgroundColor': '#ffff00'}, 500, function() { $('#subscribe').animate({'backgroundColor': '#ffff00'}, 500, function() {
$('#subscribe').animate({'backgroundColor': '#fff'}, 500, function() { $('#subscribe').animate({'backgroundColor': '#fff'}, 500, function() {
@ -12,6 +13,8 @@ $(document).ready(function() {
}); });
} }
$('#id_honeypot').parents('tr').hide();
$('input, textarea').each(function() { $('input, textarea').each(function() {
var hasPlaceholder = $(this).attr("data-placeholder") == undefined ? false : true; var hasPlaceholder = $(this).attr("data-placeholder") == undefined ? false : true;
if (hasPlaceholder) { if (hasPlaceholder) {

View File

@ -80,8 +80,21 @@ Ox.ItfBox = function(options, self) {
'id': field.name, 'id': field.name,
'width': 256 'width': 256
}); });
// $items.push($input); //$items.push($input);
break; 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: default:
// alert("default: " + field.label); // alert("default: " + field.label);
var $input = new Ox.Input({ var $input = new Ox.Input({
@ -310,7 +323,7 @@ Ox.ItfBox = function(options, self) {
Ox.ItfList = function(options, self) { Ox.ItfList = function(options, self) {
var self = self || {}; var self = self || {};
var opts = $.extend({ var opts = $.extend({
'scrollbarVisible': false, 'scrollbarVisible': true,
'hasComments': true 'hasComments': true
}, options); }, options);
var that = new Ox.TextList(opts, self); var that = new Ox.TextList(opts, self);