Skip to content

Commit

Permalink
Support 202311 (#95)
Browse files Browse the repository at this point in the history
* Clarifying the Network Type field #1357

Only indicate availability of DC voltage for facilities #1341

changelog

linting

* fix migrations hierarchy

* Modernize (#96)

* update deps, run pre-commit

* add py38 back, adjust tox

---------

Co-authored-by: 20C <[email protected]>
Co-authored-by: Matt Griswold <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2024
1 parent 3c1dffa commit 118d41f
Show file tree
Hide file tree
Showing 20 changed files with 663 additions and 635 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
- name: Run linters
Expand All @@ -22,11 +22,11 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
with:
Expand Down
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ exclude: |
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: system
Expand All @@ -20,7 +29,7 @@ repos:
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py36-plus
entry: poetry run pyupgrade --py38-plus
language: python
types: [python]
pass_filenames: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


## Unreleased
### Added
- added `info_types` field to `Network` to support multi choice type selection
### Changed
- changed `available_voltage_services` in `Facility` to allow 48 VDC, 400 VAC and 480 VAC


## 3.2.0
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Unreleased:
added: []
added:
- added `info_types` field to `Network` to support multi choice type selection
fixed: []
changed: []
changed:
- changed `available_voltage_services` in `Facility` to allow 48 VDC, 400 VAC and 480 VAC
deprecated: []
removed: []
security: []
Expand Down
1,109 changes: 534 additions & 575 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ packages = [{ include = "django_peeringdb", from = "src" }]
[tool.poetry.dependencies]
python = "^3.8"
django_countries = ">1"
django_handleref = "^2"
django_inet = "^1"
asgiref = "^3"
django_handleref = ">=2"
django_inet = ">=1"
asgiref = ">=3"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
# testing
codecov = ">=2"
coverage = ">=5"
Expand All @@ -41,29 +41,29 @@ pytest-cov = "*"
tox = ">=3.24"

# linting
# bandit = ">=1.6.2"
black = ">=20"
isort = ">=5.7"
flake8 = ">=3.8"
mypy = ">=0.950"
pre-commit = ">=2.13"
pyupgrade = ">=2.19"
ruff = "^0.1.11"

# docs
markdown = "*"
markdown-include = ">=0.5,<1"
mkdocs = "^1.2.3"
mkdocs = ">=1.2.3"

# ctl
ctl = ">=1"
jinja2 = ">=2"
tmpl = ">=1"
# v4 released 2022-03-31
twine = "^3.3.0"
twine = ">=3.3"

[tool.poetry.plugins."markdown.extensions"]
pymdgen = "pymdgen.md:Extension"


[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Expand Down
16 changes: 10 additions & 6 deletions src/django_peeringdb/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@
("100+Tbps", _("100+Tbps")),
)

NET_TYPES = (
("", _("Not Disclosed")),
("Not Disclosed", _("Not Disclosed")),

_NET_TYPES = (
("NSP", _("NSP")),
("Content", _("Content")),
("Cable/DSL/ISP", _("Cable/DSL/ISP")),
Expand All @@ -114,6 +113,13 @@
("Government", _("Government")),
)

NET_TYPES = (
("", _("Not Disclosed")),
("Not Disclosed", _("Not Disclosed")),
) + _NET_TYPES

NET_TYPES_MULTI_CHOICE = _NET_TYPES

VISIBILITY = (
("Private", _("Private")),
# ('Peers', _('Peers')),
Expand Down Expand Up @@ -164,9 +170,7 @@

AVAILABLE_VOLTAGE = (
("48 VDC", _("48 VDC")),
("120 VAC", _("120 VAC")),
("208 VAC", _("208 VAC")),
("240 VAC", _("240 VAC")),
("400 VAC", _("400 VAC")),
("480 VAC", _("480 VAC")),
)

Expand Down
7 changes: 1 addition & 6 deletions src/django_peeringdb/migrations/0007_add_verbose_names.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Generated by Django 2.2.12 on 2020-05-01 16:17

import django.db.models.deletion
import django_countries.fields
import django_inet.models
from django.db import migrations, models

import django_peeringdb.models.abstract
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
5 changes: 0 additions & 5 deletions src/django_peeringdb/migrations/0010_ix_ixf_fields.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Generated by Django 2.2.12 on 2020-07-10 13:33

import django.db.models.deletion
import django_countries.fields
import django_inet.models
from django.db import migrations, models

import django_peeringdb.models.abstract


class Migration(migrations.Migration):
dependencies = [
Expand Down
5 changes: 0 additions & 5 deletions src/django_peeringdb/migrations/0011_ixlan_ixf_fields.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Generated by Django 2.2.12 on 2020-07-13 07:00

import django.db.models.deletion
import django_countries.fields
import django_inet.models
from django.db import migrations, models

import django_peeringdb.models.abstract


class Migration(migrations.Migration):
dependencies = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Generated by Django 3.1.2 on 2020-10-06 17:37

import django.db.models.deletion
import django_countries.fields
import django_inet.models
from django.db import migrations, models

import django_peeringdb.models.abstract


class Migration(migrations.Migration):
dependencies = [
Expand Down
4 changes: 0 additions & 4 deletions src/django_peeringdb/migrations/0017_facility_fields.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Generated by Django 3.2.7 on 2021-09-07 13:34

import django.core.validators
import django.db.models.deletion
import django_countries.fields
import django_inet.models
from django.db import migrations, models

import django_peeringdb.fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated by Django 3.2.7 on 2021-09-21 15:50

import django.core.validators
import django_inet.models
from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated by Django 3.2.7 on 2021-10-02 00:54

import django.core.validators
import django_inet.models
from django.db import migrations, models


Expand Down
4 changes: 1 addition & 3 deletions src/django_peeringdb/migrations/0020_status_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generated by Django 3.2.9 on 2022-02-02 13:59

import django.core.validators
import django_inet.models
from django.db import migrations, models
from django.db import migrations

import django_peeringdb.models.abstract

Expand Down
35 changes: 35 additions & 0 deletions src/django_peeringdb/migrations/0028_auto_20240109_1157.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.2.7 on 2024-01-09 11:57

from django.db import migrations

import django_peeringdb.fields


class Migration(migrations.Migration):
dependencies = [
("django_peeringdb", "0027_auto_20230804_1414"),
]

operations = [
migrations.AddField(
model_name="network",
name="info_types",
field=django_peeringdb.fields.MultipleChoiceField(
blank=True,
choices=[
("NSP", "NSP"),
("Content", "Content"),
("Cable/DSL/ISP", "Cable/DSL/ISP"),
("Enterprise", "Enterprise"),
("Educational/Research", "Educational/Research"),
("Non-Profit", "Non-Profit"),
("Route Server", "Route Server"),
("Network Services", "Network Services"),
("Route Collector", "Route Collector"),
("Government", "Government"),
],
max_length=255,
verbose_name="Network Types",
),
),
]
30 changes: 30 additions & 0 deletions src/django_peeringdb/migrations/0029_auto_20240109_1246.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.7 on 2024-01-09 12:46

from django.db import migrations

import django_peeringdb.fields


class Migration(migrations.Migration):
dependencies = [
("django_peeringdb", "0028_auto_20240109_1157"),
]

operations = [
migrations.AlterField(
model_name="facility",
name="available_voltage_services",
field=django_peeringdb.fields.MultipleChoiceField(
blank=True,
choices=[
("48 VDC", "48 VDC"),
("400 VAC", "400 VAC"),
("480 VAC", "480 VAC"),
],
help_text="The alternating current voltage available to users of the facility either directly from the landlord or delivered by the utility separately.",
max_length=255,
null=True,
verbose_name="Available Voltage Services",
),
),
]
11 changes: 6 additions & 5 deletions src/django_peeringdb/models/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,14 @@ class NetworkBase(HandleRefModel):
choices=const.SCOPES,
default="Not Disclosed",
)
info_type = models.CharField(
_("Network Type"),
max_length=60,

info_types = MultipleChoiceField(
_("Network Types"),
blank=True,
choices=const.NET_TYPES,
default="Not Disclosed",
max_length=255,
choices=const.NET_TYPES_MULTI_CHOICE,
)

info_prefixes4 = models.PositiveIntegerField(
_("IPv4 Prefixes"),
null=True,
Expand Down
12 changes: 12 additions & 0 deletions src/django_peeringdb/models/concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from django_peeringdb import const
from django_peeringdb.models import (
CampusBase,
CarrierBase,
Expand Down Expand Up @@ -80,6 +81,17 @@ class Network(NetworkBase):
on_delete=models.CASCADE,
)

# keep legacy info type field on the concrete
# models so its still queryable and syncable via
# peeringdb-py
info_type = models.CharField(
_("Network Type"),
max_length=60,
blank=True,
choices=const.NET_TYPES,
default="Not Disclosed",
)


@expose_model
class InternetExchange(InternetExchangeBase):
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
envlist =
py{38,39,310,311}-django{31,32,40,42}
py312-django{40,42}
isolated_build = True

[gh-actions]
Expand All @@ -9,11 +10,12 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[testenv]
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
deps =
django31: Django>=3.1,<3.2
django32: Django>=3.2,<3.3
Expand Down

0 comments on commit 118d41f

Please sign in to comment.