projects: модуль проектов с шагами по отделам и Task.
Шаблоны/ручное создание, access_projects, сид «Открытие аптеки». Плюс SILO/S3 для Django media. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
from django.contrib import admin
|
||||
from unfold.admin import ModelAdmin, TabularInline
|
||||
|
||||
from apps.projects.models import (
|
||||
Project, ProjectStep, ProjectStepItem,
|
||||
ProjectTemplate, ProjectTemplateStep, ProjectTemplateStepItem,
|
||||
)
|
||||
|
||||
|
||||
class TemplateStepItemInline(TabularInline):
|
||||
model = ProjectTemplateStepItem
|
||||
extra = 1
|
||||
fields = ('order', 'title', 'priority', 'description')
|
||||
|
||||
|
||||
class TemplateStepInline(TabularInline):
|
||||
model = ProjectTemplateStep
|
||||
extra = 1
|
||||
fields = ('order', 'title', 'department', 'offset_days', 'duration_days')
|
||||
show_change_link = True
|
||||
autocomplete_fields = ['department']
|
||||
|
||||
|
||||
@admin.register(ProjectTemplate)
|
||||
class ProjectTemplateAdmin(ModelAdmin):
|
||||
list_display = ('name', 'default_duration_days', 'is_active', 'updated_at')
|
||||
list_filter = ('is_active',)
|
||||
search_fields = ('name', 'description')
|
||||
inlines = [TemplateStepInline]
|
||||
|
||||
|
||||
@admin.register(ProjectTemplateStep)
|
||||
class ProjectTemplateStepAdmin(ModelAdmin):
|
||||
list_display = ('template', 'order', 'title', 'department', 'offset_days', 'duration_days')
|
||||
list_filter = ('template',)
|
||||
search_fields = ('title',)
|
||||
autocomplete_fields = ['template', 'department']
|
||||
inlines = [TemplateStepItemInline]
|
||||
|
||||
|
||||
class ProjectStepItemInline(TabularInline):
|
||||
model = ProjectStepItem
|
||||
extra = 0
|
||||
fields = ('order', 'title', 'priority', 'task')
|
||||
readonly_fields = ('task',)
|
||||
show_change_link = True
|
||||
|
||||
|
||||
class ProjectStepInline(TabularInline):
|
||||
model = ProjectStep
|
||||
extra = 0
|
||||
fields = ('order', 'title', 'department', 'status', 'planned_start', 'planned_due')
|
||||
show_change_link = True
|
||||
autocomplete_fields = ['department']
|
||||
|
||||
|
||||
@admin.register(Project)
|
||||
class ProjectAdmin(ModelAdmin):
|
||||
list_display = (
|
||||
'title', 'status', 'owner', 'pharmacy', 'start_date', 'due_date', 'updated_at',
|
||||
)
|
||||
list_filter = ('status',)
|
||||
search_fields = ('title', 'description')
|
||||
autocomplete_fields = ['owner', 'created_by', 'pharmacy', 'template']
|
||||
inlines = [ProjectStepInline]
|
||||
readonly_fields = ('uuid', 'created_at', 'updated_at')
|
||||
|
||||
|
||||
@admin.register(ProjectStep)
|
||||
class ProjectStepAdmin(ModelAdmin):
|
||||
list_display = ('project', 'order', 'title', 'department', 'status', 'planned_due')
|
||||
list_filter = ('status',)
|
||||
search_fields = ('title', 'project__title')
|
||||
autocomplete_fields = ['project', 'department']
|
||||
inlines = [ProjectStepItemInline]
|
||||
Reference in New Issue
Block a user