|
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 pyfreebilling.did.models import CustomerRatesDid, ProviderRatesDid |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class CustomerRatesDidAdmin(admin.ModelAdmin): |
|
23
|
|
|
list_display = ('id', |
|
24
|
|
|
'name', |
|
25
|
|
|
'enabled', |
|
26
|
|
|
'rate', |
|
27
|
|
|
'block_min_duration', |
|
28
|
|
|
'interval_duration', |
|
29
|
|
|
'date_modified') |
|
30
|
|
|
readonly_fields = ('date_added', 'date_modified') |
|
31
|
|
|
list_display_links = ('name',) |
|
32
|
|
|
ordering = ('name',) |
|
33
|
|
|
search_fields = ('name',) |
|
34
|
|
|
save_on_top = True |
|
35
|
|
|
|
|
36
|
|
|
def has_change_permission(self, request, obj=None): |
|
37
|
|
|
if request.user.is_superuser: |
|
38
|
|
|
return True |
|
39
|
|
|
else: |
|
40
|
|
|
return False |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
class ProviderRatesDidAdmin(admin.ModelAdmin): |
|
44
|
|
|
list_display = ('id', |
|
45
|
|
|
'name', |
|
46
|
|
|
'provider', |
|
47
|
|
|
'enabled', |
|
48
|
|
|
'rate', |
|
49
|
|
|
'block_min_duration', |
|
50
|
|
|
'interval_duration', |
|
51
|
|
|
'date_modified') |
|
52
|
|
|
readonly_fields = ('date_added', 'date_modified') |
|
53
|
|
|
list_filter = ('provider',) |
|
54
|
|
|
list_display_links = ('name',) |
|
55
|
|
|
ordering = ('provider', 'name') |
|
56
|
|
|
search_fields = ('provider', 'name') |
|
57
|
|
|
save_on_top = True |
|
58
|
|
|
|
|
59
|
|
|
def has_change_permission(self, request, obj=None): |
|
60
|
|
|
if request.user.is_superuser: |
|
61
|
|
|
return True |
|
62
|
|
|
else: |
|
63
|
|
|
return False |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
# ---------------------------------------- |
|
67
|
|
|
# register |
|
68
|
|
|
# ---------------------------------------- |
|
69
|
|
|
admin.site.register(CustomerRatesDid, CustomerRatesDidAdmin) |
|
70
|
|
|
admin.site.register(ProviderRatesDid, ProviderRatesDidAdmin) |
|
71
|
|
|
|