From 8ae383f9fe61fcfdf7aba5d8375b18a93769eb30 Mon Sep 17 00:00:00 2001 From: Dale Smith Date: Wed, 7 Dec 2022 19:37:28 +1300 Subject: [PATCH] Fix gates for Antelope and update Django * Zuul deprecated (and now removed) declaring shared queues at a pipeline level [1]. This patch fixes the syntax to make the gate work for adjutant. * Updates Django version to allow upper-constraints version * Fix Django 3.2 warnings * Fix flake8 errors * Remove support for Python 3.6, Python 3.7 [1] https://lists.openstack.org/pipermail/openstack-discuss/2022-May/028603.html Change-Id: Ic369b59bb062df867d78b006f06e48cf9c98a3ee --- .zuul.yaml | 6 +++--- README.rst | 7 +++---- .../0005_alter_action_auto_approve.py | 18 ++++++++++++++++++ adjutant/actions/models.py | 2 +- adjutant/actions/v1/users.py | 4 ++-- requirements.txt | 4 ++-- setup.cfg | 4 +--- tox.ini | 4 ++-- 8 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 adjutant/actions/migrations/0005_alter_action_auto_approve.py diff --git a/.zuul.yaml b/.zuul.yaml index 69d07fd..20c69b2 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -11,15 +11,15 @@ - project: + queue: adjutant templates: - publish-openstack-docs-pti - build-release-notes-jobs-python3 - openstack-cover-jobs - - openstack-python3-yoga-jobs + - openstack-python3-zed-jobs check: jobs: - adjutant-black-style-check gate: - queue: adjutant jobs: - - adjutant-black-style-check \ No newline at end of file + - adjutant-black-style-check diff --git a/README.rst b/README.rst index dea24ab..0693e64 100644 --- a/README.rst +++ b/README.rst @@ -23,10 +23,9 @@ to external systems as needed. Useful for automating generic admin tasks that users might request but otherwise can't do without the admin role. Also allows automating the -signup and creation of new users, but also allows such requests to -require approval first if wanted. Due to issuing of uri+tokens for -final steps of some actions, allows for a password submit/reset system -as well. +signup and creation of new users, and allows such requests to require +approval first if wanted. Due to issuing of uri+tokens for final steps +of some actions, allows for a password submit/reset system as well. Documentation ============= diff --git a/adjutant/actions/migrations/0005_alter_action_auto_approve.py b/adjutant/actions/migrations/0005_alter_action_auto_approve.py new file mode 100644 index 0000000..45fdff0 --- /dev/null +++ b/adjutant/actions/migrations/0005_alter_action_auto_approve.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.16 on 2022-12-07 00:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("actions", "0004_auto_20190610_0209"), + ] + + operations = [ + migrations.AlterField( + model_name="action", + name="auto_approve", + field=models.BooleanField(default=None, null=True), + ), + ] diff --git a/adjutant/actions/models.py b/adjutant/actions/models.py index f260f67..2dc31f1 100644 --- a/adjutant/actions/models.py +++ b/adjutant/actions/models.py @@ -40,7 +40,7 @@ class Action(models.Model): # Can be thought of in terms of priority, None has the # lowest priority, then True with False having the # highest priority - auto_approve = models.NullBooleanField(default=None) + auto_approve = models.BooleanField(default=None, null=True) order = models.IntegerField() created = models.DateTimeField(default=timezone.now) diff --git a/adjutant/actions/v1/users.py b/adjutant/actions/v1/users.py index 4e44310..4252dce 100644 --- a/adjutant/actions/v1/users.py +++ b/adjutant/actions/v1/users.py @@ -211,10 +211,10 @@ class ResetUserPasswordAction(UserNameAction, UserMixin): def _validate_user_roles(self): id_manager = user_store.IdentityManager() - roles = id_manager.get_all_roles(self.user) + all_roles = id_manager.get_all_roles(self.user) user_roles = [] - for roles in roles.values(): + for roles in all_roles.values(): user_roles.extend(role.name for role in roles) if set(self.config.blacklisted_roles) & set(user_roles): diff --git a/requirements.txt b/requirements.txt index 1fe6a23..bae8366 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ pbr>=5.2.0 -Django>=2.2,<2.3 +Django>=3.2.12 Babel>=2.6.0 decorator>=4.4.0 django-rest-swagger>=2.2.0 -djangorestframework>=3.9.4 +djangorestframework>=3.14.0 jsonfield>=2.0.2 keystoneauth1>=3.14.0 keystonemiddleware>=6.0.0 diff --git a/setup.cfg b/setup.cfg index 69276e8..99c8eff 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,10 +16,8 @@ classifier = Intended Audience :: Developers Intended Audience :: System Administrators License :: OSI Approved :: Apache Software License - Framework :: Django :: 2.2 + Framework :: Django :: 3.2 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Environment :: OpenStack diff --git a/tox.ini b/tox.ini index df5d31d..fcef6e6 100644 --- a/tox.ini +++ b/tox.ini @@ -67,8 +67,8 @@ extension=.txt,.rst,.inc [testenv:black] commands = - black -t py36 . + black -t py38 --exclude /(\.tox|\.venv|.*venv.*|build|dist)/ . [testenv:black_check] commands = - black -t py36 --check . + black -t py38 --exclude /(\.tox|\.venv|.*venv.*|build|dist)/ --check .