Completed
Push — master ( 254aa9...d57b0b )
by
unknown
01:38
created

FeedbackDescriptionAdmin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_queryset() 0 3 1
1
# coding: utf8
2
3
"""
4
This software is licensed under the Apache 2 license, quoted below.
5
6
Copyright 2015 Crystalnix Limited
7
8
Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
use this file except in compliance with the License. You may obtain a copy of
10
the License at
11
12
    http://www.apache.org/licenses/LICENSE-2.0
13
14
Unless required by applicable law or agreed to in writing, software
15
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
License for the specific language governing permissions and limitations under
18
the License.
19
"""
20
21
from django.contrib import admin
22
23
from crash.admin import TextInputFilter, BooleanFilter
24
25
from feedback.models import Feedback, FeedbackDescription
26
from feedback.forms import FeedbackForm
27
28
29
class ScreenshotFilter(BooleanFilter):
30
    title = 'Screenshot'
31
    parameter_name = 'screenshot'
32
33
34
class BlackboxFilter(BooleanFilter):
35
    title = 'Blackbox'
36
    parameter_name = 'blackbox'
37
38
39
class SystemLogsFilter(BooleanFilter):
40
    title = 'System Logs'
41
    parameter_name = 'system_logs'
42
43
44
class AttachedFileFilter(BooleanFilter):
45
    title = 'Attached File'
46
    parameter_name = 'attached_file'
47
48
49
@admin.register(Feedback)
50
class FeedbackAdmin(admin.ModelAdmin):
51
    list_display = ('id', 'description', 'email', 'page_url', 'created_at', 'ip',)
52
    list_display_links = ('id', 'description')
53
    list_filter = (('id', TextInputFilter,), ScreenshotFilter, BlackboxFilter, SystemLogsFilter, AttachedFileFilter, 'created_at',)
54
    form = FeedbackForm
55
    readonly_fields = ('created_at',)
56
57
    def get_queryset(self, request):
58
        qs = super(FeedbackAdmin, self).get_queryset(request)
59
        return qs.filter(description__startswith='BlackBox')
60
61
62
@admin.register(FeedbackDescription)
63
class FeedbackDescriptionAdmin(admin.ModelAdmin):
64
    list_display = ('id', 'description', 'email', 'page_url', 'created_at', 'ip',)
65
    list_display_links = ('id', 'description')
66
    list_filter = (('id', TextInputFilter,), ScreenshotFilter, BlackboxFilter, SystemLogsFilter, AttachedFileFilter, 'created_at')
67
    form = FeedbackForm
68
    readonly_fields = ('created_at',)
69
70
    def get_queryset(self, request):
71
        qs = super(FeedbackDescriptionAdmin, self).get_queryset(request)
72
        return qs.exclude(description__startswith='BlackBox')
73