search foo

This commit is contained in:
Sanj 2011-09-28 22:18:29 +05:30
parent a0a0992854
commit 222e8fd489
4 changed files with 12 additions and 7 deletions

View File

@ -5,6 +5,7 @@ from django.contrib.contenttypes.models import ContentType
class Module(models.Model): class Module(models.Model):
title = models.CharField(max_length=255, help_text="Title of Module. eg. Best Practices") title = models.CharField(max_length=255, help_text="Title of Module. eg. Best Practices")
slug = models.SlugField(help_text="short name of module to be used for url. eg. bestpractices") slug = models.SlugField(help_text="short name of module to be used for url. eg. bestpractices")
about = models.TextField(blank=True)
def __unicode__(self): def __unicode__(self):
return self.title return self.title

View File

@ -44,7 +44,7 @@ def get_list(request):
'search': request.GET.get("search", ""), 'search': request.GET.get("search", ""),
'sort': sortArray, 'sort': sortArray,
'page': request.GET.get("page", 1), 'page': request.GET.get("page", 1),
# 'count': request.GET.get("count", 12) #FIXME: make list_length either in settings.py or config per model 'count': request.GET.get("count", 12) #FIXME: make list_length either in settings.py or config per model
} }
object_list = tab.get_list(list_options) object_list = tab.get_list(list_options)
return render_to_json_response(object_list) return render_to_json_response(object_list)

View File

@ -117,22 +117,24 @@ $(function() {
}); });
$('#orderBySelect').change(function(e) { $('#orderBySelect').change(function(e) {
$('.selectMenu').submit(); $('#listForm').submit();
}); });
$('#searchListIcon').click(function() { $('#searchListIcon').click(function() {
$('.selectMenu').submit(); $('#listForm').submit();
}); });
/*
$('.searchListField').keyup(function(e) { $('.searchListField').keyup(function(e) {
e.preventDefault(); e.preventDefault();
if (e.keyCode == 13) { if (e.keyCode == 13) {
$('.selectMenu').submit(); $('#listForm').submit();
} }
}); });
*/
$('.selectMenu').submit(function(e) { $('#listForm').submit(function(e) {
e.preventDefault(); e.preventDefault();
var sortString = $('#orderBySelect').val(); var sortString = $('#orderBySelect').val();
var searchTerm = $('.searchListField').val(); var searchTerm = $('.searchListField').val();
@ -167,8 +169,8 @@ function displayList(items) {
} }
function doListLoading() { function doListLoading() {
$('#loadingList').show();
$('.tabListItem').remove(); $('.tabListItem').remove();
$('#loadingList').show();
} }
function stopListLoading(page) { function stopListLoading(page) {
@ -223,6 +225,7 @@ function getNoListHtml(items) {
return $rhs; return $rhs;
} }
function getNoListItemHtml(item) { function getNoListItemHtml(item) {
if (item.hasOwnProperty("url")) { if (item.hasOwnProperty("url")) {
var $ret = $('<div />').addClass("noListItem"); var $ret = $('<div />').addClass("noListItem");
@ -237,6 +240,7 @@ function getNoListItemHtml(item) {
return $ret; return $ret;
} }
jQuery.fn.formatTitle = function() { jQuery.fn.formatTitle = function() {
var txt = $(this).text(); var txt = $(this).text();
var fontSize; var fontSize;

View File

@ -50,7 +50,7 @@
{{ t.text }} {{ t.text }}
</div> </div>
{% endfor %} {% endfor %}
<!--is this select okay, my forms are a bit weak, do we need action and method here?--><form class="selectMenu" action="" method="post"> <!--is this select okay, my forms are a bit weak, do we need action and method here?--><form class="selectMenu" id="listForm" method="post" action="">
<span>Order by</span><!--Can i avoid a p tag here to keep it inline--> <span>Order by</span><!--Can i avoid a p tag here to keep it inline-->
<select id="orderBySelect">Select <select id="orderBySelect">Select
{% for s in default_sorts %} {% for s in default_sorts %}