Re: [Django] #19611: User Admin breaks on submit with form validation error

2013-05-15 Thread Django
#19611: User Admin breaks on submit with form validation error
--+--
 Reporter:  gcc   |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  contrib.auth  |  Version:  1.5
 Severity:  Normal|   Resolution:  duplicate
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  1 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+--
Changes (by anonymous):

 * version:  1.4 => 1.5


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #19611: User Admin breaks on submit with form validation error

2013-01-15 Thread Django
#19611: User Admin breaks on submit with form validation error
--+--
 Reporter:  gcc   |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  contrib.auth  |  Version:  1.4
 Severity:  Normal|   Resolution:  duplicate
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  1 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+--
Changes (by anonymous):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Duplicate of #19349

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #19611: User Admin breaks on submit with form validation error

2013-01-14 Thread Django
#19611: User Admin breaks on submit with form validation error
--+--
 Reporter:  gcc   |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.auth  |  Version:  1.4
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  1 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+--
Changes (by slurms):

 * needs_better_patch:   => 0
 * easy:  0 => 1
 * needs_tests:   => 1
 * needs_docs:   => 0


Comment:

 Could you provide an example configuration to reproduce the error with? I
 can't seem to reproduce this on current Django master.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Django] #19611: User Admin breaks on submit with form validation error

2013-01-14 Thread Django
#19611: User Admin breaks on submit with form validation error
--+
 Reporter:  gcc   |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  contrib.auth  |Version:  1.4
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+
 {{{
 Internal Server Error: /admin/users/ischooluser/4/
 ...
   File
 
"/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/utils/encoding.py",
 line 99, in force_text
 s = s.__unicode__()
   File
 
"/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/forms/forms.py",
 line 411, in __str__
 return self.as_widget()
   File
 
"/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/forms/forms.py",
 line 458, in as_widget
 return widget.render(name, self.value(), attrs=attrs)
   File
 
"/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/contrib/auth/forms.py",
 line 34, in render
 hasher = identify_hasher(encoded)
   File
 
"/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/contrib/auth/hashers.py",
 line 135, in identify_hasher
 if len(encoded) == 32 and '$' not in encoded:
 Exception: Failed to render template: admin/change_form.html: Failed to
 render template: admin/includes/fieldset.html: object of type 'NoneType'
 has no len()
 }}}

 This happens when you click the Save button on the user edit form, but the
 form doesn't validate, so it tries to display again.

 ReadOnlyPasswordHashWidget doesn't include any hidden fields, so there's
 no data bound to the field, but the form is still bound (because this is a
 POST request), so ReadOnlyPasswordHashField's bound_data returns None
 instead of the current password value:

 {{{
 >
 
/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/contrib/auth/forms.py(32)render()
 -> if encoded == '' or encoded == UNUSABLE_PASSWORD:
 (Pdb) p encoded
 None
 (Pdb) up
 >
 
/home/installuser/Dropbox/projects/ischool/user_manager/django/django-1.5/django/forms/forms.py(458)as_widget()
 -> return widget.render(name, self.value(), attrs=attrs)
 (Pdb) l
 453
 454 if not only_initial:
 455 name = self.html_name
 456 else:
 457 name = self.html_initial_name
 458  -> return widget.render(name, self.value(), attrs=attrs)
 459
 460 def as_text(self, attrs=None, **kwargs):
 461 """
 462 Returns a string of HTML for representing this as an
 .
 463 """
 (Pdb) p self
 
 >
 (Pdb) p self.form.is_bound
 True
 (Pdb) p self.form.data
 
 (Pdb) p self.name
 'password'
 (Pdb) p self.form.initial
 {'username': u'smith', 'first_name': u'', 'last_name': u'',
 'account_type': 1, 'is_active': True, 'is_superuser': False, 'is_staff':
 True, 'last_login': datetime.datetime(2012, 1, 24, 8, 36, 9,
 tzinfo=), 'groups': [2], 'user_permissions': [], 'password':
 u'sha1$03d63$4ae1e7f3426c5c8bb4e008dea8d178f88a0c62ed', 'email':
 u'j...@smithy.example.com', 'date_joined': datetime.datetime(2012, 1, 12,
 9, 44, 56, tzinfo=)}
 (Pdb) p self.form.initial.get('password')
 u'sha1$03d63$4ae1e7f3426c5c8bb4e008dea8d178f88a0c62ed'
 (Pdb) p self.field.bound_data
 >
 (Pdb) p self.field.bound_data(self.data, self.form.initial.get(self.name,
 self.field.initial))
 None
 (Pdb) p self.data
 None
 (Pdb) p self.form.initial.get(self.name, self.field.initial)
 u'sha1$03d63$4ae1e7f3426c5c8bb4e008dea8d178f88a0c62ed'
 (Pdb) c
 }}}

 Since this widget has no input fields, and therefore sends no data on
 POST, I propose modifying it to always return the initial data:

 {{{
 diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
 index 9279c52..8246a3b 100644
 --- a/django/contrib/auth/forms.py
 +++ b/django/contrib/auth/forms.py
 @@ -52,6 +54,13 @@ class ReadOnlyPasswordHashField(forms.Field):
  kwargs.setdefault("required", False)
  super(ReadOnlyPasswordHashField, self).__init__(*args, **kwargs)

 +def bound_data(self, data, initial):
 +"""
 +This widget has no fields, so data will always be None, so return
 +the initial value always.
 +"""
 +return initial
 +

  class UserCreationForm(forms.ModelForm):
  """
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.