Skip to content

Commit

Permalink
feat(access): History Model for Organization added
Browse files Browse the repository at this point in the history
ref: #605 #607
  • Loading branch information
jon-nfc committed Feb 19, 2025
1 parent 61207c5 commit b2f1fba
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
43 changes: 43 additions & 0 deletions app/access/migrations/0004_organizationhistory_teamhistory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 5.1.5 on 2025-02-19 13:32

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0003_alter_team_organization_organizationnotes_teamnotes'),
('core', '0018_ticketcommentcategoryhistory'),
]

operations = [
migrations.CreateModel(
name='OrganizationHistory',
fields=[
('modelhistory_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelhistory')),
('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='history', to='access.organization', verbose_name='Model')),
],
options={
'verbose_name': 'Organization History',
'verbose_name_plural': 'Organization History',
'db_table': 'access_organization_history',
'ordering': ['-created'],
},
bases=('core.modelhistory',),
),
migrations.CreateModel(
name='TeamHistory',
fields=[
('modelhistory_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelhistory')),
('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='history', to='access.team', verbose_name='Model')),
],
options={
'verbose_name': 'Team History',
'verbose_name_plural': 'Team History',
'db_table': 'access_team_history',
'ordering': ['-created'],
},
bases=('core.modelhistory',),
),
]
53 changes: 53 additions & 0 deletions app/access/models/organization_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django.db import models

from core.models.model_history import ModelHistory

from access.models.organization import Organization



class OrganizationHistory(
ModelHistory
):


class Meta:

db_table = 'access_organization_history'

ordering = ModelHistory._meta.ordering

verbose_name = 'Organization History'

verbose_name_plural = 'Organization History'


model = models.ForeignKey(
Organization,
blank = False,
help_text = 'Model this note belongs to',
null = False,
on_delete = models.CASCADE,
related_name = 'history',
verbose_name = 'Model',
)

table_fields: list = []

page_layout: dict = []


def get_object(self):

return self


def get_serialized_model(self, serializer_context):

model = None

from access.serializers.organization import OrganizationBaseSerializer

model = OrganizationBaseSerializer(self.model, context = serializer_context)

return model
2 changes: 2 additions & 0 deletions app/access/viewsets/organization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiResponse

# THis import only exists so that the migrations can be created
from access.models.organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
from access.serializers.organization import (
Organization,
OrganizationModelSerializer,
Expand Down

0 comments on commit b2f1fba

Please sign in to comment.