Cloned DMOJ
This commit is contained in:
parent
f623974b58
commit
49dc9ff10c
513 changed files with 132349 additions and 39 deletions
39
judge/admin/ticket.py
Normal file
39
judge/admin/ticket.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from django.contrib.admin import ModelAdmin
|
||||
from django.contrib.admin.options import StackedInline
|
||||
from django.forms import ModelForm
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from judge.models import TicketMessage
|
||||
from judge.widgets import AdminHeavySelect2MultipleWidget, AdminHeavySelect2Widget, HeavyPreviewAdminPageDownWidget
|
||||
|
||||
|
||||
class TicketMessageForm(ModelForm):
|
||||
class Meta:
|
||||
widgets = {
|
||||
'user': AdminHeavySelect2Widget(data_view='profile_select2', attrs={'style': 'width: 100%'}),
|
||||
}
|
||||
if HeavyPreviewAdminPageDownWidget is not None:
|
||||
widgets['body'] = HeavyPreviewAdminPageDownWidget(preview=reverse_lazy('ticket_preview'))
|
||||
|
||||
|
||||
class TicketMessageInline(StackedInline):
|
||||
model = TicketMessage
|
||||
form = TicketMessageForm
|
||||
fields = ('user', 'body')
|
||||
|
||||
|
||||
class TicketForm(ModelForm):
|
||||
class Meta:
|
||||
widgets = {
|
||||
'user': AdminHeavySelect2Widget(data_view='profile_select2', attrs={'style': 'width: 100%'}),
|
||||
'assignees': AdminHeavySelect2MultipleWidget(data_view='profile_select2', attrs={'style': 'width: 100%'}),
|
||||
}
|
||||
|
||||
|
||||
class TicketAdmin(ModelAdmin):
|
||||
fields = ('title', 'time', 'user', 'assignees', 'content_type', 'object_id', 'notes')
|
||||
readonly_fields = ('time',)
|
||||
list_display = ('title', 'user', 'time', 'linked_item')
|
||||
inlines = [TicketMessageInline]
|
||||
form = TicketForm
|
||||
date_hierarchy = 'time'
|
Loading…
Add table
Add a link
Reference in a new issue