From 88bfc3309f2bbd4a8ba43fd9e1e3a2718cbb1005 Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Tue, 10 Dec 2019 13:40:57 +1000 Subject: [PATCH] Update min vstutils version --- doc/api_schema.yaml | 100 +++++++++++++++--------------- polemarch/__init__.py | 2 +- polemarch/main/models/__init__.py | 3 +- polemarch/main/models/base.py | 4 +- polemarch/main/models/tasks.py | 3 +- polemarch/main/models/users.py | 3 +- polemarch/main/models/vars.py | 1 + polemarch/main/tests/api.py | 7 +-- polemarch/main/tests/openapi.py | 4 +- tox.ini | 3 +- 10 files changed, 64 insertions(+), 66 deletions(-) diff --git a/doc/api_schema.yaml b/doc/api_schema.yaml index 3788e44a..81d52caf 100755 --- a/doc/api_schema.yaml +++ b/doc/api_schema.yaml @@ -11,52 +11,52 @@ info: has_docs: true docs_url: /docs/ x-links: - Request: - - url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Ask&issue%5Btitle%5D=Ask%20about%20version%201.5.1 - name: Question - - url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Bug&issue%5Btitle%5D=Bug%20in%20version%201.5.1 - name: Bug report - - url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Feature%20request&issue%5Btitle%5D= - name: Feature request Documentation: - url: http://polemarch.readthedocs.io/ name: Official documentation + url: http://polemarch.readthedocs.io/ Repository: - url: https://gitlab.com/vstconsulting/polemarch.git name: Official repository + url: https://gitlab.com/vstconsulting/polemarch.git + Request: + - name: Question + url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Ask&issue%5Btitle%5D=Ask%20about%20version%201.5.2 + - name: Bug report + url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Bug&issue%5Btitle%5D=Bug%20in%20version%201.5.2 + - name: Feature request + url: https://gitlab.com/vstconsulting/polemarch/issues/new?issuable_template%5D=Feature%20request&issue%5Btitle%5D= x-menu: - name: Projects - url: /project span_class: fa fa-fort-awesome + url: /project - name: Community - url: /community_template span_class: fa fa-cloud + url: /community_template - name: Inventories - url: /inventory span_class: fa fa-folder sublinks: - name: Groups - url: /group span_class: fa fa-tasks + url: /group - name: Hosts - url: /host span_class: fa fa-codepen + url: /host + url: /inventory - name: History - url: /history span_class: fa fa-calendar + url: /history - name: System span_class: fa fa-cog sublinks: - name: Users - url: /user span_class: fa fa-user + url: /user - name: Hooks - url: /hook span_class: fa fa-plug + url: /hook x-versions: - application: 1.5.1 - library: 1.5.1 - vstutils: 2.11.1 + application: 1.5.2 + library: 1.5.2 + vstutils: 2.11.2 django: 2.2.7 ansible: 2.8.7 version: v2 @@ -10953,14 +10953,14 @@ definitions: type: string format: dynamic additionalProperties: - field: key choices: {} + field: key types: - ansible_ssh_pass: password - ansible_ssh_private_key_file: secretfile ansible_become: boolean - ansible_port: integer ansible_become_pass: password + ansible_port: integer + ansible_ssh_pass: password + ansible_ssh_private_key_file: secretfile Host: type: object properties: @@ -11325,15 +11325,15 @@ definitions: format: dynamic default: NONE additionalProperties: - field: type choices: GIT: - NONE - KEY - PASSWORD + field: type types: - MANUAL: hidden GIT: string + MANUAL: hidden TAR: hidden auth_data: title: Repo auth data @@ -11341,22 +11341,22 @@ definitions: format: dynamic default: '' additionalProperties: - field: repo_auth choices: {} + field: repo_auth types: KEY: secretfile - PASSWORD: password NONE: hidden + PASSWORD: password branch: title: Branch for GIT(branch/tag/SHA) or TAR(subdir) type: string format: dynamic additionalProperties: - field: type choices: {} + field: type types: - MANUAL: hidden GIT: string + MANUAL: hidden TAR: string x-nullable: true OneProject: @@ -11885,22 +11885,22 @@ definitions: type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: fk_autocomplete MODULE: fk_autocomplete + PLAYBOOK: fk_autocomplete TEMPLATE: hidden inventory: title: Inventory type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: fk_autocomplete MODULE: fk_autocomplete + PLAYBOOK: fk_autocomplete TEMPLATE: hidden save_result: title: Save result @@ -11914,11 +11914,11 @@ definitions: type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: hidden MODULE: hidden + PLAYBOOK: hidden TEMPLATE: autocomplete enabled: title: Enabled @@ -11935,8 +11935,8 @@ definitions: type: string format: dynamic additionalProperties: - field: type choices: {} + field: type types: CRONTAB: crontab INTERVAL: integer @@ -11967,22 +11967,22 @@ definitions: type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: fk_autocomplete MODULE: fk_autocomplete + PLAYBOOK: fk_autocomplete TEMPLATE: hidden inventory: title: Inventory type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: fk_autocomplete MODULE: fk_autocomplete + PLAYBOOK: fk_autocomplete TEMPLATE: hidden save_result: title: Save result @@ -11996,11 +11996,11 @@ definitions: type: string format: dynamic additionalProperties: - field: kind choices: {} + field: kind types: - PLAYBOOK: hidden MODULE: hidden + PLAYBOOK: hidden TEMPLATE: autocomplete enabled: title: Enabled @@ -12017,8 +12017,8 @@ definitions: type: string format: dynamic additionalProperties: - field: type choices: {} + field: type types: CRONTAB: crontab INTERVAL: integer @@ -12182,20 +12182,20 @@ definitions: type: string format: dynamic additionalProperties: - field: key choices: + repo_sync_on_run: + - true + - false repo_type: - MANUAL - GIT - TAR - repo_sync_on_run: - - true - - false + field: key types: - repo_password: password + ci_template: fk repo_key: secretfile + repo_password: password repo_sync_on_run_timeout: uptime - ci_template: fk Team: required: - name diff --git a/polemarch/__init__.py b/polemarch/__init__.py index c6b30fb0..cc1a699e 100644 --- a/polemarch/__init__.py +++ b/polemarch/__init__.py @@ -31,6 +31,6 @@ "VST_ROOT_URLCONF": os.getenv("VST_ROOT_URLCONF", 'vstutils.urls'), } -__version__ = "1.5.1" +__version__ = "1.5.2" prepare_environment(**default_settings) diff --git a/polemarch/main/models/__init__.py b/polemarch/main/models/__init__.py index 47670ee7..0da73504 100644 --- a/polemarch/main/models/__init__.py +++ b/polemarch/main/models/__init__.py @@ -17,7 +17,7 @@ from .vars import Variable from .hosts import Host, Group, Inventory from .projects import Project, Task, Module, ProjectTemplate, list_to_choices -from .users import BaseUser, UserGroup, ACLPermission, UserSettings +from .users import get_user_model, UserGroup, ACLPermission, UserSettings from .tasks import PeriodicTask, History, HistoryLines, Template from .hooks import Hook from ..validators import RegexValidator, validate_hostname @@ -26,6 +26,7 @@ logger = logging.getLogger('polemarch') +BaseUser = get_user_model() ##################################### diff --git a/polemarch/main/models/base.py b/polemarch/main/models/base.py index 5f258ef4..5bdfa793 100644 --- a/polemarch/main/models/base.py +++ b/polemarch/main/models/base.py @@ -3,14 +3,14 @@ from typing import Callable, Any from django.db import models from django.conf import settings -from django.contrib.auth.models import User as BaseUser +from django.contrib.auth import get_user_model from django.utils.module_loading import import_string from vstutils.utils import classproperty from vstutils.models import BQuerySet as _BQSet, BaseModel as _BM, Manager as _BManager def first_staff_user() -> int: - return BaseUser.objects.filter(is_staff=True).first().id + return get_user_model().objects.filter(is_staff=True).first().id class BQuerySet(_BQSet): diff --git a/polemarch/main/models/tasks.py b/polemarch/main/models/tasks.py index f8fbc497..87557686 100644 --- a/polemarch/main/models/tasks.py +++ b/polemarch/main/models/tasks.py @@ -14,7 +14,7 @@ from django.db import transaction from django.db.models import Q from django.utils import timezone -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.db.models import functions as dbfunc, Count from django.utils.timezone import now from django.test import Client @@ -30,6 +30,7 @@ logger = logging.getLogger("polemarch") InvOrString = TypeVar('InvOrString', str, int, Inventory, None) +User = get_user_model() # Block of real models diff --git a/polemarch/main/models/users.py b/polemarch/main/models/users.py index d490dafc..a2dc0879 100644 --- a/polemarch/main/models/users.py +++ b/polemarch/main/models/users.py @@ -5,7 +5,6 @@ import json from django.contrib.auth.models import Group as BaseGroup -from django.contrib.auth.models import User as BaseUser from django.contrib.auth import get_user_model from .base import models, BModel, ACLModel, BQuerySet @@ -50,7 +49,7 @@ class UserGroup(BaseGroup, ACLModel): class UserSettings(BModel): settings = models.TextField(default="{}") - user = models.OneToOneField(BaseUser, on_delete=models.CASCADE, + user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE, related_query_name="settings", related_name="settings") diff --git a/polemarch/main/models/vars.py b/polemarch/main/models/vars.py index bf498897..8f9388f2 100644 --- a/polemarch/main/models/vars.py +++ b/polemarch/main/models/vars.py @@ -110,6 +110,7 @@ class Meta: 'ansible_ssh_pass', 'ansible_ssh_private_key_file', 'ansible_become_pass', + 'ansible_become_password', 'ansible_password' ] diff --git a/polemarch/main/tests/api.py b/polemarch/main/tests/api.py index 4c102f1b..875cfcab 100644 --- a/polemarch/main/tests/api.py +++ b/polemarch/main/tests/api.py @@ -3,12 +3,7 @@ from django.test import Client from django.contrib.auth.hashers import make_password from django.utils.timezone import now - -try: - from mock import patch -except ImportError: # nocv - from unittest.mock import patch - +from unittest.mock import patch from vstutils.utils import redirect_stdany from ._base import BaseTestCase, json from .hosts import InventoriesTestCase, InvBaseTestCase # noqa: F401 diff --git a/polemarch/main/tests/openapi.py b/polemarch/main/tests/openapi.py index b1810bd6..c8a5cd54 100644 --- a/polemarch/main/tests/openapi.py +++ b/polemarch/main/tests/openapi.py @@ -4,7 +4,9 @@ from ._base import BaseTestCase -openapi_schema_yaml = Path(__file__).parent.parent.parent.parent / 'doc' / 'api_schema.yaml' +openapi_schema_yaml = Path.cwd().parent.parent / 'doc' / 'api_schema.yaml' +if not openapi_schema_yaml.exists(): + openapi_schema_yaml = Path(__file__).parent.parent.parent.parent / 'doc' / 'api_schema.yaml' class OApiTestCase(BaseTestCase): diff --git a/tox.ini b/tox.ini index 5dd9e99e..4ff9fde4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27,35,36,37}-{django111}-{coverage,install},flake,pylint +envlist = py{35,36,37}-{coverage,install},flake,pylint skipsdist = True setenv = PIP_CONFIG_FILE=.pip.conf whitelist_externals = @@ -34,7 +34,6 @@ commands = deps = coverage: -rrequirements.txt install: cython>=0.29.2 - py27-install: multiprocessing -rrequirements-doc.txt -rrequirements-git.txt -rrequirements-test.txt