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
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
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
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
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
#!/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
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
To display the status of indexing | |
# mdutil -s / | |
To clear the metadata store | |
Turn indexing off for / | |
# mdutil -i off / | |
Clear the metadata store for / | |
# mdutil -E / | |
Turn indexing back on for / | |
# mdutil -i on / |
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
# Example how to add rich editor capabilities to your models in admin. | |
from django.contrib.admin import site, ModelAdmin | |
import models | |
# we define our resources to add to admin pages | |
class CommonMedia: | |
js = ( | |
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js', |
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
try: | |
import cPickle as pickle | |
except: | |
import pickle | |
import pprint | |
data1 = [ { 'a':'A', 'b':2, 'c':3.0 } ] | |
print 'BEFORE:', | |
pprint.pprint(data1) |