django-spire 0.16.13__py3-none-any.whl → 0.17.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. django_spire/consts.py +1 -1
  2. django_spire/core/management/commands/spire_startapp.py +84 -46
  3. django_spire/core/management/commands/spire_startapp_pkg/__init__.py +60 -0
  4. django_spire/core/management/commands/spire_startapp_pkg/builder.py +91 -0
  5. django_spire/core/management/commands/spire_startapp_pkg/config.py +115 -0
  6. django_spire/core/management/commands/spire_startapp_pkg/filesystem.py +125 -0
  7. django_spire/core/management/commands/spire_startapp_pkg/generator.py +167 -0
  8. django_spire/core/management/commands/spire_startapp_pkg/maps.py +783 -25
  9. django_spire/core/management/commands/spire_startapp_pkg/permissions.py +147 -0
  10. django_spire/core/management/commands/spire_startapp_pkg/processor.py +144 -57
  11. django_spire/core/management/commands/spire_startapp_pkg/registry.py +89 -0
  12. django_spire/core/management/commands/spire_startapp_pkg/reporter.py +245 -108
  13. django_spire/core/management/commands/spire_startapp_pkg/resolver.py +86 -0
  14. django_spire/core/management/commands/spire_startapp_pkg/template/app/__init__.py.template +0 -0
  15. django_spire/core/management/commands/spire_startapp_pkg/template/app/apps.py.template +15 -0
  16. django_spire/core/management/commands/spire_startapp_pkg/template/app/forms.py.template +18 -0
  17. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/__init__.py.template +0 -0
  18. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/bots.py.template +18 -0
  19. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/intel.py.template +7 -0
  20. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/prompts.py.template +32 -0
  21. django_spire/core/management/commands/spire_startapp_pkg/template/app/migrations/__init__.py.template +0 -0
  22. django_spire/core/management/commands/spire_startapp_pkg/template/app/models.py.template +52 -0
  23. django_spire/core/management/commands/spire_startapp_pkg/template/app/querysets.py.template +20 -0
  24. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/__init__.py.template +0 -0
  25. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/seed.py.template +6 -0
  26. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/seeder.py.template +26 -0
  27. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/__init__.py.template +0 -0
  28. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/factory_service.py.template +12 -0
  29. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/intelligence_service.py.template +12 -0
  30. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/processor_service.py.template +12 -0
  31. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/service.py.template +22 -0
  32. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/transformation_service.py.template +12 -0
  33. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/__init__.py.template +0 -0
  34. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_intelligence/__init__.py.template +0 -0
  35. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_intelligence/test_bots.py.template +8 -0
  36. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_models.py.template +8 -0
  37. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/__init__.py.template +0 -0
  38. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_factory_service.py.template +8 -0
  39. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_intelligence_service.py.template +8 -0
  40. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_processor_service.py.template +8 -0
  41. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_service.py.template +8 -0
  42. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_transformation_service.py.template +8 -0
  43. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/__init__.py.template +0 -0
  44. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/test_form_urls.py.template +8 -0
  45. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/test_page_urls.py.template +8 -0
  46. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/__init__.py.template +0 -0
  47. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/test_form_views.py.template +8 -0
  48. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/test_page_views.py.template +8 -0
  49. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/__init__.py.template +9 -0
  50. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/form_urls.py.template +15 -0
  51. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/page_urls.py.template +11 -0
  52. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/__init__.py.template +0 -0
  53. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/form_views.py.template +134 -0
  54. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/page_views.py.template +44 -0
  55. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/{spirechildapp_detail_card.html → ${detail_card_template_name}.html.template} +7 -7
  56. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/{spirechildapp_form_card.html → ${form_card_template_name}.html.template} +2 -2
  57. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_card_template_name}.html.template +18 -0
  58. django_spire/core/management/commands/spire_startapp_pkg/template/templates/form/{spirechildapp_form.html → ${form_template_name}.html.template} +4 -4
  59. django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/${item_template_name}.html.template +24 -0
  60. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_detail_page.html → ${detail_page_template_name}.html.template} +3 -3
  61. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_form_page.html → ${form_page_template_name}.html.template} +1 -1
  62. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_list_page.html → ${list_page_template_name}.html.template} +2 -2
  63. django_spire/core/management/commands/spire_startapp_pkg/user_input.py +252 -0
  64. django_spire/core/management/commands/spire_startapp_pkg/validator.py +96 -0
  65. django_spire/core/middleware/__init__.py +1 -2
  66. django_spire/profiling/__init__.py +13 -0
  67. django_spire/profiling/middleware/__init__.py +6 -0
  68. django_spire/{core → profiling}/middleware/profiling.py +63 -58
  69. django_spire/profiling/panel.py +345 -0
  70. django_spire/profiling/templates/panel.html +166 -0
  71. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/METADATA +1 -1
  72. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/RECORD +75 -23
  73. django_spire/core/management/commands/spire_startapp_pkg/constants.py +0 -4
  74. django_spire/core/management/commands/spire_startapp_pkg/manager.py +0 -176
  75. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/spirechildapp_list_card.html +0 -18
  76. django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/spirechildapp_item.html +0 -24
  77. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/WHEEL +0 -0
  78. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/licenses/LICENSE.md +0 -0
  79. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/top_level.txt +0 -0
@@ -1,176 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import shutil
4
-
5
- from typing_extensions import TYPE_CHECKING
6
-
7
- from django.conf import settings
8
- from django.core.management.base import CommandError
9
-
10
- if TYPE_CHECKING:
11
- from pathlib import Path
12
-
13
- from django_spire.core.management.commands.spire_startapp_pkg.processor import (
14
- AppTemplateProcessor,
15
- HTMLTemplateProcessor
16
- )
17
- from django_spire.core.management.commands.spire_startapp_pkg.reporter import Reporter
18
-
19
-
20
- class BaseTemplateManager:
21
- def __init__(self, base: Path, template: Path):
22
- self.base = base
23
- self.template = template
24
-
25
- def _get_destination(self, components: list[str]) -> Path:
26
- return self.base.joinpath(*components)
27
-
28
- def _report_exists(self, app: str, destination: Path, reporter: Reporter) -> None:
29
- raise NotImplementedError
30
-
31
- def _report_creating(self, app: str, destination: Path, reporter: Reporter) -> None:
32
- raise NotImplementedError
33
-
34
- def _report_success(self, app: str, reporter: Reporter) -> None:
35
- raise NotImplementedError
36
-
37
- def _create_entity(
38
- self,
39
- app: str,
40
- components: list[str],
41
- processor_method: callable,
42
- reporter: Reporter,
43
- missing_template_message: str
44
- ) -> None:
45
- destination = self._get_destination(components)
46
-
47
- if destination.exists() and any(destination.iterdir()):
48
- self._report_exists(app, destination, reporter)
49
- return
50
-
51
- self._report_creating(app, destination, reporter)
52
- destination.mkdir(parents=True, exist_ok=True)
53
-
54
- if not self.template.exists():
55
- raise CommandError(missing_template_message)
56
-
57
- shutil.copytree(
58
- self.template,
59
- destination,
60
- dirs_exist_ok=True,
61
- ignore=shutil.ignore_patterns('__pycache__', '*.pyc')
62
- )
63
-
64
- processor_method(destination, components)
65
- self._report_success(app, reporter)
66
-
67
-
68
- class AppManager(BaseTemplateManager):
69
- def get_valid_root_apps(self) -> set[str]:
70
- return {
71
- app.split('.')[0]
72
- for app in settings.INSTALLED_APPS
73
- if '.' in app and app.split('.')[0] != 'django'
74
- }
75
-
76
- def is_valid_root_apps(self, components: list[str]) -> None:
77
- valid = self.get_valid_root_apps()
78
- root = components[0]
79
-
80
- if root not in valid:
81
- message = (
82
- f'Invalid root app "{root}". '
83
- f'The following are valid root apps: {", ".join(valid)}.'
84
- )
85
-
86
- raise CommandError(message)
87
-
88
- def validate_app_name_format(self, app: str) -> None:
89
- if '.' not in app:
90
- message = (
91
- 'Invalid app name format. '
92
- 'The app path must use dot notation (e.g., "parent.child").'
93
- )
94
-
95
- raise CommandError(message)
96
-
97
- def parse_app_name(self, app: str) -> list[str]:
98
- return app.split('.') if '.' in app else [app]
99
-
100
- def get_missing_components(
101
- self,
102
- components: list[str],
103
- registry: list[str]
104
- ) -> list[str]:
105
- missing = []
106
- total = len(components)
107
-
108
- for i in range(total):
109
- component = '.'.join(components[: i + 1])
110
-
111
- if component not in registry and i > 0:
112
- missing.append(component)
113
-
114
- return missing
115
-
116
- def _report_exists(self, app: str, destination: Path, reporter: Reporter) -> None:
117
- reporter.report_app_exists(app, destination)
118
-
119
- def _report_creating(self, app: str, destination: Path, reporter: Reporter) -> None:
120
- reporter.report_creating_app(app, destination)
121
-
122
- def _report_success(self, app: str, reporter: Reporter) -> None:
123
- reporter.report_app_creation_success(app)
124
-
125
- def create_custom_app(
126
- self,
127
- app: str,
128
- processor: AppTemplateProcessor,
129
- reporter: Reporter
130
- ) -> None:
131
- components = app.split('.')
132
-
133
- message = (
134
- f'Template directory "{self.template}" is missing. '
135
- 'Ensure you have a valid app template.'
136
- )
137
-
138
- self._create_entity(
139
- app,
140
- components,
141
- processor.replace_app_name,
142
- reporter,
143
- message
144
- )
145
-
146
-
147
- class HTMLTemplateManager(BaseTemplateManager):
148
- def _report_exists(self, app: str, destination: Path, reporter: Reporter) -> None:
149
- reporter.report_templates_exist(app, destination)
150
-
151
- def _report_creating(self, app: str, destination: Path, reporter: Reporter) -> None:
152
- reporter.report_creating_templates(app, destination)
153
-
154
- def _report_success(self, app: str, reporter: Reporter) -> None:
155
- reporter.report_templates_creation_success(app)
156
-
157
- def create_custom_templates(
158
- self,
159
- app: str,
160
- processor: HTMLTemplateProcessor,
161
- reporter: Reporter
162
- ) -> None:
163
- components = app.split('.')[1:]
164
-
165
- message = (
166
- f'Template directory "{self.template}" is missing. '
167
- 'Ensure you have a valid templates template.'
168
- )
169
-
170
- self._create_entity(
171
- app,
172
- components,
173
- processor.replace_template_names,
174
- reporter,
175
- message
176
- )
@@ -1,18 +0,0 @@
1
- {% extends 'django_spire/card/title_card.html' %}
2
-
3
- {% block card_title %}
4
- spire_model_name_plural
5
- {% endblock %}
6
-
7
- {% block card_button %}
8
- {% url 'spire_parent_app:spire_app_name:page:form' pk=0 as new_spire_app_name_url %}
9
- {% include 'django_spire/button/primary_dark_button.html' with button_text='Add' button_icon='bi bi-plus' button_href=new_spire_app_name_url %}
10
- {% endblock %}
11
-
12
- {% block card_title_content %}
13
- {% for spire_app_name in spire_app_name_plural %}
14
- {% include 'spire_parent_app/spire_app_name/item/spire_app_name_item.html' %}
15
- {% empty %}
16
- {% include 'django_spire/item/no_data_item.html' %}
17
- {% endfor %}
18
- {% endblock %}
@@ -1,24 +0,0 @@
1
- {% extends 'django_spire/item/item.html' %}
2
-
3
- {% block item_title %}
4
- {% url 'spire_parent_app:spire_app_name:page:detail' pk=spire_app_name.pk as spire_app_name_view_url %}
5
- {% include 'django_spire/element/attribute_element.html' with attribute_title='spire_model_name' attribute_value=spire_app_name.name attribute_href=spire_app_name_view_url %}
6
- {% endblock %}
7
-
8
- {% block item_row_content %}
9
- {% include 'django_spire/element/attribute_element.html' with attribute_title='Description' attribute_value=spire_app_name.description %}
10
- {% endblock %}
11
-
12
- {% block item_button %}
13
- {% url 'spire_parent_app:spire_app_name:page:detail' pk=spire_app_name.pk as spire_app_name_view_url %}
14
-
15
- {% if perms.spire_label_path.change_spire_app_name %}
16
- {% url 'spire_parent_app:spire_app_name:page:form' pk=spire_app_name.pk as spire_app_name_edit_url %}
17
- {% endif %}
18
-
19
- {% if perms.spire_label_path.delete_spire_app_name %}
20
- {% url 'spire_parent_app:spire_app_name:page:delete' pk=spire_app_name.pk as spire_app_name_delete_url %}
21
- {% endif %}
22
-
23
- {% include 'django_spire/dropdown/ellipsis_dropdown.html' with view_url=spire_app_name_view_url edit_url=spire_app_name_edit_url delete_url=spire_app_name_delete_url %}
24
- {% endblock %}