Skip to content

Commit 5c6ba74

Browse files
authored
Merge pull request #839 from nofusscomputing/model-inheritance
2 parents 9cf8d32 + bc19a9b commit 5c6ba74

67 files changed

Lines changed: 1779 additions & 871 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/new_model.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,16 @@ Describe in detail the following:
3939

4040
- [ ] 🔗 URL Route Added
4141

42-
- [ ] 🏷️ Model tag added to `app/core/lib/slash_commands/linked_model.CommandLinkedModel.get_model()` function
42+
- [ ] 🏷️ [Model tag]().
4343

4444
- [ ] 📘 Tag updated in the [docs](https://nofusscomputing.com/projects/centurion_erp/user/core/markdown/#model-reference)
45-
- [ ] tag added to `app/core/lib/slash_commands/linked_model.CommandLinkedModel.get_model()`
46-
- [ ] ⚒️ Migration _Ticket Linked Item item_type choices update_
4745

48-
49-
>[!note]
50-
> Ensure that when creating the tag the following is adhered to:
51-
> - Two words are not to contain a space char, `\s`. It is to be replaced with an underscore `_`
52-
> - As much as practical, keep the tag as close to the model name as possible
53-
54-
55-
- [ ] 📓 New [Notes model](https://nofusscomputing.com/projects/centurion_erp/development/core/model_notes/) created
56-
- [ ] 🆕 Model Created
57-
- [ ] 🛠️ Migrations added
58-
- [ ] Add `app_label` to KB Models `app/assistance/models/model_knowledge_base_article.all_models().model_apps`
59-
- [ ] _(Notes not used/required) -_ Add `model_name` to KB Models `app/assistance/models/model_knowledge_base_article.all_models().excluded_models`
60-
- [ ] 🧪 [Unit tested](https://nofusscomputing.com/projects/centurion_erp/development/core/model_notes/#testing)
61-
- [ ] 🧪 [Functional tested](https://nofusscomputing.com/projects/centurion_erp/development/core/model_notes/#testing)
46+
- [ ] tag added to class
6247

6348
- [ ] Admin Documentation added/updated _if applicable_
49+
6450
- [ ] Developer Documentation added/updated _if applicable_
51+
6552
- [ ] User Documentation added/updated
6653

6754
---
@@ -73,14 +60,13 @@ Describe in detail the following:
7360
### 🧪 Tests
7461

7562
- Unit Tests
76-
- [ ] API Render (fields)
7763
- [ ] [Model](https://nofusscomputing.com/projects/centurion_erp/development/models/#tests)
7864
- [ ] ViewSet
65+
- [ ] Serializer
7966
- Function Test
80-
- [ ] History API Render (fields)
81-
- [ ] History Entries
8267
- [ ] API Metadata
8368
- [ ] API Permissions
69+
- [ ] API Render (fields)
8470
- [ ] Model
8571
- [ ] Serializer
8672
- [ ] ViewSet
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.1.9 on 2025-06-17 07:27
2+
from django.db import migrations
3+
4+
5+
class Migration(migrations.Migration):
6+
7+
dependencies = [
8+
("access", "0016_remove_tenant_slug_alter_tenant_manager_and_more"),
9+
("core", "0033_alter_ticketcommentcategory_parent_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.DeleteModel(
14+
name="EntityHistory",
15+
),
16+
migrations.DeleteModel(
17+
name="EntityNotes",
18+
),
19+
]
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
# Generated by Django 5.1.9 on 2025-06-17 07:32
2+
3+
import access.models.tenancy_abstract
4+
import django.db.models.deletion
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
("access", "0017_remove_entitynotes_model_and_more"),
12+
("core", "0033_alter_ticketcommentcategory_parent_and_more"),
13+
]
14+
15+
operations = [
16+
migrations.RemoveField(
17+
model_name="entity",
18+
name="is_global",
19+
),
20+
migrations.AlterField(
21+
model_name="entity",
22+
name="id",
23+
field=models.AutoField(
24+
help_text="ID of the item",
25+
primary_key=True,
26+
serialize=False,
27+
unique=True,
28+
verbose_name="ID",
29+
),
30+
),
31+
migrations.AlterField(
32+
model_name="entity",
33+
name="model_notes",
34+
field=models.TextField(
35+
blank=True,
36+
help_text="Tid bits of information",
37+
null=True,
38+
verbose_name="Notes",
39+
),
40+
),
41+
migrations.AlterField(
42+
model_name="entity",
43+
name="organization",
44+
field=models.ForeignKey(
45+
help_text="Tenant this belongs to",
46+
on_delete=django.db.models.deletion.CASCADE,
47+
related_name="+",
48+
to="access.tenant",
49+
validators=[
50+
access.models.tenancy_abstract.TenancyAbstractModel.validatate_organization_exists
51+
],
52+
verbose_name="Tenant",
53+
),
54+
),
55+
migrations.CreateModel(
56+
name="ContactAuditHistory",
57+
fields=[
58+
(
59+
"centurionaudit_ptr",
60+
models.OneToOneField(
61+
auto_created=True,
62+
on_delete=django.db.models.deletion.CASCADE,
63+
parent_link=True,
64+
primary_key=True,
65+
serialize=False,
66+
to="core.centurionaudit",
67+
),
68+
),
69+
(
70+
"model",
71+
models.ForeignKey(
72+
help_text="Model this history belongs to",
73+
on_delete=django.db.models.deletion.CASCADE,
74+
related_name="+",
75+
to="access.contact",
76+
verbose_name="Model",
77+
),
78+
),
79+
],
80+
options={
81+
"verbose_name": "Contact History",
82+
"verbose_name_plural": "Contact Histories",
83+
"db_table": "access_contact_audithistory",
84+
"managed": True,
85+
},
86+
bases=("core.centurionaudit",),
87+
),
88+
migrations.CreateModel(
89+
name="ContactCenturionModelNote",
90+
fields=[
91+
(
92+
"centurionmodelnote_ptr",
93+
models.OneToOneField(
94+
auto_created=True,
95+
on_delete=django.db.models.deletion.CASCADE,
96+
parent_link=True,
97+
primary_key=True,
98+
serialize=False,
99+
to="core.centurionmodelnote",
100+
),
101+
),
102+
(
103+
"model",
104+
models.ForeignKey(
105+
help_text="Model this note belongs to",
106+
on_delete=django.db.models.deletion.CASCADE,
107+
related_name="+",
108+
to="access.contact",
109+
verbose_name="Model",
110+
),
111+
),
112+
],
113+
options={
114+
"verbose_name": "Contact Note",
115+
"verbose_name_plural": "Contact Notes",
116+
"db_table": "access_contact_centurionmodelnote",
117+
"managed": True,
118+
},
119+
bases=("core.centurionmodelnote",),
120+
),
121+
migrations.CreateModel(
122+
name="EntityAuditHistory",
123+
fields=[
124+
(
125+
"centurionaudit_ptr",
126+
models.OneToOneField(
127+
auto_created=True,
128+
on_delete=django.db.models.deletion.CASCADE,
129+
parent_link=True,
130+
primary_key=True,
131+
serialize=False,
132+
to="core.centurionaudit",
133+
),
134+
),
135+
(
136+
"model",
137+
models.ForeignKey(
138+
help_text="Model this history belongs to",
139+
on_delete=django.db.models.deletion.CASCADE,
140+
related_name="audit_history",
141+
to="access.entity",
142+
verbose_name="Model",
143+
),
144+
),
145+
],
146+
options={
147+
"verbose_name": "Entity History",
148+
"verbose_name_plural": "Entity Histories",
149+
"db_table": "access_entity_audithistory",
150+
"managed": True,
151+
},
152+
bases=("core.centurionaudit",),
153+
),
154+
migrations.CreateModel(
155+
name="EntityCenturionModelNote",
156+
fields=[
157+
(
158+
"centurionmodelnote_ptr",
159+
models.OneToOneField(
160+
auto_created=True,
161+
on_delete=django.db.models.deletion.CASCADE,
162+
parent_link=True,
163+
primary_key=True,
164+
serialize=False,
165+
to="core.centurionmodelnote",
166+
),
167+
),
168+
(
169+
"model",
170+
models.ForeignKey(
171+
help_text="Model this note belongs to",
172+
on_delete=django.db.models.deletion.CASCADE,
173+
related_name="+",
174+
to="access.entity",
175+
verbose_name="Model",
176+
),
177+
),
178+
],
179+
options={
180+
"verbose_name": "Entity Note",
181+
"verbose_name_plural": "Entity Notes",
182+
"db_table": "access_entity_centurionmodelnote",
183+
"managed": True,
184+
},
185+
bases=("core.centurionmodelnote",),
186+
),
187+
migrations.CreateModel(
188+
name="PersonAuditHistory",
189+
fields=[
190+
(
191+
"centurionaudit_ptr",
192+
models.OneToOneField(
193+
auto_created=True,
194+
on_delete=django.db.models.deletion.CASCADE,
195+
parent_link=True,
196+
primary_key=True,
197+
serialize=False,
198+
to="core.centurionaudit",
199+
),
200+
),
201+
(
202+
"model",
203+
models.ForeignKey(
204+
help_text="Model this history belongs to",
205+
on_delete=django.db.models.deletion.CASCADE,
206+
related_name="+",
207+
to="access.person",
208+
verbose_name="Model",
209+
),
210+
),
211+
],
212+
options={
213+
"verbose_name": "Person History",
214+
"verbose_name_plural": "Person Histories",
215+
"db_table": "access_person_audithistory",
216+
"managed": True,
217+
},
218+
bases=("core.centurionaudit",),
219+
),
220+
migrations.CreateModel(
221+
name="PersonCenturionModelNote",
222+
fields=[
223+
(
224+
"centurionmodelnote_ptr",
225+
models.OneToOneField(
226+
auto_created=True,
227+
on_delete=django.db.models.deletion.CASCADE,
228+
parent_link=True,
229+
primary_key=True,
230+
serialize=False,
231+
to="core.centurionmodelnote",
232+
),
233+
),
234+
(
235+
"model",
236+
models.ForeignKey(
237+
help_text="Model this note belongs to",
238+
on_delete=django.db.models.deletion.CASCADE,
239+
related_name="+",
240+
to="access.person",
241+
verbose_name="Model",
242+
),
243+
),
244+
],
245+
options={
246+
"verbose_name": "Person Note",
247+
"verbose_name_plural": "Person Notes",
248+
"db_table": "access_person_centurionmodelnote",
249+
"managed": True,
250+
},
251+
bases=("core.centurionmodelnote",),
252+
),
253+
]

app/access/mixins/permissions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from rest_framework.permissions import DjangoObjectPermissions
44

5-
from access.models.tenancy import Tenant, TenancyObject
5+
from access.models.tenancy import Tenant
66

77
from core import exceptions as centurion_exceptions
8+
from core.mixins.centurion import Centurion
89

910

1011

@@ -57,11 +58,11 @@ def is_tenancy_model(self, view) -> bool:
5758

5859
if hasattr(view, 'model'):
5960

60-
self._is_tenancy_model = issubclass(view.model, TenancyObject)
61+
self._is_tenancy_model = issubclass(view.model, Centurion)
6162

6263
if view.get_parent_model():
6364

64-
self._is_tenancy_model = issubclass(view.get_parent_model(), TenancyObject)
65+
self._is_tenancy_model = issubclass(view.get_parent_model(), Centurion)
6566

6667
return self._is_tenancy_model
6768

app/access/models/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
2-
3-
from .entity_history import EntityHistory # pylint: disable=W0611:unused-import
41
from .organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
52
from .role_history import RoleHistory # pylint: disable=W0611:unused-import
63

7-
from .entity_notes import EntityNotes # pylint: disable=W0611:unused-import
84
from .organization_notes import OrganizationNotes # pylint: disable=W0611:unused-import
95
from .role_notes import RoleNotes # pylint: disable=W0611:unused-import

app/access/models/company_base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Company(
1212
# references in code to `organization` witch clashes with the intended name of
1313
# this model.
1414

15+
_is_submodel = True
16+
17+
documentation = ''
18+
1519

1620
class Meta:
1721

@@ -40,10 +44,6 @@ def __str__(self) -> str:
4044
return self.name
4145

4246

43-
documentation = ''
44-
45-
history_model_name = 'company'
46-
4747
page_layout: dict = [
4848
{
4949
"name": "Details",
@@ -95,8 +95,3 @@ def __str__(self) -> str:
9595
'organization',
9696
'created',
9797
]
98-
99-
100-
def clean(self):
101-
102-
super().clean()

0 commit comments

Comments
 (0)