Redo non-obsoleted patches to Django - hiding password change in admin, username max_length, JSON serialization of timedelta and debug hack to DoesNotExist so .get() shows the kwargs
- Legacy-Id: 6873
This commit is contained in:
parent
73f3ce0905
commit
b54f3d05cd
|
@ -223,12 +223,12 @@ class AdminSite(object):
|
||||||
url(r'^logout/$',
|
url(r'^logout/$',
|
||||||
wrap(self.logout),
|
wrap(self.logout),
|
||||||
name='logout'),
|
name='logout'),
|
||||||
url(r'^password_change/$',
|
#url(r'^password_change/$',
|
||||||
wrap(self.password_change, cacheable=True),
|
# wrap(self.password_change, cacheable=True),
|
||||||
name='password_change'),
|
# name='password_change'),
|
||||||
url(r'^password_change/done/$',
|
#url(r'^password_change/done/$',
|
||||||
wrap(self.password_change_done, cacheable=True),
|
# wrap(self.password_change_done, cacheable=True),
|
||||||
name='password_change_done'),
|
# name='password_change_done'),
|
||||||
url(r'^jsi18n/$',
|
url(r'^jsi18n/$',
|
||||||
wrap(self.i18n_javascript, cacheable=True),
|
wrap(self.i18n_javascript, cacheable=True),
|
||||||
name='jsi18n'),
|
name='jsi18n'),
|
||||||
|
@ -313,6 +313,9 @@ class AdminSite(object):
|
||||||
"""
|
"""
|
||||||
Displays the login form for the given HttpRequest.
|
Displays the login form for the given HttpRequest.
|
||||||
"""
|
"""
|
||||||
|
url = "/accounts/login/?next="+request.get_full_path()
|
||||||
|
return http.HttpResponseRedirect(url)
|
||||||
|
|
||||||
from django.contrib.auth.views import login
|
from django.contrib.auth.views import login
|
||||||
context = {
|
context = {
|
||||||
'title': _('Log in'),
|
'title': _('Log in'),
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
{% if docsroot %}
|
{% if docsroot %}
|
||||||
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
|
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% comment %}
|
||||||
{% if user.has_usable_password %}
|
{% if user.has_usable_password %}
|
||||||
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
|
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endcomment %}
|
||||||
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
|
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -73,9 +73,9 @@ class UserCreationForm(forms.ModelForm):
|
||||||
'duplicate_username': _("A user with that username already exists."),
|
'duplicate_username': _("A user with that username already exists."),
|
||||||
'password_mismatch': _("The two password fields didn't match."),
|
'password_mismatch': _("The two password fields didn't match."),
|
||||||
}
|
}
|
||||||
username = forms.RegexField(label=_("Username"), max_length=30,
|
username = forms.RegexField(label=_("Username"), max_length=64,
|
||||||
regex=r'^[\w.@+-]+$',
|
regex=r'^[\w.@+-]+$',
|
||||||
help_text=_("Required. 30 characters or fewer. Letters, digits and "
|
help_text=_("Required. 64 characters or fewer. Letters, digits and "
|
||||||
"@/./+/-/_ only."),
|
"@/./+/-/_ only."),
|
||||||
error_messages={
|
error_messages={
|
||||||
'invalid': _("This value may contain only letters, numbers and "
|
'invalid': _("This value may contain only letters, numbers and "
|
||||||
|
@ -123,8 +123,8 @@ class UserCreationForm(forms.ModelForm):
|
||||||
|
|
||||||
class UserChangeForm(forms.ModelForm):
|
class UserChangeForm(forms.ModelForm):
|
||||||
username = forms.RegexField(
|
username = forms.RegexField(
|
||||||
label=_("Username"), max_length=30, regex=r"^[\w.@+-]+$",
|
label=_("Username"), max_length=64, regex=r"^[\w.@+-]+$",
|
||||||
help_text=_("Required. 30 characters or fewer. Letters, digits and "
|
help_text=_("Required. 64 characters or fewer. Letters, digits and "
|
||||||
"@/./+/-/_ only."),
|
"@/./+/-/_ only."),
|
||||||
error_messages={
|
error_messages={
|
||||||
'invalid': _("This value may contain only letters, numbers and "
|
'invalid': _("This value may contain only letters, numbers and "
|
||||||
|
|
|
@ -365,8 +365,8 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
|
||||||
|
|
||||||
Username, password and email are required. Other fields are optional.
|
Username, password and email are required. Other fields are optional.
|
||||||
"""
|
"""
|
||||||
username = models.CharField(_('username'), max_length=30, unique=True,
|
username = models.CharField(_('username'), max_length=64, unique=True,
|
||||||
help_text=_('Required. 30 characters or fewer. Letters, numbers and '
|
help_text=_('Required. 64 characters or fewer. Letters, numbers and '
|
||||||
'@/./+/-/_ characters'),
|
'@/./+/-/_ characters'),
|
||||||
validators=[
|
validators=[
|
||||||
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')
|
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')
|
||||||
|
|
|
@ -100,6 +100,8 @@ class DjangoJSONEncoder(json.JSONEncoder):
|
||||||
return r
|
return r
|
||||||
elif isinstance(o, decimal.Decimal):
|
elif isinstance(o, decimal.Decimal):
|
||||||
return str(o)
|
return str(o)
|
||||||
|
elif isinstance(o, datetime.timedelta):
|
||||||
|
return o.days * 24*60*60 + o.seconds
|
||||||
else:
|
else:
|
||||||
return super(DjangoJSONEncoder, self).default(o)
|
return super(DjangoJSONEncoder, self).default(o)
|
||||||
|
|
||||||
|
|
|
@ -302,9 +302,8 @@ class QuerySet(object):
|
||||||
if num == 1:
|
if num == 1:
|
||||||
return clone._result_cache[0]
|
return clone._result_cache[0]
|
||||||
if not num:
|
if not num:
|
||||||
raise self.model.DoesNotExist(
|
raise self.model.DoesNotExist(u"%s matching query does not exist. Lookup parameters were %s"
|
||||||
"%s matching query does not exist." %
|
% (self.model._meta.object_name, kwargs))
|
||||||
self.model._meta.object_name)
|
|
||||||
raise self.model.MultipleObjectsReturned(
|
raise self.model.MultipleObjectsReturned(
|
||||||
"get() returned more than one %s -- it returned %s!" %
|
"get() returned more than one %s -- it returned %s!" %
|
||||||
(self.model._meta.object_name, num))
|
(self.model._meta.object_name, num))
|
||||||
|
|
Loading…
Reference in a new issue