mirror of
https://github.com/ferdzo/serviceCRM.git
synced 2026-04-04 21:06:24 +00:00
2.9 KiB
2.9 KiB
ServiceCRM Copilot Instructions
Project Overview
ServiceCRM is a simple Service Ticket Management System built with Django. It manages repair tickets ("Inserts") for service customers, tracking details like customer info, defect description, repair status, and notes.
Architecture
- Framework: Django 4.x (compatible with 5.x/6.x in dependencies).
- Structure: Single-app project where the
serviceCRMpackage contains both project settings and application logic (views, models, urls). - Patterns: Model-View-Template (MVT).
- Frontend: Server-side rendered templates using Bootstrap 5 and
django-crispy-forms.
Key Components
Data Model
- Primary Model:
Insert(defined inserviceCRM/models.py).- Represents a service ticket.
- Key fields:
name,phone,description(defect),repair(resolution),done(status),date.
Views & Controllers
- Location:
serviceCRM/views.py. - Pattern: Mix of Class-Based Views (CBV) and Function-Based Views (FBV).
- List views use
django_tables2.SingleTableView. - Create/Update use
generic.Viewandgeneric.UpdateView. - Note: Some views use a non-standard static method pattern (e.g.,
InsertNew.insertreferenced in URLs).
- List views use
UI/UX
- Tables:
django-tables2is used for listing records (serviceCRM/tables.py). - Forms:
django-crispy-formswithcrispy-bootstrap5pack (serviceCRM/forms.py). - Templates: Located in
templates/andtemplates/serviceCRM/.
Configuration & Environment
- Settings:
serviceCRM/settings.pyusesdjango-environ. - Environment: Configuration reads from
.envfile (see.env.example). - Database:
- Local/Dev: SQLite (configured via
settings.pyoverriding env vars if needed). - Production: Configurable via
DATABASE_URLor individual env vars (PostgreSQL supported).
- Local/Dev: SQLite (configured via
Development Workflow
Setup
- Create
.envfrom.env.example. - Install dependencies:
pip install -r requirements.txt. - Run migrations:
python manage.py migrate.
Common Commands
- Run Server:
python manage.py runserver - Make Migrations:
python manage.py makemigrations(Required when changingmodels.py) - Migrate:
python manage.py migrate
Coding Conventions
- Imports: standard library -> third party -> django -> local apps.
- Urls: Defined in
serviceCRM/urls.py(which is the root URLconf). - Routing: Routes are mixed between CBV (
.as_view()) and function references. Maintain consistency with existing patterns when adding new routes.
Critical Patterns to Respect
- Forms: Always use
InputForminserviceCRM/forms.pyfor ticket creation/editing to ensure consistent widget rendering with Bootstrap classes. - Tables: When adding lists, subclass
tables.TableinserviceCRM/tables.pyand useSingleTableViewfor display/sorting features. - Template Inheritance: All templates should extend
base.html.