mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
fa74a26042
commit
eb83e00011
134 files changed
+598
-720
No files matched your search
@@ -47,14 +47,13 @@ def get_group_choices():
|
||||
|
||||
class ValidNewUsernameCheckMixin(object):
|
||||
"""Mixin to check if a username is valid for created new user."""
|
||||
|
||||
def clean_username(self):
|
||||
"""Check for username collisions with system users."""
|
||||
username = self.cleaned_data['username']
|
||||
if self.instance.username != username and \
|
||||
not self.is_valid_new_username():
|
||||
raise ValidationError(
|
||||
_('Username is taken or is reserved.'), code='invalid')
|
||||
raise ValidationError(_('Username is taken or is reserved.'),
|
||||
code='invalid')
|
||||
|
||||
return username
|
||||
|
||||
@@ -147,10 +146,8 @@ class UserUpdateForm(ValidNewUsernameCheckMixin,
|
||||
plinth.forms.LanguageSelectionFormMixin, forms.ModelForm):
|
||||
"""When user info is changed, also updates LDAP user."""
|
||||
ssh_keys = forms.CharField(
|
||||
label=ugettext_lazy('Authorized SSH Keys'),
|
||||
required=False,
|
||||
widget=forms.Textarea,
|
||||
help_text=ugettext_lazy(
|
||||
label=ugettext_lazy('Authorized SSH Keys'), required=False,
|
||||
widget=forms.Textarea, help_text=ugettext_lazy(
|
||||
'Setting an SSH public key will allow this user to '
|
||||
'securely log in to the system without using a '
|
||||
'password. You may enter multiple keys, one on each '
|
||||
@@ -283,14 +280,12 @@ class UserUpdateForm(ValidNewUsernameCheckMixin,
|
||||
|
||||
class UserChangePasswordForm(SetPasswordForm):
|
||||
"""Custom form that also updates password for LDAP users."""
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
"""Initialize the form with extra request argument."""
|
||||
self.request = request
|
||||
super(UserChangePasswordForm, self).__init__(*args, **kwargs)
|
||||
self.fields['new_password1'].widget.attrs.update({
|
||||
'autofocus': 'autofocus'
|
||||
})
|
||||
self.fields['new_password1'].widget.attrs.update(
|
||||
{'autofocus': 'autofocus'})
|
||||
|
||||
def save(self, commit=True):
|
||||
"""Save the user model and change LDAP password as well."""
|
||||
@@ -310,7 +305,6 @@ class UserChangePasswordForm(SetPasswordForm):
|
||||
|
||||
class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
|
||||
"""User module first boot step: create a new admin user."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.request = kwargs.pop('request')
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@@ -81,8 +81,8 @@ def _try_login_to_ssh(username, password, returncode=0):
|
||||
def _action_file():
|
||||
"""Return the path to the 'users' actions file."""
|
||||
current_directory = pathlib.Path(__file__).parent
|
||||
return str(
|
||||
current_directory / '..' / '..' / '..' / '..' / 'actions' / 'users')
|
||||
return str(current_directory / '..' / '..' / '..' / '..' / 'actions' /
|
||||
'users')
|
||||
|
||||
|
||||
@pytest.fixture(name='disable_restricted_access', autouse=True)
|
||||
|
||||
@@ -40,7 +40,6 @@ from .forms import (CreateUserForm, FirstBootForm, UserChangePasswordForm,
|
||||
|
||||
class ContextMixin(object):
|
||||
"""Mixin to add 'title' to the template context."""
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add self.title to template context."""
|
||||
context = super(ContextMixin, self).get_context_data(**kwargs)
|
||||
|
||||
Reference in new issue
Block a user