---
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
''' | |
Taken from: https://code.djangoproject.com/ticket/17561#comment:7 | |
''' | |
from django.db import models | |
class EmailField(models.EmailField): | |
def get_prep_value(self, value): | |
value = super(EmailField, self).get_prep_value(value) |
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.models import Q | |
from django.db.models.sql.query import get_order_dir | |
# Taken from: https://gist.github.com/dokterbob/1004216 | |
def get_next_or_previous(qs, item, next=True): | |
""" | |
Get the next or previous object in the queryset, with regards to the | |
item specified. | |
""" |
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
(function ($) { | |
var updateElementIndex = function(el, prefix, ndx) { | |
var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))"); | |
var replacement = prefix + "-" + ndx; | |
if ($(el).attr("for")) { | |
$(el).attr("for", $(el).attr("for").replace(id_regex, replacement)); | |
} | |
if (el.id) { | |
el.id = el.id.replace(id_regex, replacement); | |
} |
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.core.exceptions import ValidationError | |
from django.utils.translation import ugettext_lazy as _ | |
class FileTypeValidator(object): | |
error_message = _(u'Please upload a file of the correct type.') | |
def __init__(self, regex, error_message=None): | |
self.regex = re.compile(regex) |
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
wopp = map sayIt [1..] | |
where woppln n | (mod n 7 == 0) = True | |
| ('7' `elem` show n) = True | |
| otherwise = False | |
sayIt n = (if woppln n then "wopp" else show n, if direction n > 0 then "right" else "left") | |
direction 1 = 1 | |
direction n | woppln n = (-1) * direction (n-1) | |
| otherwise = direction (n-1) | |
main = do |
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
# -*- coding: utf-8 -*- | |
import os | |
from django.core.mail import get_connection | |
from django.core.mail.message import EmailMessage | |
from django.conf import settings | |
from django.contrib.sites.models import Site | |
from django.template import Context, RequestContext | |
from django.template.loader import get_template | |
Hi my name is Gregor Müllegger. I'm a Computer Science student in Germany at the University of Augsburg currently in the fourth year of my studies. I first came to django shortly before 0.96 was released and a lots of awesomeness was introduced with the magic removal branch.
I'm also doing some django freelancing work since 2008 to finance my studies and attended DjangoCon EU in 2010. This year I would like to apply to
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.exceptions import PermissionDenied | |
from django.contrib import admin | |
from crm.models import Customer | |
class ReadPermissionModelAdmin(admin.ModelAdmin): | |
def has_change_permission(self, request, obj=None): | |
if getattr(request, 'readonly', False): | |
return True | |
return super(ReadPermissionModelAdmin, self).has_change_permission(request, obj) |