boxes successfully render on page
This commit is contained in:
parent
e551dcab79
commit
5fb754bec8
|
@ -155,6 +155,9 @@ class ItfModel(models.Model):
|
||||||
ret = []
|
ret = []
|
||||||
page_no = options['page_no']
|
page_no = options['page_no']
|
||||||
list_size = options['list_size']
|
list_size = options['list_size']
|
||||||
|
try:
|
||||||
|
qset = kls.get_qset()
|
||||||
|
except:
|
||||||
qset = kls.objects.all()
|
qset = kls.objects.all()
|
||||||
|
|
||||||
search = options['search']
|
search = options['search']
|
||||||
|
@ -168,7 +171,7 @@ class ItfModel(models.Model):
|
||||||
operator = '-'
|
operator = '-'
|
||||||
else:
|
else:
|
||||||
operator = ''
|
operator = ''
|
||||||
sort = operator + s['ey']
|
sort = operator + s['key']
|
||||||
qset = qset.order_by(sort)
|
qset = qset.order_by(sort)
|
||||||
|
|
||||||
r0 = options['range'][0]
|
r0 = options['range'][0]
|
||||||
|
@ -178,6 +181,12 @@ class ItfModel(models.Model):
|
||||||
ret.append(r.list_dict())
|
ret.append(r.list_dict())
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_qset(kls):
|
||||||
|
'''
|
||||||
|
Override this method in your model class to define a custom queryset instead of objects.all(), for instance, to always exclude unpublished items.
|
||||||
|
'''
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def getField(fields, name):
|
def getField(fields, name):
|
||||||
for f in fields:
|
for f in fields:
|
||||||
|
|
|
@ -20,16 +20,9 @@ class BestPractice(ItfModel):
|
||||||
modified = models.DateTimeField(auto_now=True, null=True)
|
modified = models.DateTimeField(auto_now=True, null=True)
|
||||||
|
|
||||||
fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto']
|
fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto']
|
||||||
related_models = ["bestpracticestory", "bestpracticelink", "bestpracticeimage"]
|
|
||||||
extra_buttons = [
|
|
||||||
{
|
|
||||||
'title': 'Foo button',
|
|
||||||
'mouseover': 'blah',
|
|
||||||
'dialog': ''
|
|
||||||
}
|
|
||||||
]
|
|
||||||
fk_filters = ['category']
|
fk_filters = ['category']
|
||||||
sort_fields = ['title']
|
sort_fields = ['title']
|
||||||
|
|
||||||
add_form = "BestPracticeForm"
|
add_form = "BestPracticeForm"
|
||||||
getters = ['info_dict', 'list_dict', 'no_of_stories']
|
getters = ['info_dict', 'list_dict', 'no_of_stories']
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ModelExtra(models.Model):
|
||||||
return {
|
return {
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
'module': self.model.model_class()._meta.app_label,
|
'module': self.model.model_class()._meta.app_label,
|
||||||
'model': self.model.model,
|
'model': self.model.model_class().__name__,
|
||||||
'has_comments': self.has_comments,
|
'has_comments': self.has_comments,
|
||||||
# 'info': self.info,
|
# 'info': self.info,
|
||||||
'friendly_name': self.friendly_name,
|
'friendly_name': self.friendly_name,
|
||||||
|
|
|
@ -1,13 +1,35 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.comments.signals import comment_was_posted
|
from django.contrib.comments.signals import comment_was_posted
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
from app.models import ItfModel
|
||||||
|
|
||||||
class Issue(models.Model):
|
class Issue(ItfModel):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
summary = models.TextField(blank=True, null=True)
|
summary = models.TextField(blank=True, null=True)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
html = models.TextField(blank=True)
|
html = models.TextField(blank=True)
|
||||||
|
|
||||||
|
fts_fields = ['title', 'summary']
|
||||||
|
fk_filters = []
|
||||||
|
|
||||||
|
def preview_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title,
|
||||||
|
'summary': self.summary,
|
||||||
|
}
|
||||||
|
|
||||||
|
def info_dict(self):
|
||||||
|
d = self.preview_dict()
|
||||||
|
d['html'] = self.html
|
||||||
|
return d
|
||||||
|
|
||||||
|
def list_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title
|
||||||
|
}
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Image(models.Model):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
class Document(models.Model):
|
class Document(ItfModel):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
intro = RichTextField(blank=True, null=True)
|
intro = RichTextField(blank=True, null=True)
|
||||||
file = models.FileField(upload_to='upload/docs', blank=True, null=True)
|
file = models.FileField(upload_to='upload/docs', blank=True, null=True)
|
||||||
|
@ -122,16 +122,57 @@ class Document(models.Model):
|
||||||
talk = models.ForeignKey('Talk', blank=True, null=True)
|
talk = models.ForeignKey('Talk', blank=True, null=True)
|
||||||
is_resource = models.BooleanField()
|
is_resource = models.BooleanField()
|
||||||
|
|
||||||
|
fts_fields = ['title', 'intro']
|
||||||
|
fk_filters = []
|
||||||
|
sort_fields = ['title']
|
||||||
|
|
||||||
|
def preview_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title,
|
||||||
|
'intro': self.intro,
|
||||||
|
'file': self.file.url
|
||||||
|
}
|
||||||
|
|
||||||
|
def list_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title
|
||||||
|
}
|
||||||
|
|
||||||
|
def info_dict(self):
|
||||||
|
return self.preview_dict()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
class Project(models.Model):
|
class Project(ItfModel):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
intro = models.TextField(blank=True, null=True)
|
intro = models.TextField(blank=True, null=True)
|
||||||
start_date = models.DateField(blank=True, null=True)
|
start_date = models.DateField(blank=True, null=True)
|
||||||
end_date = models.DateField(blank=True, null=True)
|
end_date = models.DateField(blank=True, null=True)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
|
|
||||||
|
fts_fields = ['title', 'intro']
|
||||||
|
fk_filters = []
|
||||||
|
sort_fields = ['title', 'start_date']
|
||||||
|
|
||||||
|
def preview_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title,
|
||||||
|
'intro': self.intro
|
||||||
|
}
|
||||||
|
|
||||||
|
def info_dict(self):
|
||||||
|
return self.preview_dict()
|
||||||
|
|
||||||
|
def list_dict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'title': self.title
|
||||||
|
}
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,6 @@ app.launch(function(data) {
|
||||||
Ox.theme("classic");
|
Ox.theme("classic");
|
||||||
Ox.print(data);
|
Ox.print(data);
|
||||||
|
|
||||||
app.$body = $('body');
|
|
||||||
app.$document = $(document);
|
|
||||||
app.$window = $(window);
|
|
||||||
app.$window.resize(function() {
|
|
||||||
ITF.setSizes();
|
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
app.user = data.user;
|
app.user = data.user;
|
||||||
app.config = data.config;
|
app.config = data.config;
|
||||||
|
@ -24,21 +18,36 @@ app.launch(function(data) {
|
||||||
app.constructors = ['wrapper', 'headerPanel', 'mainPanel', 'leftPanel', 'cityPicker', 'calendarBox', 'currentEventsList', 'middlePanel', 'middleTopPanel', 'newsfeedBox', 'aboutBox', 'itfBox', 'middleBottomPanel', 'erangBox', 'scriptArchiveBox', 'bestPracticesBox', 'biblioBox', 'offersNeedsBox', 'surveysBox', 'rightPanel', 'searchBox', 'loginBox', 'previewBox', 'footerPanel']
|
app.constructors = ['wrapper', 'headerPanel', 'mainPanel', 'leftPanel', 'cityPicker', 'calendarBox', 'currentEventsList', 'middlePanel', 'middleTopPanel', 'newsfeedBox', 'aboutBox', 'itfBox', 'middleBottomPanel', 'erangBox', 'scriptArchiveBox', 'bestPracticesBox', 'biblioBox', 'offersNeedsBox', 'surveysBox', 'rightPanel', 'searchBox', 'loginBox', 'previewBox', 'footerPanel']
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
app.$ui = {};
|
app.$ui = {};
|
||||||
|
app.$body = $('body');
|
||||||
|
app.$document = $(document);
|
||||||
|
app.$window = $(window);
|
||||||
/*
|
/*
|
||||||
Ox.each(app.constructors, function(i, v) {
|
Ox.each(app.constructors, function(i, v) {
|
||||||
app.$ui[v] = app.construct[v]();
|
app.$ui[v] = app.construct[v]();
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
var wrapper = app.construct.wrapper(data.page);
|
// Ox.print("BOO", data);
|
||||||
|
app.api.getPage({}, function(data) {
|
||||||
|
var wrapper = app.construct.wrapper(data.data);
|
||||||
app.$body.css({'opacity': 0});
|
app.$body.css({'opacity': 0});
|
||||||
//FIXME: user handling should be cleaner?
|
//FIXME: user handling should be cleaner?
|
||||||
|
|
||||||
|
wrapper.appendTo(app.$body);
|
||||||
|
/*
|
||||||
if (data.user.level != 'guest') {
|
if (data.user.level != 'guest') {
|
||||||
ITF.login(data);
|
ITF.login(data);
|
||||||
}
|
}
|
||||||
wrapper.appendTo(app.$body);
|
*/
|
||||||
|
/*
|
||||||
|
app.$window.resize(function() {
|
||||||
ITF.setSizes();
|
ITF.setSizes();
|
||||||
|
});
|
||||||
|
ITF.setSizes();
|
||||||
|
*/
|
||||||
app.$body.animate({
|
app.$body.animate({
|
||||||
'opacity': 1
|
'opacity': 1
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,38 +1,49 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Ox.ItfPage = function(page, parentPanel) {
|
Ox.ItfPage = function(page, parentPanel) {
|
||||||
var panelItems = [];
|
var panelItems = [];
|
||||||
for (var i=0; i < page.panels.displayed.length; i++) {
|
Ox.print("page", page);
|
||||||
var t = page.panels.displayed[i];
|
GLOB_PAGE = page;
|
||||||
|
for (var i=0; i < page.displayed.length; i++) {
|
||||||
|
var t = page.displayed[i];
|
||||||
var displayed = true;
|
var displayed = true;
|
||||||
var panel = new Ox.ItfPanel(t, displayed);
|
var panel = new Ox.ItfPanel(t, displayed);
|
||||||
panelItems.push(panel);
|
panelItems.push({
|
||||||
|
'element': panel,
|
||||||
|
'size': 300
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var hiddenPanel = new Ox.ItfHiddenPanelContainer();
|
var hiddenPanel = new Ox.ItfHiddenPanelContainer();
|
||||||
for (var j=0; j < page.panels.hidden.length; j++) {
|
for (var j=0; j < page.hidden.length; j++) {
|
||||||
var t = page.panels.hidden[j];
|
var t = page.hidden[j];
|
||||||
var displayed = false;
|
var displayed = false;
|
||||||
var panel = new Ox.ItfPanel(t, displayed);
|
var panel = new Ox.ItfPanel(t, displayed);
|
||||||
hiddenPanel.addPanel(panel);
|
hiddenPanel.addPanel(panel);
|
||||||
}
|
}
|
||||||
var that = app.ui['ItfPage'] = new Ox.SplitPanel({
|
panelItems.push({
|
||||||
|
'element': hiddenPanel,
|
||||||
|
'size': 30
|
||||||
|
});
|
||||||
|
var that = app.$ui['ItfPage'] = new Ox.SplitPanel({
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
id: 'ItfPage',
|
id: 'ItfPage',
|
||||||
elements: panelItems
|
elements: panelItems
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
Ox.ItfPanel = function(panelData, displayed) {
|
Ox.ItfPanel = function(panelData, displayed) {
|
||||||
var items = [];
|
var items = [];
|
||||||
var id = panelData.title;
|
var id = "Panel" + panelData.id;
|
||||||
for (var i=0; i < panelData.boxes.length; i++) {
|
for (var i=0; i < panelData.boxes.length; i++) {
|
||||||
var t = panelData.boxes[i];
|
var t = panelData.boxes[i];
|
||||||
var box = new Ox.ItfBox(t);
|
var box = new Ox.ItfBox(t);
|
||||||
items.push(box);
|
items.push({
|
||||||
|
'element': box,
|
||||||
|
'size': 512
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var that = new Ox.SplitPanel({
|
var that = new Ox.SplitPanel({
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
|
@ -40,11 +51,12 @@ Ox.ItfPanel = function(panelData, displayed) {
|
||||||
elements: items
|
elements: items
|
||||||
});
|
});
|
||||||
that.displayed = displayed;
|
that.displayed = displayed;
|
||||||
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Ox.HiddenPanelContainer = function() {
|
Ox.ItfHiddenPanelContainer = function() {
|
||||||
|
return new Ox.Element();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,14 +67,14 @@ Ox.ItfBox = function(boxData) {
|
||||||
'id': boxData.itfId,
|
'id': boxData.itfId,
|
||||||
'title': boxData.title
|
'title': boxData.title
|
||||||
};
|
};
|
||||||
var that = app.ui[boxData.itfId] = new Ox.Element(options, self);
|
var that = app.$ui[boxData.itfId] = new Ox.Element(options, self);
|
||||||
var $titlebar = new Ox.Bar({
|
var $titlebar = new Ox.Bar({
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
size: '24
|
size: 24
|
||||||
}).appendTo(that);
|
}).appendTo(that);
|
||||||
var $title = new Ox.Element()
|
var $title = new Ox.Element()
|
||||||
.addClass('OxTitle')
|
.addClass('OxTitle')
|
||||||
.html(title)
|
.html(boxData.title)
|
||||||
.appendTo($titlebar);
|
.appendTo($titlebar);
|
||||||
var $buttons = new Ox.Element().appendTo($title).css({'position': 'absolute', 'top': '1px', 'right': '1px'});
|
var $buttons = new Ox.Element().appendTo($title).css({'position': 'absolute', 'top': '1px', 'right': '1px'});
|
||||||
var boxButtons = Ox.merge(ItfBoxTypes[boxData.type].buttons, boxData.extra_buttons);
|
var boxButtons = Ox.merge(ItfBoxTypes[boxData.type].buttons, boxData.extra_buttons);
|
||||||
|
@ -70,12 +82,11 @@ Ox.ItfBox = function(boxData) {
|
||||||
var t = boxButtons[i];
|
var t = boxButtons[i];
|
||||||
var button = new Ox.ItfButton(t, boxData).appendTo($buttons);
|
var button = new Ox.ItfButton(t, boxData).appendTo($buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = ItfBoxTypes[boxData.type].render(boxData);
|
$content = ItfBoxTypes[boxData.type].render(boxData);
|
||||||
$content.appendTo(that);
|
$content.appendTo(that);
|
||||||
that.$content = $content;
|
that.$content = $content;
|
||||||
return that;
|
return that;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
Ox.ItfButton = function(buttonData, boxData) {
|
Ox.ItfButton = function(buttonData, boxData) {
|
||||||
|
@ -88,7 +99,7 @@ Ox.ItfButton = function(buttonData, boxData) {
|
||||||
});
|
});
|
||||||
var that = ItfButtonTypes[buttonData.type](button, buttonData, boxData);
|
var that = ItfButtonTypes[buttonData.type](button, buttonData, boxData);
|
||||||
return that;
|
return that;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
Ox.ItfList = function(modelData, boxData, size, self) {
|
Ox.ItfList = function(modelData, boxData, size, self) {
|
||||||
|
@ -104,7 +115,7 @@ Ox.ItfList = function(modelData, boxData, size, self) {
|
||||||
'scrollbarVisible': true,
|
'scrollbarVisible': true,
|
||||||
'hasComments': modelData.has_comments || false,
|
'hasComments': modelData.has_comments || false,
|
||||||
'items': function(data, callback) {
|
'items': function(data, callback) {
|
||||||
app.api.find(getFindParams(modelData, boxData));
|
app.api.find(getFindParams(modelData, boxData, data), callback);
|
||||||
},
|
},
|
||||||
'max': 1,
|
'max': 1,
|
||||||
'columns': [
|
'columns': [
|
||||||
|
@ -147,13 +158,12 @@ Ox.ItfList = function(modelData, boxData, size, self) {
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
function getFindParams(modelData, boxData) {
|
function getFindParams(modelData, boxData, data) {
|
||||||
var box = app.ui[boxData.itfId];
|
var box = app.$ui[boxData.itfId];
|
||||||
return {
|
data['search'] = '';
|
||||||
'search': '',
|
data['model'] = modelData.model;
|
||||||
'model': modelData.model,
|
data['module'] = modelData.module;
|
||||||
'module': modelData.module
|
return data;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ BEGIN mainPanel
|
||||||
resize: [0, 128, 256, 384]
|
resize: [0, 128, 256, 384]
|
||||||
}, */
|
}, */
|
||||||
{
|
{
|
||||||
element: app.construct.middlePanel()
|
element: app.construct.middlePanel(pageData)
|
||||||
// resizable: true
|
// resizable: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -319,7 +319,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({
|
||||||
|
@ -379,6 +379,7 @@ Ox.ItfList = function(options, self) {
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
function _getComments(comments) {
|
function _getComments(comments) {
|
||||||
var that = new Ox.Element().addClass("OxCommentsWrapper")
|
var that = new Ox.Element().addClass("OxCommentsWrapper")
|
||||||
|
|
|
@ -24,6 +24,9 @@ if(typeof(console)=='undefined') {
|
||||||
<script type="text/javascript" src="/static/js/itf/construct.js"></script>
|
<script type="text/javascript" src="/static/js/itf/construct.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/itf/widgets.js"></script>
|
<script type="text/javascript" src="/static/js/itf/widgets.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/itf/forms.js"></script>
|
<script type="text/javascript" src="/static/js/itf/forms.js"></script>
|
||||||
|
<script type="text/javascript" src="/static/js/itf/boxes.js"></script>
|
||||||
|
<script type="text/javascript" src="/static/js/itf/box_types.js"></script>
|
||||||
|
<script type="text/javascript" src="/static/js/itf/button_types.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/bookmyshow.js"></script>
|
<script type="text/javascript" src="/static/js/bookmyshow.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body></body>
|
<body></body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user