|
1
|
|
|
# coding: utf-8 |
|
2
|
|
|
from dj_diabetes.forms import AppointmentTypesAdminForm, FoodsAdminForm |
|
3
|
|
|
from dj_diabetes.forms import PrefAdminForm |
|
4
|
|
|
from dj_diabetes.forms import SportsAdminForm, ExaminationTypesAdminForm |
|
5
|
|
|
from dj_diabetes.models import UserProfile, Preferences |
|
6
|
|
|
from dj_diabetes.models.appointments import AppointmentTypes |
|
7
|
|
|
from dj_diabetes.models.exams import ExaminationTypes |
|
8
|
|
|
from dj_diabetes.models.foods import Foods |
|
9
|
|
|
from dj_diabetes.models.sports import Sports |
|
10
|
|
|
|
|
11
|
|
|
from django.contrib import admin |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class DiabetesAdminMixin(object): |
|
15
|
|
|
list_display = ('title', 'created', 'modified') |
|
16
|
|
|
|
|
17
|
|
|
def get_form(self, request, obj=None, **args): |
|
18
|
|
|
defaults = {} |
|
19
|
|
|
if obj is None: |
|
20
|
|
|
defaults.update({'form': self.add_form, }) |
|
21
|
|
|
else: |
|
22
|
|
|
defaults.update({'form': self.view_form, }) |
|
23
|
|
|
defaults.update(args) |
|
24
|
|
|
return super(DiabetesAdminMixin, self).get_form(request, obj, |
|
25
|
|
|
**defaults) |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class SportsAdmin(DiabetesAdminMixin, admin.ModelAdmin): |
|
29
|
|
|
|
|
30
|
|
|
""" |
|
31
|
|
|
get the list of the sports |
|
32
|
|
|
""" |
|
33
|
|
|
add_form = SportsAdminForm |
|
34
|
|
|
view_form = SportsAdminForm |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
class FoodsAdmin(DiabetesAdminMixin, admin.ModelAdmin): |
|
38
|
|
|
|
|
39
|
|
|
""" |
|
40
|
|
|
get the list of the Foods |
|
41
|
|
|
""" |
|
42
|
|
|
add_form = FoodsAdminForm |
|
43
|
|
|
view_form = FoodsAdminForm |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
class ExaminationTypesAdmin(DiabetesAdminMixin, admin.ModelAdmin): |
|
47
|
|
|
|
|
48
|
|
|
""" |
|
49
|
|
|
get the list of the examination types |
|
50
|
|
|
""" |
|
51
|
|
|
|
|
52
|
|
|
add_form = ExaminationTypesAdminForm |
|
53
|
|
|
view_form = ExaminationTypesAdminForm |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
class AppointmentTypesAdmin(DiabetesAdminMixin, admin.ModelAdmin): |
|
57
|
|
|
|
|
58
|
|
|
""" |
|
59
|
|
|
get the list of the appointment types |
|
60
|
|
|
""" |
|
61
|
|
|
|
|
62
|
|
|
add_form = AppointmentTypesAdminForm |
|
63
|
|
|
view_form = AppointmentTypesAdminForm |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
class PrefAdmin(DiabetesAdminMixin, admin.ModelAdmin): |
|
67
|
|
|
|
|
68
|
|
|
list_display = ('key', 'title', 'value', 'created', 'modified') |
|
69
|
|
|
|
|
70
|
|
|
add_form = PrefAdminForm |
|
71
|
|
|
view_form = PrefAdminForm |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
class UserProfileAdmin(admin.ModelAdmin): |
|
75
|
|
|
|
|
76
|
|
|
list_display = ('user', 'name',) |
|
77
|
|
|
list_filter = ['user', 'name'] |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
admin.site.register(Sports, SportsAdmin) |
|
81
|
|
|
admin.site.register(Foods, FoodsAdmin) |
|
82
|
|
|
admin.site.register(UserProfile, UserProfileAdmin) |
|
83
|
|
|
admin.site.register(AppointmentTypes, AppointmentTypesAdmin) |
|
84
|
|
|
admin.site.register(ExaminationTypes, ExaminationTypesAdmin) |
|
85
|
|
|
admin.site.register(Preferences, PrefAdmin) |
|
86
|
|
|
|