mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
[sunil's changes] - Add copyright information the logo. - Deluge: undo an unintended change. - Drop wrapper calls over privileged methods. The new privileged method decorators make is easy to avoid these. - Styling updates: docstrings, single quotes for strings, casing for UI strings. - Drop "DO NOT EDIT" comment for files located in /usr as they are not expected to be editable by the user. - Fix 'miniflux' to 'Miniflux' in web client name. - Overwrite FreedomBox settings onto the existing configuration file when setup is re-run. This is to ensure that FreedomBox settings take priority. - Use return value of the miniflux command to raise errors. - Use pathlib module where possible. - Move message parsing into the privileged module from views module. - Resize SVG and PNG logo files for consistency with icon styling. - Use hypens instead of underscores in URLs and Django URL names. - Rename miniflux_configure.html to miniflux.html. - Use base method for minor simplification in backup functional test. Ensure that the test can be run independently when other tests are not run. - Update tests to reflect code changes. - Avoid concatenating internationalized strings so that they can be translated properly. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
from django import forms
|
|
from django.core.exceptions import ValidationError
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
class UserCredentialsForm(forms.Form):
|
|
"""Form to create admin user or change a user's password."""
|
|
|
|
username = forms.CharField(label=_('Username'),
|
|
help_text=_('Enter a username for the user.'))
|
|
password = forms.CharField(
|
|
label=_('Password'), widget=forms.PasswordInput, min_length=6,
|
|
strip=False,
|
|
help_text=_('Enter a strong password with a minimum of 6 characters.'))
|
|
password_confirmation = forms.CharField(
|
|
label=_('Password confirmation'), widget=forms.PasswordInput,
|
|
min_length=6, strip=False,
|
|
help_text=_('Enter the same password for confirmation.'))
|
|
|
|
def clean(self):
|
|
"""Raise error if passwords don't match."""
|
|
cleaned_data = super().clean()
|
|
password = self.cleaned_data.get('password')
|
|
password_confirmation = self.cleaned_data.get('password_confirmation')
|
|
|
|
if password and password_confirmation and (password
|
|
!= password_confirmation):
|
|
self.add_error('password_confirmation',
|
|
ValidationError(_('Passwords do not match.')))
|
|
|
|
return cleaned_data
|