1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
""" |
4
|
|
|
Created on Tue Jan 29 11:28:48 2019 |
5
|
|
|
|
6
|
|
|
@author: Paolo Cozzi <[email protected]> |
7
|
|
|
""" |
8
|
|
|
|
9
|
|
|
from django.contrib import admin |
10
|
|
|
from django.template.defaultfilters import truncatechars |
11
|
|
|
|
12
|
|
|
from .models import ValidationResult, ValidationSummary |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class ValidationSummaryAdmin(admin.ModelAdmin): |
16
|
|
|
list_display = [ |
17
|
|
|
'submission_title', 'owner', 'type', 'all_count', |
18
|
|
|
'validation_known_count', 'issues_count', 'pass_count', |
19
|
|
|
'warning_count', 'error_count'] |
20
|
|
|
|
21
|
|
|
list_select_related = ('submission', 'submission__owner') |
22
|
|
|
|
23
|
|
|
list_filter = ['submission__owner', 'submission__status'] |
24
|
|
|
|
25
|
|
|
def submission_title(self, obj): |
26
|
|
|
return obj.submission.title |
27
|
|
|
|
28
|
|
|
def owner(self, obj): |
29
|
|
|
return obj.submission.owner |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
class ValidationResultAdmin(admin.ModelAdmin): |
33
|
|
|
list_display = [ |
34
|
|
|
'submission_title', 'owner', 'content_type', 'object_id', 'status', |
35
|
|
|
'short_messages'] |
36
|
|
|
|
37
|
|
|
list_select_related = ('submission', 'submission__owner', 'content_type') |
38
|
|
|
|
39
|
|
|
list_per_page = 20 |
40
|
|
|
|
41
|
|
|
list_filter = ['submission__owner', 'status'] |
42
|
|
|
|
43
|
|
|
def submission_title(self, obj): |
44
|
|
|
return obj.submission.title |
45
|
|
|
|
46
|
|
|
def owner(self, obj): |
47
|
|
|
return obj.submission.owner |
48
|
|
|
|
49
|
|
|
def short_messages(self, obj): |
50
|
|
|
return truncatechars(",".join(obj.messages), 60) |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
# Register your models here. |
54
|
|
|
admin.site.register(ValidationResult, ValidationResultAdmin) |
55
|
|
|
admin.site.register(ValidationSummary, ValidationSummaryAdmin) |
56
|
|
|
|