def test_render(self):
     widget = ReadOnlyPasswordHashWidget()
     value = 'pbkdf2_sha256$100000$a6Pucb1qSFcD$WmCkn9Hqidj48NVe5x0FEM6A9YiOqQcl/83m2Z5udm0='
     self.assertHTMLEqual(
         widget.render('name', value, {'id': 'id_password'}), """
         <div id="id_password">
             <strong>algorithm</strong>: pbkdf2_sha256
             <strong>iterations</strong>: 100000
             <strong>salt</strong>: a6Pucb******
             <strong>hash</strong>: WmCkn9**************************************
         </div>
         """)
Exemple #2
0
 def test_render(self):
     widget = ReadOnlyPasswordHashWidget()
     value = 'pbkdf2_sha256$100000$a6Pucb1qSFcD$WmCkn9Hqidj48NVe5x0FEM6A9YiOqQcl/83m2Z5udm0='
     self.assertHTMLEqual(
         widget.render('name', value, {'id': 'id_password'}),
         """
         <div id="id_password">
             <strong>algorithm</strong>: pbkdf2_sha256
             <strong>iterations</strong>: 100000
             <strong>salt</strong>: a6Pucb******
             <strong>hash</strong>: WmCkn9**************************************
         </div>
         """
     )
Exemple #3
0
class UserChangeForm(forms.ModelForm):
    # 화면에 뿌려줄 읽기 전용 데이터(수정 할 수 없음)
    password = ReadOnlyPasswordHashWidget()

    class Meta:
        model = User
        fields = ['email', 'username', 'password', 'is_active', 'is_admin']

    def clean_password(self):
        return self.initial['password']
Exemple #4
0
class UserChangeForm(forms.ModelForm):
    """A form for updating users. Includes all the fields on
    the user, but replaces the password field with admin's
    password hash display field.
    """
    # password = ReadOnlyPasswordHashField()
    password = ReadOnlyPasswordHashWidget()

    class Meta:
        model = MyUser
        fields = ('nom', 'password', 'point', 'is_active', 'is_admin')

    def clean_password(self):
        # Regardless of what the user provides, return the initial value.
        # This is done here, rather than on the field, because the
        # field does not have access to the initial value
        return self.initial["password"]
 def test_bug_19349_render_with_none_value(self):
     # Rendering the widget with value set to None
     # mustn't raise an exception.
     widget = ReadOnlyPasswordHashWidget()
     html = widget.render(name='password', value=None, attrs={})
     self.assertIn(_("No password set."), html)
 def test_bug_19349_render_with_none_value(self):
     # Rendering the widget with value set to None
     # mustn't raise an exception.
     widget = ReadOnlyPasswordHashWidget()
     html = widget.render(name='password', value=None, attrs={})
     self.assertIn(_("No password set."), html)