diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index af94e09..bcc78d2 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -18,7 +18,6 @@ jobs: steps: - uses: actions/checkout@v2 - name: Build Container Image - run: docker build --build-arg PYTHON_VERSION=${{ matrix.python-version }} -t hamwan-portal . + run: make docker PYTHON_VERSION=${{ matrix.python-version }} - name: Run Tests - run: | - docker run --rm hamwan-portal manage.py test + run: make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2f459e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +IMAGE := hamwan-portal +PYTHON_VERSION ?= 2.7 +DOCKER_RUNNER := docker run --rm -v $(shell pwd):/app $(IMAGE) + +docker: + docker build --build-arg PYTHON_VERSION=$(PYTHON_VERSION) -t $(IMAGE) . + +test: + $(DOCKER_RUNNER) manage.py test -v3 diff --git a/dns/forms.py b/dns/forms.py index b258a2e..e2b5578 100644 --- a/dns/forms.py +++ b/dns/forms.py @@ -58,3 +58,4 @@ def _rev_to_ip(self, name): class Meta: model = Record + exclude = [] diff --git a/hamwanadmin/settings.py b/hamwanadmin/settings.py index efed9c4..522a4bf 100644 --- a/hamwanadmin/settings.py +++ b/hamwanadmin/settings.py @@ -97,6 +97,7 @@ 'portal.context_processors.encrypted44', ) +TEST_RUNNER = 'django.test.runner.DiscoverRunner' MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', diff --git a/portal/forms.py b/portal/forms.py index ad54c18..547ac88 100644 --- a/portal/forms.py +++ b/portal/forms.py @@ -43,6 +43,7 @@ def clean_name(self): class IPAddressForm(forms.ModelForm): class Meta: model = IPAddress + exclude = [] class UserIPAddressForm(IPAddressForm): @@ -76,6 +77,7 @@ def clean(self): class SubnetForm(forms.ModelForm): class Meta: model = Subnet + exclude = [] class UserSubnetForm(SubnetForm): diff --git a/portal/models.py b/portal/models.py index 4f11ccf..59692cf 100644 --- a/portal/models.py +++ b/portal/models.py @@ -51,14 +51,14 @@ ) class DomainSortManager(models.Manager): - def get_query_set(self): + def get_queryset(self): if DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql_psycopg2': - return super(DomainSortManager, self).get_query_set().extra( + return super(DomainSortManager, self).get_queryset().extra( select={'domain_order': "array_reverse(regexp_split_to_array(name, '\.'))"}, order_by=['owner__username', 'domain_order']) else: - return super(DomainSortManager, self).get_query_set() + return super(DomainSortManager, self).get_queryset() class Site(models.Model): diff --git a/portal/network.py b/portal/network.py index 7a35f6d..b9456f0 100644 --- a/portal/network.py +++ b/portal/network.py @@ -30,14 +30,14 @@ def __init__(self, qs_class=models.query.QuerySet): self.queryset_class = qs_class super(IPNetworkManager, self).__init__() - def get_query_set(self): + def get_queryset(self): return self.queryset_class(self.model) def __getattr__(self, attr, *args): try: return getattr(self.__class__, attr, *args) except AttributeError: - return getattr(self.get_query_set(), attr, *args) + return getattr(self.get_queryset(), attr, *args) class IPNetworkQuerySet(models.query.QuerySet):