This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
from django.db.models.query import QuerySet | |
from django.utils.encoding import smart_str | |
from django.db import models | |
def search_in_models(search_query, model_fields, queryset=False): | |
""" | |
Search in multiple models: | |
`model_fields` is are tuples within a tuple defining model_class, search_field pairs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 1. Imports base settings from `/serversettings/base.py` | |
# 2. Imports settings based on server name, unless: | |
# a. The environmental setting `SERVER_TYPE` has been set in the `django.wsgi` script | |
# b. The name of the server corresponds to a name in the `DEVELOPMENT_MACHINES` tuple | |
# | |
import os | |
import platform | |
import sys | |
import warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// szs Shizzle JS Selector | |
ccarousel.init = function(szsItems, szsButtonPrev, szsButtonNext) { | |
var numVisible = 4; | |
var aAllItems = $(szsItems); | |
renewList = function() { | |
aAllItems = $(szsItems); | |
}; | |
aItems = $(szsItems); | |
oLeft = $(szsButtonPrev); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.changer.nl | |
// http://jdbartlett.github.com/innershiv | |
window.innerShiv = (function() { | |
var d, r; | |
return function(h, u) { | |
if (!d) { | |
d = document.createElement('div'); | |
r = document.createDocumentFragment(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="style.css" /> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script> | |
<script type="text/javascript" src="script.js"></script> | |
<script type="text/javascript" src="jquery-ui-1.8.12.custom.min.js"></script> | |
</head> | |
<body> | |
<header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#tag('ul',''.join([tag('li',i) for i in xrange(1,6)]),{'class':'required'}) | |
#>>>'<ul class="required"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>' | |
def tag(tag_name='div', content='', attrs_dict={}): | |
""" | |
Makes an html tag. | |
""" | |
template = '<%s>' % ('%s>%s</%s' % ('%s' % (tag_name + '%s'),'%s','%s' % tag_name)) | |
return template % (' '.join([' %s="%s"' %(k,v) for k,v in attrs_dict.iteritems()]), content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_first_or_none(qs): | |
""" | |
Gets first item of queryset or None, | |
queryset can be QuerySet, RelatedManager, | |
Model, or object/Model instance. | |
Examples: | |
class Pizza(models.Model): | |
name = models.CharField(max_length=50) | |
toppings = models.ForeignKey('test.Topping') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alternate_ssr_template(ssr_template, default_args_pos): | |
""" | |
Decorator which changes the template and context for non-ajax | |
server-side requests. | |
This decorator MUST be first because it uses func_defaults. | |
`ssr_template`: Replacement template. | |
`default_args_pos`: The position of the 'template' argument that will | |
be replaced in the list of default arguments | |
for the function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ 'jquery' ], function($) { | |
$.fn.notification = function(msg_type, msg, options) { | |
var container = this; | |
var defaults = { | |
autoHide: true, | |
hideSpeed: 3000, | |
fadeInSpeed: 'fast', | |
hideOthers: true | |
}; |
OlderNewer