From 6f00c2fcbe63b23d3e8d3cbc0119fd666cc94d58 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 25 Aug 2011 15:09:15 +0530 Subject: [PATCH] ups, forgot to add js --- itf/app/models.py | 18 ++++++++--- itf/insidepages/models.py | 3 ++ itf/insidepages/views.py | 4 ++- itf/static/css/noel/inner.css | 9 ++++++ itf/static/js/insidepage.js | 52 ++++++++++++++++++++++++++++++ itf/templates/noel/insidepage.html | 23 +++++++++---- 6 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 itf/static/js/insidepage.js diff --git a/itf/app/models.py b/itf/app/models.py index 56049cf..f9367e7 100644 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -87,7 +87,7 @@ class ItfModel(models.Model): ret[p] = self._get_property(p) return ret elif typ == str: - return _get_property(props) + return self._get_property(props) else: return False @@ -192,7 +192,7 @@ class ItfModel(models.Model): def get_list(kls, data): options = { 'page_no': 1, - 'list_size': 8, + 'list_size': 12, 'search': '', 'sort': [], 'range': [0,50] @@ -219,12 +219,22 @@ class ItfModel(models.Model): operator = '' sort = operator + s['key'] qset = qset.order_by(sort) - + ''' r0 = options['range'][0] r1 = options['range'][1] results = qset[r0:r1] - for r in results: + ''' + paginator = Paginator(qset, list_size) + + + try: + results = paginator.page(page_no) + except (EmptyPage, InvalidPage): + results = paginator.page(paginator.num_pages) + + for r in results.object_list: ret.append(r.list_dict()) + return ret @classmethod diff --git a/itf/insidepages/models.py b/itf/insidepages/models.py index 4c9d5e7..f202492 100644 --- a/itf/insidepages/models.py +++ b/itf/insidepages/models.py @@ -22,6 +22,9 @@ class ModuleTab(models.Model): order = models.IntegerField(default=1) is_displayed = models.BooleanField(default=True) + class Meta: + ordering = ['-is_default', 'order'] + def __unicode__(self): return self.title diff --git a/itf/insidepages/views.py b/itf/insidepages/views.py index 0b1dc56..43452fb 100644 --- a/itf/insidepages/views.py +++ b/itf/insidepages/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from ox.django.shortcuts import render_to_json_response + def main(request, module_slug): m = get_object_or_404(Module, slug=module_slug) tabs = m.moduletab_set.all() @@ -19,7 +20,7 @@ def main(request, module_slug): def get_list(request): - tab_id = request.GET.get("tab", 0) + tab_id = request.GET.get("tab_id", 0) tab = get_object_or_404(ModuleTab, pk=tab_id) list_options = { 'search': request.GET.get("search", ""), @@ -38,3 +39,4 @@ def get_details(request): obj = get_object_or_404(model_class, pk=object_id) return render_to_json_response(obj.insidepage_dict()) + diff --git a/itf/static/css/noel/inner.css b/itf/static/css/noel/inner.css index fad460f..0705fbb 100644 --- a/itf/static/css/noel/inner.css +++ b/itf/static/css/noel/inner.css @@ -99,6 +99,15 @@ color:#FFF; box-shadow:-3px -0px 6px #e0dfdf; cursor:pointer;} +.tabText +{ display:none; } + +.displayedTab +{ display:block !important; } + +#loadingList +{display:none;} + #contentTabsInner {font-family:Arial, Helvetica, 'DejaVu Sans', sans-serif; font-size:13px; diff --git a/itf/static/js/insidepage.js b/itf/static/js/insidepage.js new file mode 100644 index 0000000..29d0102 --- /dev/null +++ b/itf/static/js/insidepage.js @@ -0,0 +1,52 @@ +$('#listLeft ul li a').live("click", function() { +// alert("foo"); +// e.preventDefault(); + var objId = $(this).attr("data-id"); + var tabId = $('.innerSelected').attr("data-id"); + $.getJSON("/m/get_details", { + 'tab_id': tabId, + 'object_id': objId + }, function(data) { + $('#textRight').text(data.title); + $('#bottomRight').html(data.html); +// console.log(data); + }); + return false; +}); + +function getLi(item) { + var $li = $('
  • ').addClass("tabListItem"); + var $a = $('').attr("href", '#').attr("data-id", item.id).appendTo($li); + var $span = $('').text(item.title).appendTo($a); + return $li; +} + +$(function() { + $('#listLeft ul li a').eq(0).click(); +// alert("hi"); + $('.tabCategory').click(function() { + var $this = $(this); + if ($this.hasClass('.innerSelected')) { + return false; + } + + $('.innerSelected').removeClass("innerSelected"); + $this.addClass("innerSelected"); + $('.displayedTab').removeClass("displayedTab"); + var tabId = $this.attr("data-id"); + $('#tabText_' + tabId).addClass("displayedTab"); + $('#loadingList').show(); + $('.tabListItem').remove(); + $.getJSON("/m/get_list", { + 'tab_id': tabId, + 'page_no': 1 + }, function(data) { + $('#loadingList').hide(); + for (var i=0; i - + {% endblock %} @@ -38,14 +38,22 @@
    - {{ default_tab.text }} +
    + {{ default_tab.text }} +
    + {% for t in tabs %} +
    + {{ t.text }} +
    + {% endfor %}
    @@ -62,9 +70,9 @@

    - The Mystery of vanishing rights +

    - + download
    +