Skip to content

Commit

Permalink
[refactor] Reformatted the code
Browse files Browse the repository at this point in the history
Formatted code using openwisp-qa-format
Solves rst errors in README
  • Loading branch information
devkapilbansal authored and nemesifier committed Oct 7, 2020
1 parent 3385539 commit 988cd27
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 103 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Settings
--------

``OPENWISP_ORGANIZATION_USER_ADMIN``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+--------------+------------------+
| **type**: | ``boolean`` |
Expand All @@ -188,7 +188,7 @@ It is disabled by default because these items can be managed via inline items
in the user administration section.

``OPENWISP_ORGANIZATION_OWNER_ADMIN``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+--------------+------------------+
| **type**: | ``boolean`` |
Expand Down
14 changes: 3 additions & 11 deletions openwisp_users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,7 @@ class UserCreationForm(UserFormMixin, BaseUserCreationForm):
phone_number = PhoneNumberField(widget=forms.TextInput(), required=False)

class Meta(BaseUserCreationForm.Meta):
fields = [
'username',
'email',
'password1',
'password2',
]
fields = ['username', 'email', 'password1', 'password2']
personal_fields = ['first_name', 'last_name', 'phone_number']
fieldsets = (
(None, {'classes': ('wide',), 'fields': fields}),
Expand All @@ -186,10 +181,7 @@ class Meta(BaseUserCreationForm.Meta):
)

class Media:
js = (
'admin/js/jquery.init.js',
'openwisp-users/js/addform.js',
)
js = ('admin/js/jquery.init.js', 'openwisp-users/js/addform.js')


class UserChangeForm(UserFormMixin, BaseUserChangeForm):
Expand Down Expand Up @@ -600,7 +592,7 @@ def delete_selected_overridden(self, request, queryset):


class OrganizationOwnerAdmin(
MultitenantAdminMixin, BaseOrganizationOwnerAdmin, BaseAdmin,
MultitenantAdminMixin, BaseOrganizationOwnerAdmin, BaseAdmin
):
list_display = ('get_user', 'organization')

Expand Down
10 changes: 4 additions & 6 deletions openwisp_users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0008_alter_user_username_max_length'),
]
dependencies = [('auth', '0008_alter_user_username_max_length')]

operations = [
migrations.CreateModel(
Expand Down Expand Up @@ -124,7 +122,7 @@ class Migration(migrations.Migration):
'verbose_name': 'user',
'abstract': False,
},
managers=[('objects', openwisp_users.base.models.UserManager()),],
managers=[('objects', openwisp_users.base.models.UserManager())],
),
migrations.CreateModel(
name='Organization',
Expand Down Expand Up @@ -285,7 +283,7 @@ class Migration(migrations.Migration):
'proxy': True,
},
bases=('auth.group',),
managers=[('objects', django.contrib.auth.models.GroupManager()),],
managers=[('objects', django.contrib.auth.models.GroupManager())],
),
migrations.AddField(
model_name='organizationowner',
Expand Down Expand Up @@ -329,6 +327,6 @@ class Migration(migrations.Migration):
),
),
migrations.AlterUniqueTogether(
name='organizationuser', unique_together=set([('user', 'organization')]),
name='organizationuser', unique_together=set([('user', 'organization')])
),
]
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0002_auto_20180508_2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0001_initial'),
]
dependencies = [('openwisp_users', '0001_initial')]

operations = [
migrations.AlterField(
Expand All @@ -16,5 +14,5 @@ class Migration(migrations.Migration):
field=models.CharField(
blank=True, max_length=150, verbose_name='last name'
),
),
)
]
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0003_default_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0002_auto_20180508_2017'),
]
dependencies = [('openwisp_users', '0002_auto_20180508_2017')]

operations = [
migrations.RunPython(
set_default_organization_uuid, reverse_code=migrations.RunPython.noop
),
)
]
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0004_default_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0003_default_organization'),
]
dependencies = [('openwisp_users', '0003_default_organization')]

operations = [
migrations.RunPython(
create_default_groups, reverse_code=migrations.RunPython.noop
),
)
]
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0005_user_phone_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0004_default_groups'),
]
dependencies = [('openwisp_users', '0004_default_groups')]

operations = [
migrations.AddField(
Expand All @@ -17,5 +15,5 @@ class Migration(migrations.Migration):
field=phonenumber_field.modelfields.PhoneNumberField(
blank=True, unique=True, max_length=128, null=True, region=None
),
),
)
]
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0006_id_email_index_together.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0005_user_phone_number'),
]
dependencies = [('openwisp_users', '0005_user_phone_number')]

operations = [
migrations.AlterIndexTogether(name='user', index_together={('id', 'email')},),
migrations.AlterIndexTogether(name='user', index_together={('id', 'email')})
]
4 changes: 1 addition & 3 deletions openwisp_users/migrations/0007_unique_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def set_blank_emails_to_none(apps, schema_editor):

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0006_id_email_index_together'),
]
dependencies = [('openwisp_users', '0006_id_email_index_together')]

operations = [
# allow NULL
Expand Down
6 changes: 2 additions & 4 deletions openwisp_users/migrations/0008_update_admins_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0007_unique_email'),
]
dependencies = [('openwisp_users', '0007_unique_email')]

operations = [
migrations.RunPython(
update_admins_permissions, reverse_code=migrations.RunPython.noop
),
)
]
4 changes: 1 addition & 3 deletions openwisp_users/migrations/0009_create_organization_owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0008_update_admins_permissions'),
]
dependencies = [('openwisp_users', '0008_update_admins_permissions')]

operations = [migrations.RunPython(create_organization_owners)]
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0009_create_organization_owners'),
]
dependencies = [('openwisp_users', '0009_create_organization_owners')]

operations = [
migrations.RunPython(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

class Migration(migrations.Migration):

dependencies = [
('openwisp_users', '0010_allow_admins_change_organization'),
]
dependencies = [('openwisp_users', '0010_allow_admins_change_organization')]

operations = [
migrations.AlterField(
Expand All @@ -16,5 +14,5 @@ class Migration(migrations.Migration):
field=models.CharField(
blank=True, max_length=150, verbose_name='first name'
),
),
)
]
3 changes: 1 addition & 2 deletions openwisp_users/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def create_default_groups(apps, schema_editor):
codename='delete_organizationuser',
).pk,
Permission.objects.get(
content_type__app_label=model_app_label,
codename='add_organizationuser',
content_type__app_label=model_app_label, codename='add_organizationuser'
).pk,
]
try:
Expand Down
6 changes: 3 additions & 3 deletions openwisp_users/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
ORGANIZATION_USER_ADMIN = (
# setting with typographic error for maintaining backward compatibility
# TODO: remove in openwisp-users 0.5
getattr(settings, 'OPENWISP_ORGANIZATON_USER_ADMIN', False) or
getattr(settings, 'OPENWISP_ORGANIZATION_USER_ADMIN', False)
getattr(settings, 'OPENWISP_ORGANIZATON_USER_ADMIN', False)
or getattr(settings, 'OPENWISP_ORGANIZATION_USER_ADMIN', False)
)
ORGANIZATION_OWNER_ADMIN = (
# setting with typographic error for maintaining backward compatibility
# TODO: remove in openwisp-users 0.5
getattr(settings, 'OPENWISP_ORGANIZATON_OWNER_ADMIN', True) or
getattr(settings, 'OPENWISP_ORGANIZATON_OWNER_ADMIN', True)
or getattr(settings, 'OPENWISP_ORGANIZATON_OWNER_ADMIN', True)
)
USERS_AUTH_API = getattr(settings, 'OPENWISP_USERS_AUTH_API', False)
USERS_AUTH_THROTTLE_RATE = getattr(
Expand Down
6 changes: 3 additions & 3 deletions openwisp_users/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def test_org_owner_can_edit_org_owner(self):
'is_staff': True,
},
'is_owner': True,
},
}
}
self._test_change(options)

Expand All @@ -637,7 +637,7 @@ def test_staff_can_edit_itself(self):
'is_staff': True,
},
'is_owner': False,
},
}
}
self._test_change(options)

Expand Down Expand Up @@ -1494,7 +1494,7 @@ def _create_multitenancy_test_env(self):
user23 = self._create_user(
username='user23', email='[email protected]', is_superuser=True
)
user3 = self._create_user(username='user3', email='[email protected]',)
user3 = self._create_user(username='user3', email='[email protected]')
organization_user1 = self._create_org_user(
organization=org1, user=user1, is_admin=True
)
Expand Down
10 changes: 2 additions & 8 deletions openwisp_users/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def test_unique_email_validation(self):
u.full_clean()

def test_create_user_without_email(self):
options = {
'username': 'testuser',
'password': 'test1',
}
options = {'username': 'testuser', 'password': 'test1'}
u = self.user_model(**options)
u.full_clean()
u.save()
Expand Down Expand Up @@ -189,10 +186,7 @@ def test_organization_owner_bad_organization(self):
org_owner.full_clean()

def test_create_users_without_email(self):
options = {
'username': 'testuser',
'password': 'test1',
}
options = {'username': 'testuser', 'password': 'test1'}
u = self.user_model(**options)
u.full_clean()
u.save()
Expand Down
2 changes: 1 addition & 1 deletion tests/openwisp2/sample_users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Fields to be added in the UserAdmin
additional_fields = [
# [position-of-field-in-form, name-of-field]
[2, 'social_security_number'],
[2, 'social_security_number']
]

# Add field to the User sign up form
Expand Down
20 changes: 9 additions & 11 deletions tests/openwisp2/sample_users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0011_update_proxy_permissions'),
]
dependencies = [('auth', '0011_update_proxy_permissions')]

operations = [
migrations.CreateModel(
Expand Down Expand Up @@ -172,7 +170,7 @@ class Migration(migrations.Migration):
'abstract': False,
'index_together': {('id', 'email')},
},
managers=[('objects', openwisp_users.base.models.UserManager()),],
managers=[('objects', openwisp_users.base.models.UserManager())],
),
migrations.CreateModel(
name='Group',
Expand All @@ -190,9 +188,9 @@ class Migration(migrations.Migration):
),
('details', models.CharField(blank=True, max_length=64, null=True)),
],
options={'abstract': False,},
options={'abstract': False},
bases=(openwisp_users.base.models.BaseGroup, 'auth.group', models.Model),
managers=[('objects', django.contrib.auth.models.GroupManager()),],
managers=[('objects', django.contrib.auth.models.GroupManager())],
),
migrations.CreateModel(
name='Organization',
Expand Down Expand Up @@ -247,7 +245,7 @@ class Migration(migrations.Migration):
),
('details', models.CharField(blank=True, max_length=64, null=True)),
],
options={'abstract': False,},
options={'abstract': False},
bases=(organizations.base.UnicodeMixin, models.Model),
),
migrations.CreateModel(
Expand All @@ -271,7 +269,7 @@ class Migration(migrations.Migration):
),
),
],
options={'abstract': False,},
options={'abstract': False},
),
migrations.CreateModel(
name='OrganizationUser',
Expand Down Expand Up @@ -316,7 +314,7 @@ class Migration(migrations.Migration):
),
),
],
options={'abstract': False,},
options={'abstract': False},
bases=(organizations.base.UnicodeMixin, models.Model),
),
migrations.CreateModel(
Expand Down Expand Up @@ -360,7 +358,7 @@ class Migration(migrations.Migration):
),
),
],
options={'abstract': False,},
options={'abstract': False},
bases=(organizations.base.UnicodeMixin, models.Model),
),
migrations.CreateModel(
Expand All @@ -384,7 +382,7 @@ class Migration(migrations.Migration):
),
),
],
options={'abstract': False,},
options={'abstract': False},
),
migrations.AddField(
model_name='organization',
Expand Down
Loading

0 comments on commit 988cd27

Please sign in to comment.