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

NN API Route #90

Merged
merged 33 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a665053
First stab at NN API route
WillNilges Dec 10, 2023
f29c48a
Add more tests
WillNilges Dec 10, 2023
8ef1d1d
Add more robust test
WillNilges Dec 10, 2023
ea42376
Andy comments 1/n
WillNilges Dec 20, 2023
f2afed1
Refactor to NetworkNumberAssignment
WillNilges Dec 22, 2023
1b52e9d
Hardcode highest network number
WillNilges Dec 22, 2023
998a69f
Remove redundant Request fields
WillNilges Dec 22, 2023
f3154fe
Update Models, remove Request
WillNilges Dec 22, 2023
7a5309a
Swap request for install
WillNilges Dec 22, 2023
9861ee2
Update status and find an install number
WillNilges Dec 22, 2023
8cc7cc5
Make tests work again
WillNilges Dec 22, 2023
d1230ef
Add member moved test
WillNilges Dec 22, 2023
9a46539
Update NN route
WillNilges Dec 22, 2023
3cd2449
Update join form and nn form
WillNilges Dec 23, 2023
7920112
andrew updates 1
WillNilges Dec 23, 2023
90242f3
Andrew changes 2
WillNilges Dec 23, 2023
22c39c4
ugh
WillNilges Dec 23, 2023
ff46c6f
blargh
WillNilges Dec 23, 2023
f254ce5
I hate computers
WillNilges Dec 23, 2023
0e014b6
Tests pass
WillNilges Dec 24, 2023
ce85c56
fuck
WillNilges Dec 24, 2023
782e81d
make big test work
WillNilges Dec 24, 2023
ed45273
Update member object creation
WillNilges Dec 24, 2023
85aaa82
datetime
WillNilges Dec 24, 2023
360be60
squash part 1
WillNilges Dec 24, 2023
4dc0540
nuke migrations
WillNilges Dec 24, 2023
b1acc3a
nuke migrations II electic boogalooo
WillNilges Dec 24, 2023
8e97acc
timezone
WillNilges Dec 24, 2023
cedc588
black
WillNilges Dec 24, 2023
eb72341
Bring back referral field
WillNilges Dec 24, 2023
eb0ef31
andrew comments 4
WillNilges Dec 24, 2023
962a95a
migrations
WillNilges Dec 24, 2023
6573316
make tests pass
WillNilges Dec 24, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.5 on 2023-12-23 03:01

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("meshapi", "0017_building_node_name_building_secondary_nn_and_more"),
]

operations = [
migrations.RenameField(
model_name="building",
old_name="network_number",
new_name="primary_nn",
),
migrations.RemoveField(
model_name="building",
name="secondary_nn",
),
migrations.RemoveField(
model_name="install",
name="id",
),
migrations.RemoveField(
model_name="install",
name="referral",
),
migrations.AddField(
model_name="install",
name="network_number",
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name="install",
name="install_number",
field=models.IntegerField(primary_key=True, serialize=False),
),
]
17 changes: 17 additions & 0 deletions src/meshapi/migrations/0019_alter_install_install_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-12-23 03:19

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("meshapi", "0018_rename_network_number_building_primary_nn_and_more"),
]

operations = [
migrations.AlterField(
model_name="install",
name="install_number",
field=models.AutoField(db_column="install_number", primary_key=True, serialize=False),
),
]
26 changes: 26 additions & 0 deletions src/meshapi/migrations/0020_alter_install_install_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.5 on 2023-12-23 03:25

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


class Migration(migrations.Migration):
dependencies = [
("meshapi", "0019_alter_install_install_number"),
]

operations = [
migrations.AlterField(
model_name="install",
name="install_number",
field=models.AutoField(
db_column="install_number",
primary_key=True,
serialize=False,
validators=[
django.core.validators.MinValueValidator(101),
django.core.validators.MaxValueValidator(8192),
],
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.5 on 2023-12-23 03:37

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


class Migration(migrations.Migration):
dependencies = [
("meshapi", "0020_alter_install_install_number"),
]

operations = [
migrations.AlterField(
model_name="install",
name="install_number",
field=models.AutoField(db_column="install_number", primary_key=True, serialize=False),
Andrew-Dickinson marked this conversation as resolved.
Show resolved Hide resolved
),
migrations.AlterField(
model_name="install",
name="network_number",
field=models.IntegerField(
blank=True,
null=True,
validators=[
django.core.validators.MinValueValidator(101),
django.core.validators.MaxValueValidator(8192),
],
),
),
]
27 changes: 18 additions & 9 deletions src/meshapi/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.contrib.postgres.fields import ArrayField

from django.contrib.auth.models import Group
from django.db.models.aggregates import IntegerField
from django.db.models.fields import EmailField

NETWORK_NUMBER_MAX = 8000
NETWORK_NUMBER_MIN = 101
NETWORK_NUMBER_MAX = 8192


class Installer(Group):
Expand All @@ -29,8 +30,7 @@ class BuildingStatus(models.IntegerChoices):
latitude = models.FloatField()
longitude = models.FloatField()
altitude = models.FloatField()
network_number = models.IntegerField(blank=True, null=True)
secondary_nn = ArrayField(IntegerField(blank=True, null=True), null=True)
primary_nn = models.IntegerField(blank=True, null=True)
node_name = models.TextField(default=None, blank=True, null=True)
install_date = models.DateField(default=None, blank=True, null=True)
abandon_date = models.DateField(default=None, blank=True, null=True)
Expand All @@ -54,12 +54,23 @@ class InstallStatus(models.IntegerChoices):
INACTIVE = 4
CLOSED = 5

# Install Number (generated when form is submitted)
install_number = models.AutoField(
primary_key=True,
db_column="install_number",
)

# The NN this install is associated with.
# Through this, a building can have multiple NNs
network_number = models.IntegerField(
blank=True,
null=True,
validators=[MinValueValidator(NETWORK_NUMBER_MIN), MaxValueValidator(NETWORK_NUMBER_MAX)],
)

# Summary status of install
install_status = models.IntegerField(choices=InstallStatus.choices)

# Install Number (generated when form is submitted)
install_number = models.IntegerField()

# OSTicket ID
ticket_id = models.IntegerField(blank=True, null=True)

Expand All @@ -75,6 +86,4 @@ class InstallStatus(models.IntegerChoices):

# Relation to Member
member_id = models.ForeignKey(Member, on_delete=models.PROTECT)
referral = models.TextField(default=None, blank=True, null=True)

notes = models.TextField(default=None, blank=True, null=True)
7 changes: 3 additions & 4 deletions src/meshapi/tests/sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"network_number": 9001,
"primary_nn": 2000,
"install_date": "2222-02-02",
"abandon_date": "",
}

sample_install = {
"network_number": 2000,
"install_status": Install.InstallStatus.ACTIVE,
"install_number": 420,
"ticket_id": 69,
"request_date": "2022-02-27",
"install_date": "2022-03-01",
Expand All @@ -34,6 +34,5 @@
"unit": 3,
"roof_access": True,
"member_id": 1,
"referral": "Read about it on the internet",
"notes": "",
"notes": "Referral: Read about it on the internet",
}
4 changes: 2 additions & 2 deletions src/meshapi/tests/test_join_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def validate_successful_join_form_submission(test_case, test_name, s, response):
)

# Check that a install was created
install_id = json.loads(response.content.decode("utf-8"))["install_id"]
join_form_installs = Install.objects.filter(pk=install_id)
install_number = json.loads(response.content.decode("utf-8"))["install_number"]
join_form_installs = Install.objects.filter(pk=install_number)

length = 1
test_case.assertEqual(
Expand Down
Loading