Completed
Push — master ( da0207...5a5796 )
by Mathias
01:37
created

CustomerRatesDidAdmin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %
Metric Value
wmc 2
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A has_change_permission() 0 5 2
1
# Copyright 2013 Mathias WOLFF
2
# This file is part of pyfreebilling.
3
#
4
# pyfreebilling is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# pyfreebilling is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with pyfreebilling.  If not, see <http://www.gnu.org/licenses/>
16
17
from django.contrib import admin
18
19
from yawdadmin import admin_site
20
21
from did.models import CustomerRatesDid, ProviderRatesDid
22
23
24
class CustomerRatesDidAdmin(admin.ModelAdmin):
25
    list_display = ('id',
26
                    'name',
27
                    'enabled',
28
                    'rate',
29
                    'block_min_duration',
30
                    'interval_duration',
31
                    'date_modified')
32
    readonly_fields = ('date_added', 'date_modified')
33
    list_display_links = ('name',)
34
    ordering = ('name',)
35
    search_fields = ('name',)
36
    save_on_top = True
37
38
    def has_change_permission(self, request, obj=None):
39
        if request.user.is_superuser:
40
            return True
41
        else:
42
            return False
43
44
45
class ProviderRatesDidAdmin(admin.ModelAdmin):
46
    list_display = ('id',
47
                    'name',
48
                    'provider',
49
                    'enabled',
50
                    'rate',
51
                    'block_min_duration',
52
                    'interval_duration',
53
                    'date_modified')
54
    readonly_fields = ('date_added', 'date_modified')
55
    list_filter = ('provider',)
56
    list_display_links = ('name',)
57
    ordering = ('provider', 'name')
58
    search_fields = ('provider', 'name')
59
    save_on_top = True
60
61
    def has_change_permission(self, request, obj=None):
62
        if request.user.is_superuser:
63
            return True
64
        else:
65
            return False
66
67
#----------------------------------------
68
# register
69
#----------------------------------------
70
admin_site.register(CustomerRatesDid, CustomerRatesDidAdmin)
71
admin_site.register(ProviderRatesDid, ProviderRatesDidAdmin)
72