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 comment_saved_handler(sender, instance, created, **kwargs): | |
""" | |
Signal handler to populated comment count fields. | |
Bound to 'comment_count' field, should probably be checking for a field annotation in the model. | |
""" | |
if 'comment_count' in [f.name for f in instance.content_object._meta.fields]: | |
instance.content_object.count = instance.content_object.comments.count() | |
instance.content_object.save() | |
from django.contrib.comments.models import Comment |
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
@register.filter | |
def gt(value, arg): | |
"Returns a boolean of whether the value is greater than the argument" | |
return value > int(arg) | |
@register.filter | |
def lt(value, arg): | |
"Returns a boolean of whether the value is less than the argument" | |
return value < int(arg) |
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
#!/usr/bin/env python | |
# | |
# some bits stolen from Travis Cline's http://github.com/traviscline/git-branchdescriptions | |
# | |
import os | |
import re | |
import sys | |
from subprocess import Popen, PIPE |
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
diff --git a/django/contrib/admindocs/templates/admin_doc/model_index.html b/django/contrib/admindocs/templates/admin_doc/model_index.html | |
index 4dd7caa..47c94c0 100644 | |
--- a/django/contrib/admindocs/templates/admin_doc/model_index.html | |
+++ b/django/contrib/admindocs/templates/admin_doc/model_index.html | |
@@ -36,7 +36,7 @@ | |
<ul> | |
{% regroup models by app_label as grouped_models %} | |
{% for group in grouped_models %} | |
- <li><a href="#{{ group.grouper }}">{{ group.grouper|capfirst }}</a></li> | |
+ <li><a href="#app-{{ group.grouper }}">{{ group.grouper|capfirst }}</a></li> |
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
from dateutil.relativedelta import * | |
from datetime import * | |
TODAY = datetime.now() | |
TODAY+relativedelta(weekday=FR(+2)) |
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
urlpatterns([ | |
{'regex': /^\/(\w+)\/$/, 'view': View.timeline}, | |
{'regex': /^\/(\w+)\/timeline\//, 'view': View.timeline}, | |
{'regex': /^\/(\w+)\/notes\//, 'view': View.notes}, | |
{'regex': /^\/(\w+)\/books\/$/, 'view': View.readerbooks}, | |
{'regex': /^\/(\w+)\/contacts\//, 'view': View.contacts} | |
]); | |
function urlpatterns(obj) { |
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
/** | |
* DatePicker | |
* @author Rick Hopkins | |
* @modified Micah Nolte, Martin Vaina, Nathan Borror | |
* @version 1.0 | |
* @classDescription A date picker object for user with MooTools 1.2 | |
* MIT-style License. | |
* | |
* Example: | |
* new DatePicker('date_input'); |
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
from django.template import Library | |
from django.template.defaultfilters import lower | |
register = Library() | |
@register.filter | |
def gt(value, arg): | |
"Returns a boolean of whether the value is greater than the argument" | |
try: | |
return float(value) > float(arg) |
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 PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>untitled</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.3/mootools-yui-compressed.js"></script> | |
<script type="text/javascript"> | |
var Box = new Class({ |
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
from django.db import models | |
from django.contrib.auth.models import User | |
from django.utils.translation import ugettext_lazy as _ | |
from django.core.cache import cache | |
RELATIONSHIP_CACHE = 60*60*24*7 | |
RELATIONSHIP_CACHE_KEYS = { | |
'FRIENDS': 'friends', | |
'FOLLOWERS': 'followers', |