Skip to content

Commit b54f3d0

Browse files
committed
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
1 parent 73f3ce0 commit b54f3d0

6 files changed

Lines changed: 21 additions & 15 deletions

File tree

django/contrib/admin/sites.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ def wrapper(*args, **kwargs):
223223
url(r'^logout/$',
224224
wrap(self.logout),
225225
name='logout'),
226-
url(r'^password_change/$',
227-
wrap(self.password_change, cacheable=True),
228-
name='password_change'),
229-
url(r'^password_change/done/$',
230-
wrap(self.password_change_done, cacheable=True),
231-
name='password_change_done'),
226+
#url(r'^password_change/$',
227+
# wrap(self.password_change, cacheable=True),
228+
# name='password_change'),
229+
#url(r'^password_change/done/$',
230+
# wrap(self.password_change_done, cacheable=True),
231+
# name='password_change_done'),
232232
url(r'^jsi18n/$',
233233
wrap(self.i18n_javascript, cacheable=True),
234234
name='jsi18n'),
@@ -313,6 +313,9 @@ def login(self, request, extra_context=None):
313313
"""
314314
Displays the login form for the given HttpRequest.
315315
"""
316+
url = "/accounts/login/?next="+request.get_full_path()
317+
return http.HttpResponseRedirect(url)
318+
316319
from django.contrib.auth.views import login
317320
context = {
318321
'title': _('Log in'),

django/contrib/admin/templates/admin/base.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
{% if docsroot %}
3333
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
3434
{% endif %}
35+
{% comment %}
3536
{% if user.has_usable_password %}
3637
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
3738
{% endif %}
39+
{% endcomment %}
3840
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
3941
{% endblock %}
4042
</div>

django/contrib/auth/forms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class UserCreationForm(forms.ModelForm):
7373
'duplicate_username': _("A user with that username already exists."),
7474
'password_mismatch': _("The two password fields didn't match."),
7575
}
76-
username = forms.RegexField(label=_("Username"), max_length=30,
76+
username = forms.RegexField(label=_("Username"), max_length=64,
7777
regex=r'^[\w.@+-]+$',
78-
help_text=_("Required. 30 characters or fewer. Letters, digits and "
78+
help_text=_("Required. 64 characters or fewer. Letters, digits and "
7979
"@/./+/-/_ only."),
8080
error_messages={
8181
'invalid': _("This value may contain only letters, numbers and "
@@ -123,8 +123,8 @@ def save(self, commit=True):
123123

124124
class UserChangeForm(forms.ModelForm):
125125
username = forms.RegexField(
126-
label=_("Username"), max_length=30, regex=r"^[\w.@+-]+$",
127-
help_text=_("Required. 30 characters or fewer. Letters, digits and "
126+
label=_("Username"), max_length=64, regex=r"^[\w.@+-]+$",
127+
help_text=_("Required. 64 characters or fewer. Letters, digits and "
128128
"@/./+/-/_ only."),
129129
error_messages={
130130
'invalid': _("This value may contain only letters, numbers and "

django/contrib/auth/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
365365
366366
Username, password and email are required. Other fields are optional.
367367
"""
368-
username = models.CharField(_('username'), max_length=30, unique=True,
369-
help_text=_('Required. 30 characters or fewer. Letters, numbers and '
368+
username = models.CharField(_('username'), max_length=64, unique=True,
369+
help_text=_('Required. 64 characters or fewer. Letters, numbers and '
370370
'@/./+/-/_ characters'),
371371
validators=[
372372
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')

django/core/serializers/json.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def default(self, o):
100100
return r
101101
elif isinstance(o, decimal.Decimal):
102102
return str(o)
103+
elif isinstance(o, datetime.timedelta):
104+
return o.days * 24*60*60 + o.seconds
103105
else:
104106
return super(DjangoJSONEncoder, self).default(o)
105107

django/db/models/query.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ def get(self, *args, **kwargs):
302302
if num == 1:
303303
return clone._result_cache[0]
304304
if not num:
305-
raise self.model.DoesNotExist(
306-
"%s matching query does not exist." %
307-
self.model._meta.object_name)
305+
raise self.model.DoesNotExist(u"%s matching query does not exist. Lookup parameters were %s"
306+
% (self.model._meta.object_name, kwargs))
308307
raise self.model.MultipleObjectsReturned(
309308
"get() returned more than one %s -- it returned %s!" %
310309
(self.model._meta.object_name, num))

0 commit comments

Comments
 (0)