djangosnippets.org: Latest snippets posted by brutassehttps://djangosnippets.org/users/brutasse/2011-02-15T09:43:46.141655-06:00brutasselogin_required decorator that doesn't redirect
2011-02-15T09:43:46.141655-06:00brutassehttps://djangosnippets.org/snippets/2357/<p>A login_required decorator that wraps the login view instead of redirecting to it.</p>
<p>This prevents your site from leaking login information with HTTP status codes as explained <a href="https://grepular.com/Abusing_HTTP_Status_Codes_to_Expose_Private_Information">here</a>.</p>
<p>This is the way Django's admin is protected, the difference being that it checks for is_active and is_staff instead of is_authenticated. …</p>
Freely redistributableCurrent Page Middleware
2010-06-23T09:59:27.581750-05:00brutassehttps://djangosnippets.org/snippets/2077/<p>This module provides a middleware that implements a mechanism to
highlight a link pointing to the current URL.</p>
<p>Every link on the rendered page matching the current URL will be highlighted with a 'current_page' CSS class.</p>
<p>The name of the CSS class can be changed by setting <code>CURRENT_PAGE_CLASS</code> in the …</p>
Freely redistributableSilently-failing include tag
2010-06-10T10:00:05.213545-05:00brutassehttps://djangosnippets.org/snippets/2058/<p>This is the <code>local_settings.py</code> trick extended to Django templates.
</p>
<p>Sometimes you need to insert some arbitrary code in the HTML of the production site for external service integration like uservoice, typekit, google analytics... You don't want to put this code into source control because some other sites using the same …</p>
Freely redistributableClass-based coverage test runner
2010-06-04T08:43:16.169000-05:00brutassehttps://djangosnippets.org/snippets/2052/<p>A coverage test runner that uses the class-based runner introduced with Django 1.2.</p>
<p>Put it in your python path and add to your <code>settings.py</code>:</p>
<pre><code>TEST_RUNNER = 'path_to.CoverageRunner'
COVERAGE_MODULES = [
'blog.views',
'projects.views',
'middleware',
]
</code></pre>
<p>Compatible with Django 1.2 and higher. You also need Ned Batchelder's <code>coverage.py</code> module (<code>pip …</code></p>
Freely redistributable