boxes successfully render on page
This commit is contained in:
parent
e551dcab79
commit
5fb754bec8
|
@ -155,7 +155,10 @@ class ItfModel(models.Model):
|
|||
ret = []
|
||||
page_no = options['page_no']
|
||||
list_size = options['list_size']
|
||||
qset = kls.objects.all()
|
||||
try:
|
||||
qset = kls.get_qset()
|
||||
except:
|
||||
qset = kls.objects.all()
|
||||
|
||||
search = options['search']
|
||||
if search != '':
|
||||
|
@ -168,7 +171,7 @@ class ItfModel(models.Model):
|
|||
operator = '-'
|
||||
else:
|
||||
operator = ''
|
||||
sort = operator + s['ey']
|
||||
sort = operator + s['key']
|
||||
qset = qset.order_by(sort)
|
||||
|
||||
r0 = options['range'][0]
|
||||
|
@ -178,6 +181,12 @@ class ItfModel(models.Model):
|
|||
ret.append(r.list_dict())
|
||||
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):
|
||||
for f in fields:
|
||||
|
|
|
@ -19,17 +19,10 @@ class BestPractice(ItfModel):
|
|||
added = models.DateTimeField(auto_now_add=True, null=True)
|
||||
modified = models.DateTimeField(auto_now=True, null=True)
|
||||
|
||||
fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto']
|
||||
related_models = ["bestpracticestory", "bestpracticelink", "bestpracticeimage"]
|
||||
extra_buttons = [
|
||||
{
|
||||
'title': 'Foo button',
|
||||
'mouseover': 'blah',
|
||||
'dialog': ''
|
||||
}
|
||||
]
|
||||
fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto']
|
||||
fk_filters = ['category']
|
||||
sort_fields = ['title']
|
||||
|
||||
add_form = "BestPracticeForm"
|
||||
getters = ['info_dict', 'list_dict', 'no_of_stories']
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class ModelExtra(models.Model):
|
|||
return {
|
||||
'id': self.id,
|
||||
'module': self.model.model_class()._meta.app_label,
|
||||
'model': self.model.model,
|
||||
'model': self.model.model_class().__name__,
|
||||
'has_comments': self.has_comments,
|
||||
# 'info': self.info,
|
||||
'friendly_name': self.friendly_name,
|
||||
|
|
|
@ -1,13 +1,35 @@
|
|||
from django.db import models
|
||||
from django.contrib.comments.signals import comment_was_posted
|
||||
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)
|
||||
summary = models.TextField(blank=True, null=True)
|
||||
date = models.DateField()
|
||||
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):
|
||||
return self.title
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class Image(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
class Document(models.Model):
|
||||
class Document(ItfModel):
|
||||
title = models.CharField(max_length=255)
|
||||
intro = RichTextField(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)
|
||||
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):
|
||||
return self.title
|
||||
|
||||
class Project(models.Model):
|
||||
class Project(ItfModel):
|
||||
title = models.CharField(max_length=255)
|
||||
intro = models.TextField(blank=True, null=True)
|
||||
start_date = models.DateField(blank=True, null=True)
|
||||
end_date = models.DateField(blank=True, null=True)
|
||||
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):
|
||||
return self.title
|
||||
|
||||
|
|
|
@ -8,12 +8,6 @@ app.launch(function(data) {
|
|||
Ox.theme("classic");
|
||||
Ox.print(data);
|
||||
|
||||
app.$body = $('body');
|
||||
app.$document = $(document);
|
||||
app.$window = $(window);
|
||||
app.$window.resize(function() {
|
||||
ITF.setSizes();
|
||||
});
|
||||
/*
|
||||
app.user = data.user;
|
||||
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.$ui = {};
|
||||
app.$body = $('body');
|
||||
app.$document = $(document);
|
||||
app.$window = $(window);
|
||||
/*
|
||||
Ox.each(app.constructors, function(i, v) {
|
||||
app.$ui[v] = app.construct[v]();
|
||||
});
|
||||
*/
|
||||
var wrapper = app.construct.wrapper(data.page);
|
||||
app.$body.css({'opacity': 0});
|
||||
//FIXME: user handling should be cleaner?
|
||||
if (data.user.level != 'guest') {
|
||||
ITF.login(data);
|
||||
}
|
||||
wrapper.appendTo(app.$body);
|
||||
ITF.setSizes();
|
||||
app.$body.animate({
|
||||
'opacity': 1
|
||||
}, 2000);
|
||||
// Ox.print("BOO", data);
|
||||
app.api.getPage({}, function(data) {
|
||||
var wrapper = app.construct.wrapper(data.data);
|
||||
app.$body.css({'opacity': 0});
|
||||
//FIXME: user handling should be cleaner?
|
||||
|
||||
wrapper.appendTo(app.$body);
|
||||
/*
|
||||
if (data.user.level != 'guest') {
|
||||
ITF.login(data);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
app.$window.resize(function() {
|
||||
ITF.setSizes();
|
||||
});
|
||||
ITF.setSizes();
|
||||
*/
|
||||
app.$body.animate({
|
||||
'opacity': 1
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,38 +1,49 @@
|
|||
/*
|
||||
|
||||
*/
|
||||
|
||||
Ox.ItfPage = function(page, parentPanel) {
|
||||
var panelItems = [];
|
||||
for (var i=0; i < page.panels.displayed.length; i++) {
|
||||
var t = page.panels.displayed[i];
|
||||
Ox.print("page", page);
|
||||
GLOB_PAGE = page;
|
||||
for (var i=0; i < page.displayed.length; i++) {
|
||||
var t = page.displayed[i];
|
||||
var displayed = true;
|
||||
var panel = new Ox.ItfPanel(t, displayed);
|
||||
panelItems.push(panel);
|
||||
panelItems.push({
|
||||
'element': panel,
|
||||
'size': 300
|
||||
});
|
||||
}
|
||||
var hiddenPanel = new Ox.ItfHiddenPanelContainer();
|
||||
for (var j=0; j < page.panels.hidden.length; j++) {
|
||||
var t = page.panels.hidden[j];
|
||||
for (var j=0; j < page.hidden.length; j++) {
|
||||
var t = page.hidden[j];
|
||||
var displayed = false;
|
||||
var panel = new Ox.ItfPanel(t, displayed);
|
||||
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',
|
||||
id: 'ItfPage',
|
||||
elements: panelItems
|
||||
});
|
||||
return that;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Ox.ItfPanel = function(panelData, displayed) {
|
||||
var items = [];
|
||||
var id = panelData.title;
|
||||
var id = "Panel" + panelData.id;
|
||||
for (var i=0; i < panelData.boxes.length; i++) {
|
||||
var t = panelData.boxes[i];
|
||||
var box = new Ox.ItfBox(t);
|
||||
items.push(box);
|
||||
items.push({
|
||||
'element': box,
|
||||
'size': 512
|
||||
});
|
||||
}
|
||||
var that = new Ox.SplitPanel({
|
||||
orientation: 'horizontal',
|
||||
|
@ -40,11 +51,12 @@ Ox.ItfPanel = function(panelData, displayed) {
|
|||
elements: items
|
||||
});
|
||||
that.displayed = displayed;
|
||||
return that;
|
||||
};
|
||||
|
||||
|
||||
Ox.HiddenPanelContainer = function() {
|
||||
|
||||
Ox.ItfHiddenPanelContainer = function() {
|
||||
return new Ox.Element();
|
||||
};
|
||||
|
||||
|
||||
|
@ -55,27 +67,26 @@ Ox.ItfBox = function(boxData) {
|
|||
'id': boxData.itfId,
|
||||
'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({
|
||||
orientation: 'horizontal',
|
||||
size: '24
|
||||
size: 24
|
||||
}).appendTo(that);
|
||||
var $title = new Ox.Element()
|
||||
.addClass('OxTitle')
|
||||
.html(title)
|
||||
.html(boxData.title)
|
||||
.appendTo($titlebar);
|
||||
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);
|
||||
for (var i=0; i<boxButtons.length; i++) {
|
||||
var t = boxButtons[i];
|
||||
var button = new Ox.ItfButton(t, boxData).appendTo($buttons);
|
||||
}
|
||||
|
||||
}
|
||||
$content = ItfBoxTypes[boxData.type].render(boxData);
|
||||
$content.appendTo(that);
|
||||
that.$content = $content;
|
||||
return that;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Ox.ItfButton = function(buttonData, boxData) {
|
||||
|
@ -88,7 +99,7 @@ Ox.ItfButton = function(buttonData, boxData) {
|
|||
});
|
||||
var that = ItfButtonTypes[buttonData.type](button, buttonData, boxData);
|
||||
return that;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Ox.ItfList = function(modelData, boxData, size, self) {
|
||||
|
@ -104,7 +115,7 @@ Ox.ItfList = function(modelData, boxData, size, self) {
|
|||
'scrollbarVisible': true,
|
||||
'hasComments': modelData.has_comments || false,
|
||||
'items': function(data, callback) {
|
||||
app.api.find(getFindParams(modelData, boxData));
|
||||
app.api.find(getFindParams(modelData, boxData, data), callback);
|
||||
},
|
||||
'max': 1,
|
||||
'columns': [
|
||||
|
@ -147,13 +158,12 @@ Ox.ItfList = function(modelData, boxData, size, self) {
|
|||
|
||||
return that;
|
||||
|
||||
function getFindParams(modelData, boxData) {
|
||||
var box = app.ui[boxData.itfId];
|
||||
return {
|
||||
'search': '',
|
||||
'model': modelData.model,
|
||||
'module': modelData.module
|
||||
}
|
||||
function getFindParams(modelData, boxData, data) {
|
||||
var box = app.$ui[boxData.itfId];
|
||||
data['search'] = '';
|
||||
data['model'] = modelData.model;
|
||||
data['module'] = modelData.module;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ BEGIN mainPanel
|
|||
resize: [0, 128, 256, 384]
|
||||
}, */
|
||||
{
|
||||
element: app.construct.middlePanel()
|
||||
element: app.construct.middlePanel(pageData)
|
||||
// resizable: true
|
||||
},
|
||||
{
|
||||
|
|
|
@ -319,7 +319,7 @@ Ox.ItfBox = function(options, self) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Ox.ItfList = function(options, self) {
|
||||
var self = self || {};
|
||||
var opts = $.extend({
|
||||
|
@ -379,6 +379,7 @@ Ox.ItfList = function(options, self) {
|
|||
});
|
||||
return that;
|
||||
}
|
||||
*/
|
||||
|
||||
function _getComments(comments) {
|
||||
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/widgets.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>
|
||||
</head>
|
||||
<body></body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user