From 8a99176aba8295059fd0570efbb1b0ee0cd87c13 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 20 May 2013 15:06:48 +0000 Subject: [PATCH] add missing file --- pandora/app/monkey_patch.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pandora/app/monkey_patch.py diff --git a/pandora/app/monkey_patch.py b/pandora/app/monkey_patch.py new file mode 100644 index 00000000..44d08d73 --- /dev/null +++ b/pandora/app/monkey_patch.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=4:sts=4:ts=4 +from django.contrib.auth.models import User, Group +from django.core.validators import MaxLengthValidator + +#load config from json +import config +config.init() + +NEW_LENGTH = { + 'username': 255, + 'email': 255, + 'password': 255, +} + +def monkey_patch_username(): + for field in NEW_LENGTH: + f = User._meta.get_field(field) + f.max_length = NEW_LENGTH[field] + for v in f.validators: + if isinstance(v, MaxLengthValidator): + v.limit_value = NEW_LENGTH[field] + + f = Group._meta.get_field('name') + f.max_length = 255 + for v in f.validators: + if isinstance(v, MaxLengthValidator): + v.limit_value = 255 + +monkey_patch_username()