Добавил журнал ошибок
This commit is contained in:
@@ -1380,3 +1380,77 @@ class SourceRequestStatusHistoryAdmin(BaseAdmin):
|
||||
|
||||
def has_change_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Errors Report Admin
|
||||
# ============================================================================
|
||||
|
||||
from .models import IssueType, DailyReport, DowntimePeriod, IssueMark
|
||||
|
||||
|
||||
class DowntimePeriodInline(admin.TabularInline):
|
||||
"""Inline для периодов простоя."""
|
||||
model = DowntimePeriod
|
||||
extra = 1
|
||||
fields = ('start_time', 'end_time', 'reason')
|
||||
|
||||
|
||||
class IssueMarkInline(admin.TabularInline):
|
||||
"""Inline для отметок об ошибках."""
|
||||
model = IssueMark
|
||||
extra = 0
|
||||
fields = ('issue_type', 'is_present')
|
||||
autocomplete_fields = ('issue_type',)
|
||||
|
||||
|
||||
@admin.register(IssueType)
|
||||
class IssueTypeAdmin(BaseAdmin):
|
||||
"""Админ-панель для типов ошибок/неисправностей."""
|
||||
|
||||
list_display = ('name', 'category')
|
||||
list_filter = ('category',)
|
||||
search_fields = ('name',)
|
||||
ordering = ('category', 'name')
|
||||
|
||||
|
||||
@admin.register(DailyReport)
|
||||
class DailyReportAdmin(BaseAdmin):
|
||||
"""Админ-панель для ежедневных отчётов."""
|
||||
|
||||
list_display = (
|
||||
'date',
|
||||
'daily_work_hours',
|
||||
'weekly_work_hours',
|
||||
'downtime_count',
|
||||
'issues_count',
|
||||
'created_at',
|
||||
)
|
||||
list_filter = (
|
||||
('date', DateRangeQuickSelectListFilterBuilder()),
|
||||
)
|
||||
search_fields = ('explanation', 'comment')
|
||||
ordering = ('-date',)
|
||||
readonly_fields = ('created_at', 'updated_at', 'created_by')
|
||||
inlines = [DowntimePeriodInline, IssueMarkInline]
|
||||
|
||||
fieldsets = (
|
||||
('Основная информация', {
|
||||
'fields': ('date', 'daily_work_hours', 'weekly_work_hours')
|
||||
}),
|
||||
('Примечания', {
|
||||
'fields': ('explanation', 'comment')
|
||||
}),
|
||||
('Метаданные', {
|
||||
'fields': ('created_at', 'updated_at', 'created_by'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
|
||||
def downtime_count(self, obj):
|
||||
return obj.downtime_periods.count()
|
||||
downtime_count.short_description = 'Простоев'
|
||||
|
||||
def issues_count(self, obj):
|
||||
return obj.issue_marks.filter(is_present=True).count()
|
||||
issues_count.short_description = 'Ошибок/неисправностей'
|
||||
|
||||
Reference in New Issue
Block a user