Commit 8d15f2c
committed
[REF] spp_event_*: Centralize event model registration with mixin pattern
Major refactoring to improve event type registration architecture and eliminate code duplication:
- Add is_event_model boolean field to ir.model in spp_event_data
- Create spp.event.mixin abstract model to encapsulate common event functionality
- Implement automatic event model registration via _register_hook()
- Provide reusable get_view_id() method through mixin
Changes to spp_event_data:
- Add models/ir_model.py: Extend ir.model with is_event_model flag
- Add models/event_mixin.py: New abstract mixin for all event types
- Update wizard/create_event_wizard.py: Dynamic selection now queries ir.model.is_event_model
- Update models/event_data.py: Handle get_view_id() for both mixin and non-mixin models
Changes to spp_event_demo:
- Refactor house_visit, phone_survey, school_enrolment to inherit spp.event.mixin
- Remove boilerplate _register_hook() and get_view_id() methods
- Delete redundant wizard/create_event_wizard.py (static selection_add)
Changes to spp_event_spec_loader:
- Update event_type_definition.py: Set is_event_model=True on dynamic model creation
- Update dynamic_event_model.py: Inherit spp.event.mixin, add guard to prevent mixin self-registration
- Remove boilerplate get_view_id() method
Benefits:
- DRY: Eliminates code duplication across event models
- Centralized: Single source of truth for event model registration
- Scalable: Works seamlessly with both static and dynamic event models
- Maintainable: Changes to event model behavior now in one place1 parent 77bda71 commit 8d15f2c
File tree
8 files changed
+34
-22
lines changed- spp_event_data
- models
- wizard
- spp_event_spec_loader
- models
8 files changed
+34
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 451 | + | |
| 452 | + | |
456 | 453 | | |
457 | 454 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 332 | + | |
| 333 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
| 146 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
| 446 | + | |
| 447 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
| 271 | + | |
| 272 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
26 | 37 | | |
| |||
0 commit comments