Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #30

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions dns/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ def _rev_to_ip(self, name):

class Meta:
model = Record
exclude = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a security warning against this approach:

https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#selecting-the-fields-to-use

1 change: 1 addition & 0 deletions hamwanadmin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'portal.context_processors.encrypted44',
)

TEST_RUNNER = 'django.test.runner.DiscoverRunner'

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
Expand Down
2 changes: 2 additions & 0 deletions portal/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def clean_name(self):
class IPAddressForm(forms.ModelForm):
class Meta:
model = IPAddress
exclude = []


class UserIPAddressForm(IPAddressForm):
Expand Down Expand Up @@ -76,6 +77,7 @@ def clean(self):
class SubnetForm(forms.ModelForm):
class Meta:
model = Subnet
exclude = []


class UserSubnetForm(SubnetForm):
Expand Down
6 changes: 3 additions & 3 deletions portal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions portal/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down