1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# Copyright 2013 Mathias WOLFF |
3
|
|
|
# This file is part of pyfreebilling. |
4
|
|
|
# |
5
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
6
|
|
|
# it under the terms of the GNU General Public License as published by |
7
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
# (at your option) any later version. |
9
|
|
|
# |
10
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
11
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
# GNU General Public License for more details. |
14
|
|
|
# |
15
|
|
|
# You should have received a copy of the GNU General Public License |
16
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
17
|
|
|
|
18
|
|
|
from django.contrib import admin, messages |
19
|
|
|
from django.template import Context, loader |
20
|
|
|
from django.utils.safestring import mark_safe |
21
|
|
|
from django.utils.translation import ugettext_lazy as _ |
22
|
|
|
|
23
|
|
|
from .models import Pdau, Caau, UrgencyNumber, InseeCityCode |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
class InseeCityCodeAdmin(admin.ModelAdmin): |
27
|
|
|
search_fields = ['^insee_code', '^city'] |
28
|
|
|
|
29
|
|
|
def has_change_permission(self, request, obj=None): |
30
|
|
|
if request.user.is_superuser: |
31
|
|
|
return True |
32
|
|
|
else: |
33
|
|
|
return False |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
class UrgencyNumberAdmin(admin.ModelAdmin): |
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 CaauAdmin(admin.ModelAdmin): |
46
|
|
|
search_fields = ['^caau_code', ] |
47
|
|
|
|
48
|
|
|
def has_change_permission(self, request, obj=None): |
49
|
|
|
if request.user.is_superuser: |
50
|
|
|
return True |
51
|
|
|
else: |
52
|
|
|
return False |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
class PdauAdmin(admin.ModelAdmin): |
56
|
|
|
list_filter = ('urgencynumber', 'caau') |
57
|
|
|
search_fields = ['^caau__caau_code', 'insee_code__insee_code', ] |
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
|
|
|
admin.site.register(InseeCityCode, InseeCityCodeAdmin) |
66
|
|
|
admin.site.register(UrgencyNumber, UrgencyNumberAdmin) |
67
|
|
|
admin.site.register(Caau, CaauAdmin) |
68
|
|
|
admin.site.register(Pdau, PdauAdmin) |
69
|
|
|
|