Repository: netbox-community/netbox

Issue:
Add existing fields to the Rack Reservation user interface pages
### NetBox version

v3.2.4

### Feature type

Change to existing functionality

### Proposed functionality

Proposing to add already existent fields to the Rack Reservation create/edit/list user interface pages.

1. Add the **Site Group** field to the Rack Reservation **add** and **edit** pages to filter the **Site** input.
![image](https://user-images.githubusercontent.com/52260120/176745821-87899598-5e02-45b8-8ffe-e76c310970f5.png)
![image](https://user-images.githubusercontent.com/52260120/176747807-a2209e4f-0e8f-45f4-adb3-7c129b5eff34.png)
2. Add the **Location** field as a column option for the Rack Reservation **list** page.
![image](https://user-images.githubusercontent.com/52260120/176746655-aa17532a-7c1f-40e9-8ba2-521d4ffa3963.png)
3. Change the **Rack** section name in the **filter** tab for the Rack Reservation **list** page to **Location**.
![image](https://user-images.githubusercontent.com/52260120/176749017-cef9d884-fc2f-451e-9839-16410e856a57.png)

**Site group** and **Location** are already options as filters in the Rack Reservation list page.


### Use case

The proposed changes would better align the user interface for the RackReservation model to other similar model pages (Rack) and provide additional filtering options.

### Database changes

_No response_

### External dependencies

_No response_


Discussion:
Item number 2 (add Location field) looks like it can be accomplished by updating the RackReservationTable class in [netbox/dcim/tables/racks.py](https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/tables/racks.py)

```
class RackReservationTable(NetBoxTable):
    reservation = tables.Column(
        accessor='pk',
        linkify=True
    )
    site = tables.Column(
        accessor=Accessor('rack__site'),
        linkify=True
    )
    location = tables.Column(
        accessor=Accessor('rack__location'),
        linkify=True
    )
    tenant = TenantColumn()
    rack = tables.Column(
        linkify=True
    )
    unit_list = tables.Column(
        orderable=False,
        verbose_name='Units'
    )
    tags = columns.TagColumn(
        url_name='dcim:rackreservation_list'
    )

    class Meta(NetBoxTable.Meta):
        model = RackReservation
        fields = (
            'pk', 'id', 'reservation', 'site', 'location', 'rack', 'unit_list', 'user', 'created', 'tenant', 'description', 'tags',
            'actions', 'created', 'last_updated',
        )
        default_columns = ('pk', 'reservation', 'site', 'rack', 'unit_list', 'user', 'description')
```

This seems to work.

Item number 3 (change Rack to Location in the filter page) looks like it can be accomplished by updating the RackReservationFilterForm class in [netbox/dcim/forms/filtersets.py](https://github.com/netbox-community/netbox/blob/a52c68f4c2dffb6ea263711d37a997b082ece055/netbox/dcim/forms/filtersets.py)

```
class RackReservationFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
    model = RackReservation
    fieldsets = (
        (None, ('q', 'tag')),
        ('User', ('user_id',)),
        ('Location', ('region_id', 'site_group_id', 'site_id', 'location_id')),
        ('Tenant', ('tenant_group_id', 'tenant_id')),
    )
...
```
Item number 1 (add Site Group field) looks like it can be accomplished by adding site_group to the fieldsets property in the RackReservationForm class in [netbox/dcim/forms/models.py](https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/forms/models.py)

```
...
    fieldsets = (
        ('Reservation', ('region', 'site_group', 'site', 'location', 'rack', 'units', 'user', 'description', 'tags')),
        ('Tenancy', ('tenant_group', 'tenant')),
    )
...
```

Resolving patch:
diff --git a/netbox/dcim/forms/filtersets.py b/netbox/dcim/forms/filtersets.py
--- a/netbox/dcim/forms/filtersets.py
+++ b/netbox/dcim/forms/filtersets.py
@@ -287,7 +287,7 @@ class RackReservationFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
     fieldsets = (
         (None, ('q', 'tag')),
         ('User', ('user_id',)),
-        ('Rack', ('region_id', 'site_group_id', 'site_id', 'location_id')),
+        ('Location', ('region_id', 'site_group_id', 'site_id', 'location_id')),
         ('Tenant', ('tenant_group_id', 'tenant_id')),
     )
     region_id = DynamicModelMultipleChoiceField(
diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py
--- a/netbox/dcim/forms/models.py
+++ b/netbox/dcim/forms/models.py
@@ -321,7 +321,7 @@ class RackReservationForm(TenancyForm, NetBoxModelForm):
     )
 
     fieldsets = (
-        ('Reservation', ('region', 'site', 'location', 'rack', 'units', 'user', 'description', 'tags')),
+        ('Reservation', ('region', 'site_group', 'site', 'location', 'rack', 'units', 'user', 'description', 'tags')),
         ('Tenancy', ('tenant_group', 'tenant')),
     )
 
diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py
--- a/netbox/dcim/tables/racks.py
+++ b/netbox/dcim/tables/racks.py
@@ -109,6 +109,10 @@ class RackReservationTable(TenancyColumnsMixin, NetBoxTable):
         accessor=Accessor('rack__site'),
         linkify=True
     )
+    location = tables.Column(
+        accessor=Accessor('rack__location'),
+        linkify=True
+    )
     rack = tables.Column(
         linkify=True
     )
@@ -123,7 +127,7 @@ class RackReservationTable(TenancyColumnsMixin, NetBoxTable):
     class Meta(NetBoxTable.Meta):
         model = RackReservation
         fields = (
-            'pk', 'id', 'reservation', 'site', 'rack', 'unit_list', 'user', 'created', 'tenant', 'tenant_group', 'description', 'tags',
+            'pk', 'id', 'reservation', 'site', 'location', 'rack', 'unit_list', 'user', 'created', 'tenant', 'tenant_group', 'description', 'tags',
             'actions', 'created', 'last_updated',
         )
         default_columns = ('pk', 'reservation', 'site', 'rack', 'unit_list', 'user', 'description')


Test patch: