This file contains hidden or 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
The requirements file format | |
============================ | |
The requirements file is a way to get pip to install specific packages | |
to make up an *environment*. This document describes that format. To | |
read about *when* you should use requirement files, see `Requirements | |
Files <./#requirements-files>`_. | |
Each line of the requirements file indicates something to be | |
installed. For example:: |
This file contains hidden or 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
#!/bin/sh | |
POSTGISCONTRIB_PATH=`pg_config --sharedir`/contrib | |
POSTGIS=$(find $POSTGISCONTRIB_PATH -name 'postgis.sql') | |
POSTGIS_COMMENTS=$(find $POSTGISCONTRIB_PATH -name 'postgis_comments.sql') | |
POSTGIS_SPATIAL=$(find $POSTGISCONTRIB_PATH -name 'spatial_ref_sys.sql') | |
if [ -z "$POSTGIS" ] || [ -z "$POSTGIS_SPATIAL" ]; then | |
echo " * Not found postgis contrib files." | |
exit 1 |
This file contains hidden or 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.views.generic.edit import FormView | |
from django.views.generic.base import RedirectView | |
from registration.models import RegistrationProfile | |
from forms import RegistrationForm | |
class AccountRegistrationView(FormView): | |
template_name = 'authentication/registration_form.html' | |
form_class = RegistrationForm |
This file contains hidden or 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 search_sites import register_model_for_search | |
from .models import CoolModel | |
register_model_for_search(CoolModel) |
This file contains hidden or 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 re | |
from django import template | |
from django.template import Node, TemplateSyntaxError | |
from django.conf import settings | |
from django.utils.safestring import mark_safe | |
from wwwsite.applications.portal.utils.search import get_tokenize | |
register = template.Library() | |
def highlight_word(needles, haystack, class_name='highlight'): |
This file contains hidden or 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 highlight_word(needles, haystack, cls_name='highlighted'): | |
regex = re.compile(r"(%s)" % "|".join(needles), re.I) | |
i = 0; out = "" | |
for m in regex.finditer(haystack): | |
out += "".join([haystack[i:m.start()],'<span class="%s">'%cls_name,haystack[m.start():m.end()],"</span>"]) | |
i = m.end() | |
return mark_safe(out + haystack[i:]) |
This file contains hidden or 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.contrib.contenttypes.models import ContentType | |
from django.contrib.contenttypes import generic | |
class BookmarkQuerySet(models.query.QuerySet): | |
def get_or_create(self, **kwargs): | |
new_kwargs = {} | |
content_object = kwargs.get('content_object') |
This file contains hidden or 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.utils.encoding import force_unicode | |
from django.utils.functional import allow_lazy | |
from django.template.defaultfilters import stringfilter | |
register = Library() | |
def truncate_chars(s, num): | |
""" | |
Template filter to truncate a string to at most num characters respecting word |
This file contains hidden or 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
#!/bin/sh | |
# git-create-branch <branch_name> | |
if [ $# -ne 1 ]; then | |
echo 1>&2 Usage: $0 branch_name | |
exit 127 | |
fi | |
set branch_name = $1 | |
git push origin origin:refs/heads/${branch_name} |
This file contains hidden or 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.core.cache import cache | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15) | |
ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50) | |
def get_online_now(self): | |
return User.objects.filter(id__in=self.online_now_ids or []) |