🏗️ Struktura Modułu¶
Każdy moduł w Panel Księgowy musi mieć standardową strukturę zgodną z wytycznymi.
📁 Wymagana struktura¶
apps/module_name/
├── __init__.py
├── models/ # ✅ REQUIRED
│ ├── __init__.py
│ └── main.py # BaseTeamModel models
├── views/ # ✅ REQUIRED
│ ├── __init__.py
│ ├── dashboard.py # ✅ REQUIRED - Module dashboard
│ ├── settings.py # ✅ REQUIRED - Module settings
│ └── crud.py # CRUD operations
├── templates/module_name/ # ✅ REQUIRED
│ ├── dashboard.html # ✅ REQUIRED
│ ├── settings.html # ✅ REQUIRED
│ └── components/ # Reusable components
├── urls.py # ✅ REQUIRED - team_urlpatterns
├── admin.py # ✅ REQUIRED
├── forms.py # If forms needed
├── services.py # Business logic (optional)
├── tasks.py # Celery tasks (optional)
├── signals.py # Django signals (optional)
└── README.md # ✅ REQUIRED - Module documentation
🎯 Wymagane komponenty¶
1. Models¶
Wszystkie modele muszą dziedziczyć po BaseTeamModel:
from apps.teams.models import BaseTeamModel
class MyModel(BaseTeamModel):
name = models.CharField(max_length=200)
# team field jest automatycznie dodany
2. Views¶
Dashboard View¶
from apps.teams.decorators import login_and_team_required
@login_and_team_required
def dashboard(request, team_slug):
"""Module dashboard."""
team = request.team
stats = {
'total': MyModel.objects.filter(team=team).count(),
}
return render(request, 'module_name/dashboard.html', {
'team': team,
'stats': stats,
})
Settings View¶
@login_and_team_required
@team_admin_required
def settings(request, team_slug):
"""Module settings."""
# ...
3. URLs¶
app_name = 'module_name'
team_urlpatterns = [
path('', views.dashboard, name='dashboard'),
path('settings/', views.settings, name='settings'),
# ...
]
4. Templates¶
Dashboard Template¶
{% extends "web/app/app_base_tailadmin.html" %}
{% load i18n %}
{% block app %}
<div class="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10">
<h1>{% translate "Module Dashboard" %}</h1>
<!-- ... -->
</div>
{% endblock %}
📚 Więcej informacji¶
- Tworzenie Modułu - Przewodnik krok po kroku
- CRM - Przykład modułu CRM
Ostatnia aktualizacja: 2025-11-29
Wersja dokumentacji: 1.0