forked from tbotnz/netbox_floorplan
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from netbox-community/0.5.0
Reinstate image upload
- Loading branch information
Showing
31 changed files
with
624 additions
and
31,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 140 | ||
ignore = E126, E722 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
from netbox.plugins import PluginConfig | ||
from .version import __version__ | ||
|
||
|
||
class FloorplanConfig(PluginConfig): | ||
|
||
name = "netbox_floorplan" | ||
verbose_name = "Netbox Floorplan" | ||
description = "" | ||
version = "0.4.1" | ||
version = __version__ | ||
base_url = "floorplan" | ||
min_version = "4.0.2" | ||
max_version = "4.0.11" | ||
min_version = "4.1.0" | ||
max_version = "4.1.99" | ||
|
||
|
||
config = FloorplanConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib import admin | ||
from .models import Floorplan | ||
|
||
|
||
@admin.register(Floorplan) | ||
class FloorplanAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"pk", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
from rest_framework import serializers | ||
from netbox.api.serializers import NetBoxModelSerializer | ||
from ..models import Floorplan | ||
from ..models import Floorplan, FloorplanImage | ||
|
||
|
||
class FloorplanImageSerializer(NetBoxModelSerializer): | ||
url = serializers.HyperlinkedIdentityField( | ||
view_name='plugins-api:netbox_floorplan-api:floorplanimage-detail') | ||
|
||
class Meta: | ||
model = FloorplanImage | ||
fields = ['id', 'url', 'name', 'file', 'external_url', 'filename', 'comments', 'tags', 'custom_fields', 'created', 'last_updated'] | ||
brief_fields = ['id', 'url', 'name', 'file', 'filename', 'external_url'] | ||
|
||
|
||
class FloorplanSerializer(NetBoxModelSerializer): | ||
url = serializers.HyperlinkedIdentityField( | ||
view_name='plugins-api:netbox_floorplan-api:floorplan-detail') | ||
assigned_image = FloorplanImageSerializer(nested=True, required=False, allow_null=True) | ||
|
||
class Meta: | ||
model = Floorplan | ||
fields = ['id', 'url', 'site', 'location', 'background_image', | ||
fields = ['id', 'url', 'site', 'location', 'assigned_image', | ||
'width', 'height', 'tags', 'custom_fields', 'created', | ||
'last_updated', 'canvas', 'measurement_unit'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from netbox.api.viewsets import NetBoxModelViewSet | ||
|
||
from .. import filtersets, models | ||
from .serializers import FloorplanSerializer | ||
from .serializers import FloorplanSerializer, FloorplanImageSerializer | ||
|
||
|
||
class FloorplanViewSet(NetBoxModelViewSet): | ||
queryset = models.Floorplan.objects.all() | ||
serializer_class = FloorplanSerializer | ||
filterset_class = filtersets.FloorplanFilterSet | ||
|
||
|
||
class FloorplanImageViewSet(NetBoxModelViewSet): | ||
queryset = models.FloorplanImage.objects.prefetch_related('tags') | ||
serializer_class = FloorplanImageSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 5.0.7 on 2024-07-19 23:49 | ||
|
||
import taggit.managers | ||
import utilities.json | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('extras', '0115_convert_dashboard_widgets'), | ||
('netbox_floorplan', '0007_alter_floorplan_options_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='FloorplanImage', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)), | ||
('created', models.DateTimeField(auto_now_add=True, null=True)), | ||
('last_updated', models.DateTimeField(auto_now=True, null=True)), | ||
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)), | ||
('name', models.CharField(max_length=128)), | ||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')), | ||
], | ||
options={ | ||
'ordering': ('name',), | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 5.0.7 on 2024-07-20 19:02 | ||
|
||
import netbox_floorplan.utils | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_floorplan', '0008_floorplanimage'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='floorplanimage', | ||
name='file', | ||
field=models.FileField(blank=True, upload_to=netbox_floorplan.utils.file_upload), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
netbox_floorplan/migrations/0010_floorplanimage_external_url.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.7 on 2024-07-20 19:57 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_floorplan', '0009_floorplanimage_file'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='floorplanimage', | ||
name='external_url', | ||
field=models.URLField(blank=True, max_length=255), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
netbox_floorplan/migrations/0011_floorplanimage_comments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.7 on 2024-07-20 20:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_floorplan', '0010_floorplanimage_external_url'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='floorplanimage', | ||
name='comments', | ||
field=models.TextField(blank=True), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
netbox_floorplan/migrations/0012_alter_floorplan_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 5.0.7 on 2024-07-20 20:53 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('netbox_floorplan', '0011_floorplanimage_comments'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='floorplan', | ||
options={'ordering': ('site', 'location', 'assigned_image', 'width', 'height', 'measurement_unit')}, | ||
), | ||
migrations.RemoveField( | ||
model_name='floorplan', | ||
name='background_image', | ||
), | ||
migrations.AddField( | ||
model_name='floorplan', | ||
name='assigned_image', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='netbox_floorplan.floorplanimage'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.