66from xadmin .plugins .inline import Inline
77from xadmin .plugins .batch import BatchChangeAction
88
9+
910class MainDashboard (object ):
1011 widgets = [
1112 [
1213 {"type" : "html" , "title" : "Test Widget" , "content" : "<h3> Welcome to Xadmin! </h3><p>Join Online Group: <br/>QQ Qun : 282936295</p>" },
1314 {"type" : "chart" , "model" : "app.accessrecord" , 'chart' : 'user_count' , 'params' : {'_p_date__gte' : '2013-01-08' , 'p' : 1 , '_p_date__lt' : '2013-01-29' }},
14- {"type" : "list" , "model" : "app.host" , 'params' : {'o' :'-guarantee_date' }},
15+ {"type" : "list" , "model" : "app.host" , 'params' : {
16+ 'o' :'-guarantee_date' }},
1517 ],
1618 [
1719 {"type" : "qbutton" , "title" : "Quick Start" , "btns" : [{'model' : Host }, {'model' :IDC }, {'title' : "Google" , 'url' : "http://www.google.com" }]},
@@ -20,130 +22,143 @@ class MainDashboard(object):
2022 ]
2123xadmin .site .register (views .website .IndexView , MainDashboard )
2224
25+
2326class BaseSetting (object ):
2427 enable_themes = True
2528 use_bootswatch = True
2629xadmin .site .register (views .BaseAdminView , BaseSetting )
2730
31+
2832class GolbeSetting (object ):
2933 globe_search_models = [Host , IDC ]
3034 globe_models_icon = {
3135 Host : 'laptop' , IDC : 'cloud'
3236 }
3337xadmin .site .register (views .CommAdminView , GolbeSetting )
3438
39+
3540class MaintainInline (object ):
3641 model = MaintainLog
3742 extra = 1
3843 style = 'accordion'
3944
45+
4046class IDCAdmin (object ):
4147 list_display = ('name' , 'description' , 'create_time' )
4248 list_display_links = ('name' ,)
4349 wizard_form_list = [
44- ('Frist \' s Form' , ('name' , 'description' )),
45- ('Seocnd Form' , ('contact' , 'telphone' , 'address' )),
50+ ('First \' s Form' , ('name' , 'description' )),
51+ ('Second Form' , ('contact' , 'telphone' , 'address' )),
4652 ('Thread Form' , ('customer_id' ,))
4753 ]
4854
4955 search_fields = ['name' ]
5056 relfield_style = 'fk-ajax'
5157 reversion_enable = True
5258
53- actions = [BatchChangeAction ,]
59+ actions = [BatchChangeAction , ]
5460 batch_fields = ('contact' , 'create_time' )
55-
61+
62+
5663class HostAdmin (object ):
5764 def open_web (self , instance ):
5865 return "<a href='http://%s' target='_blank'>Open</a>" % instance .ip
5966 open_web .short_description = "Acts"
6067 open_web .allow_tags = True
6168 open_web .is_column = True
6269
63- list_display = ('name' , 'idc' , 'guarantee_date' , 'service_type' , 'status' , 'open_web' , 'description' )
70+ list_display = ('name' , 'idc' , 'guarantee_date' , 'service_type' ,
71+ 'status' , 'open_web' , 'description' )
6472 list_display_links = ('name' ,)
6573
6674 raw_id_fields = ('idc' ,)
6775 style_fields = {'system' : "radio-inline" }
6876
6977 search_fields = ['name' , 'ip' , 'description' ]
70- list_filter = ['idc' , 'guarantee_date' , 'status' , 'brand' , 'model' , 'cpu' , 'core_num' , 'hard_disk' , 'memory' , 'service_type' ]
78+ list_filter = ['idc' , 'guarantee_date' , 'status' , 'brand' , 'model' ,
79+ 'cpu' , 'core_num' , 'hard_disk' , 'memory' , 'service_type' ]
7180
7281 list_bookmarks = [{'title' : "Need Guarantee" , 'query' : {'status__exact' : 2 }, 'order' : ('-guarantee_date' ,), 'cols' : ('brand' , 'guarantee_date' , 'service_type' )}]
7382
7483 show_detail_fields = ('idc' ,)
75- list_editable = ('name' , 'idc' , 'guarantee_date' , 'service_type' , 'description' )
84+ list_editable = (
85+ 'name' , 'idc' , 'guarantee_date' , 'service_type' , 'description' )
7686 save_as = True
77-
87+
7888 aggregate_fields = {"guarantee_date" : "min" }
7989
8090 form_layout = (
8191 Main (
8292 TabHolder (
8393 Tab ('Comm Fiels' ,
8494 Fieldset ('Company data' ,
85- 'name' , 'idc' ,
86- description = "some comm fields, required"
87- ),
95+ 'name' , 'idc' ,
96+ description = "some comm fields, required"
97+ ),
8898 Inline (MaintainLog ),
89- ),
99+ ),
90100 Tab ('Extend Fiedls' ,
91101 Fieldset ('Contact details' ,
92- 'service_type' ,
93- Row ('brand' , 'model' ),
94- Row ('cpu' , 'core_num' ),
95- Row (AppendedText ('hard_disk' , 'G' ), AppendedText ('memory' , "G" )),
96- 'guarantee_date'
102+ 'service_type' ,
103+ Row ('brand' , 'model' ),
104+ Row ('cpu' , 'core_num' ),
105+ Row (AppendedText (
106+ 'hard_disk' , 'G' ), AppendedText ('memory' , "G" )),
107+ 'guarantee_date'
108+ ),
97109 ),
98- ),
99110 ),
100111 ),
101112 Side (
102113 Fieldset ('Status data' ,
103- 'status' , 'ssh_port' , 'ip'
104- ),
114+ 'status' , 'ssh_port' , 'ip'
115+ ),
105116 )
106117 )
107118 inlines = [MaintainInline ]
108119 reversion_enable = True
109-
120+
121+
110122class HostGroupAdmin (object ):
111123 list_display = ('name' , 'description' )
112124 list_display_links = ('name' ,)
113125
114126 search_fields = ['name' ]
115127 style_fields = {'hosts' : 'checkbox-inline' }
116128
129+
117130class MaintainLogAdmin (object ):
118- list_display = ('host' , 'maintain_type' , 'hard_type' , 'time' , 'operator' , 'note' )
131+ list_display = (
132+ 'host' , 'maintain_type' , 'hard_type' , 'time' , 'operator' , 'note' )
119133 list_display_links = ('host' ,)
120134
121135 list_filter = ['host' , 'maintain_type' , 'hard_type' , 'time' , 'operator' ]
122136 search_fields = ['note' ]
123137
124138 form_layout = (
125- Col ("col2" ,
139+ Col ("col2" ,
126140 Fieldset ('Record data' ,
127- 'time' , 'note' ,
128- css_class = 'unsort short_label no_title'
129- ),
141+ 'time' , 'note' ,
142+ css_class = 'unsort short_label no_title'
143+ ),
130144 span = 9 , horizontal = True
131- ),
145+ ),
132146 Col ("col1" ,
133147 Fieldset ('Comm data' ,
134- 'host' , 'maintain_type'
135- ),
148+ 'host' , 'maintain_type'
149+ ),
136150 Fieldset ('Maintain details' ,
137- 'hard_type' , 'operator'
138- ),
151+ 'hard_type' , 'operator'
152+ ),
139153 span = 3
140- )
154+ )
141155 )
142156 reversion_enable = True
143157
158+
144159class AccessRecordAdmin (object ):
145160 def avg_count (self , instance ):
146- return int (instance .view_count / instance .user_count )
161+ return int (instance .view_count / instance .user_count )
147162 avg_count .short_description = "Avg Count"
148163 avg_count .allow_tags = True
149164 avg_count .is_column = True
0 commit comments