code
stringlengths
1
1.72M
language
stringclasses
1 value
# -*- encoding: utf-8 -*- from models import Streaming from django.contrib import admin admin.site.register(Streaming)
Python
# -*- encoding: utf-8 -*- from django.template import RequestContext from django.shortcuts import render_to_response from django.views.decorators.cache import cache_page from models import Streaming @cache_page(60 * 15) def streaming(request): stream = request.section.stream.get() return render_to_response(...
Python
# -*- encoding: utf-8 -*- from django.db import models from django.contrib.sitemaps import ping_google from django.conf import settings from django.utils.translation import get_language from modulo.utils import APPS import mptt from multilingual.translation import Translation from multilingual.languages import get_tra...
Python
""" This file demonstrates two different styles of tests (one doctest and one unittest). These will both pass when you run "manage.py test". Replace these with more appropriate tests for your application. """ from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): """ ...
Python
# -*- coding: utf-8 -*- class ModuleNotInstalled(Exception): def __init__(self, app): self.app = app def __str__(self): return repr("%s app is not installed" % self.app)
Python
# -*- coding: utf-8 -*- from models import Section, Widget from django.contrib import admin from django.utils.translation import ugettext as _ from multilingual.admin import MultilingualModelAdmin class SectionAdmin(MultilingualModelAdmin): list_display = ('title', 'slug', 'app', 'parent', 'menuTop') list_dis...
Python
# -*- encoding: utf-8 -*- from hashlib import sha1 from django.conf import settings from django.db import connection from django.http import Http404, HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext from django.contrib.auth.decorators import user_passes_t...
Python
# -*- encoding: utf-8 -*- from django import forms from django.conf import settings from django.core.mail import EmailMessage from django.utils.translation import ugettext_lazy as _ class ContactForm(forms.Form): name = forms.CharField(label=_(u'Nom '), required=False) mail = forms.EmailField(label=_(u'Email ...
Python
# -*- encoding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from modulo.page.models import Section class Contact(models.Model): section = models.ForeignKey(Section, limit_choices_to = {'app': 'contact'}, ...
Python
# -*- encoding: utf-8 -*- from models import Contact from django.contrib import admin from multilingual.admin import MultilingualModelAdmin class ContactAdmin(MultilingualModelAdmin): list_display = ('email','section') search_fields = ['email'] ordering = ['section'] admin.site.register(Contact, ContactA...
Python
# -*- encoding: utf-8 -*- from django.template import RequestContext from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy as _ from django.views.decorators.cache import cache_page from forms import ContactForm from models import Contact @cache_page(60 * 15) def contact(r...
Python
from django.conf.urls.defaults import * from django.conf import settings from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/section/change_order/((?P<section_id>\d+)/)?$', 'modulo.page.views.changeMenuOrder'), (r'^admin/sponsors/change_order/$', 'modulo.sponsors.views.c...
Python
# -*- encoding: utf-8 -*- from django.http import Http404 from django.conf import settings from modulo.page.views import views_switcher class PageFallbackMiddleware(object): """ If no urls.py rules took this URL, it could be a page """ def process_response(self, request, response): if response...
Python
# -*- encoding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from multilingual.translation import TranslationModel from modulo.groups.models import Group from modulo.map.models import Map from modulo.page.models import Section class Schedule(models.Model): CONCER...
Python
# -*- coding: utf-8 -*- from django import template from modulo.schedule.models import Schedule register = template.Library() @register.filter(name='day') def day(value): """ Affiche le nom du jour """ for days in Schedule.CONCERT_DAYS: if value == days[0]: return days[1]
Python
# -*- encoding: utf-8 -*- from models import Schedule, Concert from django.contrib import admin from multilingual.admin import MultilingualModelAdmin class ConcertAdmin(MultilingualModelAdmin): list_display = ('day', 'scene', 'group', 'starting_time', 'playing_time') list_display_links = ('day', 'starting_tim...
Python
# -*- encoding: utf-8 -*- from django.template import RequestContext from django.shortcuts import render_to_response, get_object_or_404 from django.views.decorators.cache import cache_page import datetime from models import Schedule @cache_page(15 * 60) def schedule_day(request): schedule = request.section.day.g...
Python
""" Support for models' internal Translation class. """ ##TODO: this is messy and needs to be cleaned up from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.db.models import signals from django.db.models.base import ModelBase from django.utils.translation import get_language...
Python
""" Django-multilingual: a QuerySet subclass for models with translatable fields. This file contains the implementation for QSRF Django. """ import datetime from copy import deepcopy from django.core.exceptions import FieldError from django.db import connection from django.db.models.fields import FieldDoesNotExist f...
Python
""" Django-multilingual: a QuerySet subclass for models with translatable fields. This file contains the implementation for QSRF Django. Huge thanks to hubscher.remy for writing this! """ from django.db.models.sql.compiler import SQLCompiler from multilingual.languages import ( get_translation_table_alias, g...
Python
""" Django-multilingual: language-related settings and functions. """ # Note: this file did become a mess and will have to be refactored # after the configuration changes get in place. #retrieve language settings from settings.py from multilingual import settings from django.utils.translation import ugettext_lazy as...
Python
from multilingual.languages import get_language_code_list, get_default_language_code from multilingual.settings import LANG_DICT from django.conf import settings def multilingual(request): """ Returns context variables containing information about available languages. """ codes = sorted(get_language_c...
Python
""" Multilingual model support. This code is put in multilingual.models to make Django execute it during application initialization. TO DO: remove it. Right now multilingual must be imported directly into any file that defines translatable models, so it will be installed anyway. This module is here only to make it ...
Python
from django.db import models from django.contrib.sites.models import Site from django.utils.translation import ugettext_lazy as _ from multilingual.translation import Translation as TranslationBase from multilingual.exceptions import TranslationDoesNotExist from multilingual.manager import MultilingualManager class M...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('multilingual.flatpages.views', (r'^(?P<url>.*)$', 'multilingual_flatpage'), )
Python
from multilingual.flatpages.views import multilingual_flatpage from django.http import Http404 from django.conf import settings class FlatpageFallbackMiddleware(object): def process_response(self, request, response): if response.status_code != 404: return response # No need to check for a flatp...
Python
from django import forms from django.contrib import admin from multilingual.flatpages.models import MultilingualFlatPage from django.utils.translation import ugettext_lazy as _ from multilingual.admin import MultilingualModelAdmin, MultilingualModelAdminForm class MultilingualFlatpageForm(MultilingualModelAdminForm):...
Python
from multilingual.flatpages.models import MultilingualFlatPage from django.template import loader, RequestContext from django.shortcuts import get_object_or_404 from django.http import HttpResponse, HttpResponseRedirect from django.conf import settings from django.core.xheaders import populate_xheaders from django.util...
Python
from django.db import models class TranslationForeignKey(models.ForeignKey): """ """ def south_field_triple(self): from south.modelsinspector import introspector field_class = "django.db.models.fields.related.ForeignKey" args, kwargs = introspector(self) return (field_class...
Python
from django.utils.translation import get_language from multilingual.exceptions import LanguageDoesNotExist from multilingual.languages import set_default_language class DefaultLanguageMiddleware(object): """ Binds DEFAULT_LANGUAGE_CODE to django's currently selected language. The effect of enabling this...
Python
import math import StringIO import tokenize from django import template from django import forms from django.template import Node, NodeList, Template, Context, resolve_variable from django.template.loader import get_template, render_to_string from django.conf import settings from django.utils.html import escape from m...
Python
from django.conf import settings from django.core.exceptions import ImproperlyConfigured LANGUAGES = settings.LANGUAGES LANG_DICT = dict(LANGUAGES) def get_fallback_languages(): fallbacks = {} for lang in LANG_DICT: fallbacks[lang] = [lang] for other in LANG_DICT: if other != lang...
Python
from multilingual.languages import get_default_language from django.utils.decorators import method_decorator def is_multilingual_model(model): """ Return True if `model` is a multilingual model. """ return hasattr(model._meta, 'translation_model') class GLLError(Exception): pass class GlobalLanguag...
Python
"""Admin suppor for inlines Peter Cicman, Divio GmbH, 2008 """ from django.utils.text import capfirst, get_text_list from django.contrib.admin.util import flatten_fieldsets from django.http import HttpResponseRedirect from django.utils.encoding import force_unicode import re from copy import deepcopy from django.conf...
Python
from django.core.exceptions import ImproperlyConfigured from django.db import models from multilingual.utils import is_multilingual_model def get_field(cls, model, opts, label, field): """ Just like django.contrib.admin.validation.get_field, but knows about translation models. """ trans_model = ...
Python
class TranslationDoesNotExist(Exception): """ The requested translation does not exist """ pass class LanguageDoesNotExist(Exception): """ The requested language does not exist """ pass
Python
from django.core.management.base import AppCommand from django.db import models from django.utils.importlib import import_module from django.conf import settings from django.db import connection from django.core.management import call_command from multilingual.utils import is_multilingual_model from multilingual.langua...
Python
""" Django-multilingual-ng: multilingual model support for Django 1.2. Note about version numbers: - uneven minor versions are considered unstable releases - even minor versions are considered stable releases """ VERSION = ('0', '1', '30') __version__ = '.'.join(VERSION) try: """ WARNING: All these na...
Python
from django.db import models from multilingual.query import MultilingualModelQuerySet from multilingual.languages import * class MultilingualManager(models.Manager): """ A manager for multilingual models. TO DO: turn this into a proxy manager that would allow developers to use any manager they need....
Python
import urllib, urllib2, simplejson from datetime import datetime from django.utils.http import urlquote from time import sleep import re htmlCodes = [ ['&', '&amp;'], ['<', '&lt;'], ['>', '&gt;'], ['"', '&quot;'], ] htmlCodesReversed = htmlCodes[:] htmlCodesReversed.reverse() def htmlDecode(s, codes=...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt) from django.db import models from django.contrib.admin import widgets as admin_widgets from tinymce import widgets as tinymce_widgets class HTMLField(models.TextField): """ A large string field for HTML content. ...
Python
""" Based on "TinyMCE Compressor PHP" from MoxieCode. http://tinymce.moxiecode.com/ Copyright (c) 2008 Jason Davies Licensed under the terms of the MIT License (see LICENSE.txt) """ from datetime import datetime import os from django.conf import settings from django.core.cache import cache from django...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt) from django.conf.urls.defaults import * urlpatterns = patterns('tinymce.views', url(r'^js/textareas/(?P<name>.+)/$', 'textareas_js', name='tinymce-js'), url(r'^js/textareas/(?P<name>.+)/(?P<lang>.*)$', 'textareas...
Python
# Copyright (c) 2009 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt) from django import template from django.template.loader import render_to_string import tinymce.settings register = template.Library() def tinymce_preview(element_id): return render_to_string('tinymce/preview_javasc...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt)
Python
import os from django.conf import settings DEFAULT_CONFIG = getattr(settings, 'TINYMCE_DEFAULT_CONFIG', {'theme': "simple", 'relative_urls': False}) USE_SPELLCHECKER = getattr(settings, 'TINYMCE_SPELLCHECKER', False) USE_COMPRESSOR = getattr(settings, 'TINYMCE_COMPRESSOR', False) USE_FILEBROWSER = getattr(s...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt) """ This TinyMCE widget was copied and extended from this code by John D'Agostino: http://code.djangoproject.com/wiki/CustomWidgetsTinyMCE """ from django import forms from django.conf import settings from django.contrib...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt) import logging from django.core import urlresolvers from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext, loader from django.utils import simplejs...
Python
# Copyright (c) 2008 Joost Cassee # Licensed under the terms of the MIT License (see LICENSE.txt)
Python
from django import template from django.conf import settings register = template.Library() def googleanalytics(tracking_code=None): """ Includes the google analytics tracking code, using the code number in GOOGLE_ANALYTICS_ACCOUNT_CODE setting or the tag's param if given. Syntax:: ...
Python
""" Form components for working with trees. """ from django import forms from django.forms.forms import NON_FIELD_ERRORS from django.forms.util import ErrorList from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _ from mptt.exceptions import InvalidMove __all__ = ('T...
Python
""" New instance methods for Django models which are set up for Modified Preorder Tree Traversal. """ def get_ancestors(self, ascending=False): """ Creates a ``QuerySet`` containing the ancestors of this model instance. This defaults to being in descending order (root ancestor first, immediate par...
Python
""" Signal receiving functions which handle Modified Preorder Tree Traversal related logic when model instances are about to be saved or deleted. """ import operator from django.db.models.query import Q __all__ = ('pre_save',) def _insertion_target_filters(node, order_insertion_by): """ Creates a filter whic...
Python
""" A custom manager for working with trees of objects. """ from django.db import connection, models, transaction from django.utils.translation import ugettext as _ from mptt.exceptions import InvalidMove __all__ = ('TreeManager',) qn = connection.ops.quote_name COUNT_SUBQUERY = """( SELECT COUNT(*) FROM %(...
Python
import re from django.test import TestCase from mptt.exceptions import InvalidMove from mptt.tests import doctests from mptt.tests.models import Category, Genre def get_tree_details(nodes): """Creates pertinent tree details for the given list of nodes.""" opts = nodes[0]._meta return '\n'.join(['%s %s %s...
Python
from django.db import models import mptt class Category(models.Model): name = models.CharField(max_length=50) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') def __unicode__(self): return self.name def delete(self): super(Category, self).delete() c...
Python
import doctest import unittest from mptt.tests import doctests from mptt.tests import testcases def suite(): s = unittest.TestSuite() s.addTest(doctest.DocTestSuite(doctests)) s.addTest(unittest.defaultTestLoader.loadTestsFromModule(testcases)) return s
Python
import os DIRNAME = os.path.dirname(__file__) DEBUG = True DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = os.path.join(DIRNAME, 'mptt.db') #DATABASE_ENGINE = 'mysql' #DATABASE_NAME = 'mptt_test' #DATABASE_USER = 'root' #DATABASE_PASSWORD = '' #DATABASE_HOST = 'localhost' #DATABASE_PORT = '3306' #DATABASE_ENGINE = 'po...
Python
r""" >>> from datetime import date >>> from mptt.exceptions import InvalidMove >>> from mptt.tests.models import Genre, Insert, MultiOrder, Node, OrderedInsertion, Tree >>> def print_tree_details(nodes): ... opts = nodes[0]._meta ... print '\n'.join(['%s %s %s %s %s %s' % \ ... (n.pk, geta...
Python
""" Template tags for working with lists of model instances which represent trees. """ from django import template from django.db.models import get_model from django.db.models.fields import FieldDoesNotExist from django.utils.encoding import force_unicode from django.utils.translation import ugettext as _ from mptt.ut...
Python
""" Utilities for working with lists of model instances which represent trees. """ import copy import itertools __all__ = ('previous_current_next', 'tree_item_iterator', 'drilldown_tree_for_node') def previous_current_next(items): """ From http://www.wordaligned.org/articles/zippy-triples-served-wi...
Python
""" MPTT exceptions. """ class InvalidMove(Exception): """ An invalid node move was attempted. For example, attempting to make a node a child of itself. """ pass
Python
VERSION = (0, 3, 'pre') __all__ = ('register',) class AlreadyRegistered(Exception): """ An attempt was made to register a model for MPTT more than once. """ pass registry = [] def register(model, parent_attr='parent', left_attr='lft', right_attr='rght', tree_id_attr='tree_id', level_att...
Python
from django.db import models from captcha.conf import settings as captcha_settings import datetime, unicodedata, random, time # Heavily based on session key generation in Django # Use the system (hardware-based) random number generator if it exists. if hasattr(random, 'SystemRandom'): randrange = random.SystemRand...
Python
from django.forms.fields import CharField, MultiValueField from django.forms import ValidationError from django.forms.widgets import TextInput, MultiWidget, HiddenInput from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse from...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'test/$','captcha.tests.views.test',name='captcha-test'), url(r'test2/$','captcha.tests.views.test_custom_error_message',name='captcha-test-custom-error-message'), url(r'',include('captcha.urls')), )
Python
from django import forms from captcha.fields import CaptchaField from django.template import Context, RequestContext, loader from django.http import HttpResponse TEST_TEMPLATE = r''' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> ...
Python
# -*- coding: utf-8 -*- from captcha.conf import settings from captcha.models import CaptchaStore from django.core.urlresolvers import reverse from django.test import TestCase from django.utils.translation import ugettext_lazy as _ import datetime class CaptchaCase(TestCase): urls = 'captcha.tests.urls' def ...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('captcha.views', url(r'image/(?P<key>\w+)/$','captcha_image',name='captcha-image'), url(r'audio/(?P<key>\w+)/$','captcha_audio',name='captcha-audio'), )
Python
# -*- coding: utf-8 -*- import random from captcha.conf import settings def math_challenge(): operators = ('+','*','-',) operands = (random.randint(1,10),random.randint(1,10)) operator = random.choice(operators) if operands[0] < operands[1] and '-' == operator: operands = (operands[1],operands[...
Python
from django.core.management.base import BaseCommand, CommandError import sys from optparse import make_option class Command(BaseCommand): help = "Clean up expired captcha hashkeys." def handle(self, **options): from captcha.models import CaptchaStore import datetime verbose = int(...
Python
import os from django.conf import settings CAPTCHA_FONT_PATH = getattr(settings,'CAPTCHA_FONT_PATH', os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'fonts/Vera.ttf'))) CAPTCHA_FONT_SIZE = getattr(settings,'CAPTCHA_FONT_SIZE', 22) CAPTCHA_LETTER_ROTATION = getattr(settings, 'CAPTCHA_LETTER_ROTATION', (...
Python
from cStringIO import StringIO from captcha.models import CaptchaStore from django.http import HttpResponse, Http404 from django.shortcuts import get_object_or_404 from captcha.conf import settings import re, random try: import Image, ImageDraw, ImageFont, ImageFilter except ImportError: from PIL import Image,...
Python
VERSION = (0, 1, 7) def get_version(svn=False): "Returns the version as a human-format string." v = '.'.join([str(i) for i in VERSION]) if svn: from django.utils.version import get_svn_revision import os svn_rev = get_svn_revision(os.path.dirname(__file__)) if svn_rev: ...
Python
# coding: utf-8 # imports import re, os # django imports from django import forms from django.forms.formsets import BaseFormSet from django.utils.translation import ugettext as _ # filebrowser imports from filebrowser.settings import MAX_UPLOAD_SIZE, FOLDER_REGEX from filebrowser.functions import convert_filename a...
Python
# This file is only necessary for the tests to work
Python
# coding: utf-8 # imports import os # django imports from django.db import models from django import forms from django.forms.widgets import Input from django.db.models.fields import Field, CharField from django.utils.encoding import force_unicode from django.template.loader import render_to_string from django.utils.t...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', # filebrowser urls url(r'^browse/$', 'filebrowser.views.browse', name="fb_browse"), url(r'^mkdir/', 'filebrowser.views.mkdir', name="fb_mkdir"), url(r'^upload/', 'filebrowser.views.upload', name="fb_upload"), url(r'^rename/$', ...
Python
# coding: utf-8 # django imports from django import template from django.utils.encoding import smart_unicode from django.utils.safestring import mark_safe # filebrowser imports from filebrowser.settings import SELECT_FORMATS register = template.Library() @register.inclusion_tag('filebrowser/include/_response.html'...
Python
# coding: utf-8 from django.utils.html import escape from django.utils.safestring import mark_safe from django.template import Library register = Library() DOT = '.' @register.inclusion_tag('filebrowser/include/paginator.html', takes_context=True) def pagination(context): page_num = context['page'].number-1 ...
Python
# coding: utf-8 # django imports from django.template import Node from django.template import Library from django.utils.safestring import mark_safe register = Library() class CsrfTokenNode(Node): def render(self, context): csrf_token = context.get('csrf_token', None) if csrf_token: i...
Python
# coding: utf-8 # imports import os, re from time import gmtime # django imports from django.template import Library, Node, Variable, VariableDoesNotExist, TemplateSyntaxError from django.conf import settings from django.utils.encoding import force_unicode # filebrowser imports from filebrowser.settings import MEDIA...
Python
# coding: utf-8 # imports import os # django imports from django.conf import settings from django.utils.translation import ugettext_lazy as _ # settings for django-tinymce try: import tinymce.settings DEFAULT_URL_TINYMCE = tinymce.settings.JS_BASE_URL + '/' DEFAULT_PATH_TINYMCE = tinymce.settings.JS_ROOT...
Python
# coding: utf-8 # django imports from django.contrib.sessions.models import Session from django.shortcuts import get_object_or_404, render_to_response from django.contrib.auth.models import User from django.template import RequestContext from django.conf import settings def flash_login_required(function): """ ...
Python
from django.core.management.base import NoArgsCommand class Command(NoArgsCommand): help = "(Re)Generate versions of Images" def handle_noargs(self, **options): import os, re from filebrowser.settings import EXTENSION_LIST, EXCLUDE, MEDIA_ROOT, DIRECTORY, VERSIONS, EXTENSIONS ...
Python
# coding: utf-8 # imports import os, re, datetime from time import gmtime, strftime # django imports from django.conf import settings # filebrowser imports from filebrowser.settings import * from filebrowser.functions import get_file_type, url_join, is_selectable, get_version_path # PIL import if STRICT_PIL: fr...
Python
# coding: utf-8 # imports import os, re, decimal from time import gmtime, strftime, localtime, mktime, time from urlparse import urlparse # django imports from django.utils.translation import ugettext as _ from django.utils.safestring import mark_safe from django.core.files import File from django.core.files.storage ...
Python
# coding: utf-8 # general imports import os, re from time import gmtime, strftime # django imports from django.shortcuts import render_to_response, HttpResponse from django.template import RequestContext as Context from django.http import HttpResponseRedirect from django.contrib.admin.views.decorators import staff_me...
Python
# coding: utf-8 from django.shortcuts import render_to_response from django.http import Http404, HttpResponse from django.template import Context, Template from django.contrib.contenttypes.models import ContentType from django.utils.html import strip_tags, fix_ampersands, escape from django.utils.encoding import forc...
Python
# coding: utf-8 from django.shortcuts import render_to_response from django.template import RequestContext from django.shortcuts import get_object_or_404 from django.contrib.admin.views.decorators import staff_member_required from django.utils.translation import ugettext as _ from grappelli.models.help import Help, H...
Python
# coding: utf-8 from django.http import HttpResponse from django.db import models def related_lookup(request): if request.method == 'GET': if request.GET.has_key('object_id') and request.GET.has_key('app_label') and request.GET.has_key('model_name'): object_id = request.GET.get('object_id...
Python
# -*- coding: utf-8 -*- # imports import urllib # django imports from django.shortcuts import HttpResponse, render_to_response from django.http import HttpResponseRedirect from django.contrib.admin.views.decorators import staff_member_required from django.utils.translation import ugettext as _ # grappelli imports fr...
Python
"""Beautiful Soup Elixir and Tonic "The Screen-Scraper's Friend" http://www.crummy.com/software/BeautifulSoup/ Beautiful Soup parses a (possibly invalid) XML or HTML document into a tree representation. It provides methods and Pythonic idioms that make it easy to navigate, search, and modify the tree. A well-formed X...
Python
# coding: utf-8 from django.db import connection, models from django.db.models.signals import post_delete, post_save qn = connection.ops.quote_name class PositionField(models.IntegerField): """A model field to manage the position of an item within a collection. By default all instances of a model are trea...
Python
# coding: utf-8 from django.db import models, transaction from django.utils.translation import ugettext as _ from grappelli.fields import PositionField class Help(models.Model): """ Help Entry. """ title = models.CharField(_('Title'), max_length=50) # order order = PositionField(_('...
Python
from grappelli.models.navigation import Navigation, NavigationItem from grappelli.models.bookmarks import Bookmark, BookmarkItem from grappelli.models.help import Help, HelpItem
Python
# coding: utf-8 from django.db import models, transaction from django.utils.translation import ugettext as _ from grappelli.fields import PositionField class Bookmark(models.Model): """ Bookmark. """ user = models.ForeignKey('auth.User', limit_choices_to={'is_staff': True}, verbose_name=_('User'...
Python
# coding: utf-8 from django.db import models, transaction from django.utils.translation import ugettext as _ from grappelli.fields import PositionField ITEM_CATEGORY_CHOICES = ( ('1', 'internal'), ('2', 'external'), ) class Navigation(models.Model): """ Sidebar-Navigation on the Admin Index-Site. ...
Python
# coding: utf-8 from django.conf.urls.defaults import * urlpatterns = patterns('', # BOOKMARKS url(r'^bookmark/add/$', 'grappelli.views.bookmarks.add_bookmark', name="grp_bookmark_add"), url(r'^bookmark/remove/$', 'grappelli.views.bookmarks.remove_bookmark', name="grp_bookmark_remove"), url(r'^bo...
Python
# coding: utf-8 # django imports from django.template import Node from django.template import Library from django.utils.safestring import mark_safe register = Library() class CsrfTokenNode(Node): def render(self, context): csrf_token = context.get('csrf_token', None) if csrf_token: i...
Python