Skip to content

Commit c61d024

Browse files
committed
PEP8 fixes
1 parent 707c044 commit c61d024

54 files changed

Lines changed: 1136 additions & 718 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

demo_app/app/adminx.py

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
from xadmin.plugins.inline import Inline
77
from xadmin.plugins.batch import BatchChangeAction
88

9+
910
class 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
]
2123
xadmin.site.register(views.website.IndexView, MainDashboard)
2224

25+
2326
class BaseSetting(object):
2427
enable_themes = True
2528
use_bootswatch = True
2629
xadmin.site.register(views.BaseAdminView, BaseSetting)
2730

31+
2832
class GolbeSetting(object):
2933
globe_search_models = [Host, IDC]
3034
globe_models_icon = {
3135
Host: 'laptop', IDC: 'cloud'
3236
}
3337
xadmin.site.register(views.CommAdminView, GolbeSetting)
3438

39+
3540
class MaintainInline(object):
3641
model = MaintainLog
3742
extra = 1
3843
style = 'accordion'
3944

45+
4046
class 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+
5663
class 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+
110122
class 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+
117130
class 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+
144159
class 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

demo_app/app/models.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.db import models
22

3+
34
class IDC(models.Model):
45
name = models.CharField(max_length=64)
56
description = models.TextField()
@@ -8,12 +9,12 @@ class IDC(models.Model):
89
telphone = models.CharField(max_length=32)
910
address = models.CharField(max_length=128)
1011
customer_id = models.CharField(max_length=128)
11-
12+
1213
create_time = models.DateField(auto_now=True)
1314

1415
def __unicode__(self):
1516
return self.name
16-
17+
1718
class Meta:
1819
verbose_name = u"IDC"
1920
verbose_name_plural = verbose_name
@@ -35,6 +36,8 @@ class Meta:
3536
('email', u"Email"),
3637
('mix', u"Mix"),
3738
)
39+
40+
3841
class Host(models.Model):
3942

4043
idc = models.ForeignKey(IDC)
@@ -47,16 +50,16 @@ class Host(models.Model):
4750
ssh_port = models.IntegerField(blank=True, null=True)
4851
status = models.SmallIntegerField(choices=SERVER_STATUS)
4952

50-
brand = models.CharField(max_length=64, choices=[(i,i) for i in (u"DELL", u"HP", u"Other")])
53+
brand = models.CharField(max_length=64, choices=[(i, i) for i in (u"DELL", u"HP", u"Other")])
5154
model = models.CharField(max_length=64)
5255
cpu = models.CharField(max_length=64)
53-
core_num = models.SmallIntegerField(choices=[(i*2, "%s Cores" % (i*2)) for i in range(1,15)])
56+
core_num = models.SmallIntegerField(choices=[(i * 2, "%s Cores" % (i * 2)) for i in range(1, 15)])
5457
hard_disk = models.IntegerField()
5558
memory = models.IntegerField()
5659

57-
system = models.CharField(u"System OS", max_length=32, choices=[(i,i) for i in (u"CentOS", u"FreeBSD", u"Ubuntu")])
60+
system = models.CharField(u"System OS", max_length=32, choices=[(i, i) for i in (u"CentOS", u"FreeBSD", u"Ubuntu")])
5861
system_version = models.CharField(max_length=32)
59-
system_arch = models.CharField(max_length=32, choices=[(i,i) for i in (u"x86_64", u"i386")])
62+
system_arch = models.CharField(max_length=32, choices=[(i, i) for i in (u"x86_64", u"i386")])
6063

6164
create_time = models.DateField()
6265
guarantee_date = models.DateField()
@@ -65,11 +68,12 @@ class Host(models.Model):
6568

6669
def __unicode__(self):
6770
return self.name
68-
71+
6972
class Meta:
7073
verbose_name = u"Host"
7174
verbose_name_plural = verbose_name
7275

76+
7377
class MaintainLog(models.Model):
7478
host = models.ForeignKey(Host)
7579
maintain_type = models.CharField(max_length=32)
@@ -79,18 +83,20 @@ class MaintainLog(models.Model):
7983
note = models.TextField()
8084

8185
def __unicode__(self):
82-
return '%s maintain-log [%s] %s %s' % (self.host.name, self.time.strftime('%Y-%m-%d %H:%M:%S'), \
83-
self.maintain_type, self.hard_type)
84-
86+
return '%s maintain-log [%s] %s %s' % (self.host.name, self.time.strftime('%Y-%m-%d %H:%M:%S'),
87+
self.maintain_type, self.hard_type)
88+
8589
class Meta:
8690
verbose_name = u"Maintain Log"
8791
verbose_name_plural = verbose_name
8892

93+
8994
class HostGroup(models.Model):
9095

9196
name = models.CharField(max_length=32)
9297
description = models.TextField()
93-
hosts = models.ManyToManyField(Host, verbose_name=u'Hosts', blank=True, related_name='groups')
98+
hosts = models.ManyToManyField(
99+
Host, verbose_name=u'Hosts', blank=True, related_name='groups')
94100

95101
class Meta:
96102
verbose_name = u"Host Group"
@@ -99,6 +105,7 @@ class Meta:
99105
def __unicode__(self):
100106
return self.name
101107

108+
102109
class AccessRecord(models.Model):
103110
date = models.DateField()
104111
user_count = models.IntegerField()

demo_app/demo/settings.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import os.path
55

66
reload(sys)
7-
sys.setdefaultencoding('utf-8')
7+
sys.setdefaultencoding('utf-8')
88
gettext = lambda s: s
99

10-
PROJECT_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir)
10+
PROJECT_ROOT = os.path.join(
11+
os.path.realpath(os.path.dirname(__file__)), os.pardir)
1112

1213
DEBUG = True
1314
TEMPLATE_DEBUG = DEBUG
@@ -20,7 +21,7 @@
2021

2122
DATABASES = {
2223
'default': {
23-
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
24+
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
2425
'NAME': os.path.join(PROJECT_ROOT, 'data.db'), # Or path to database file if using sqlite3.
2526
'USER': '', # Not used with sqlite3.
2627
'PASSWORD': '', # Not used with sqlite3.
@@ -91,7 +92,7 @@
9192
STATICFILES_FINDERS = (
9293
'django.contrib.staticfiles.finders.FileSystemFinder',
9394
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
94-
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
95+
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
9596
)
9697

9798
# Make this unique, and don't share it with anybody.
@@ -101,7 +102,7 @@
101102
TEMPLATE_LOADERS = (
102103
'django.template.loaders.filesystem.Loader',
103104
'django.template.loaders.app_directories.Loader',
104-
# 'django.template.loaders.eggs.Loader',
105+
# 'django.template.loaders.eggs.Loader',
105106
)
106107

107108
MIDDLEWARE_CLASSES = (
@@ -136,7 +137,7 @@
136137
'xadmin',
137138
'crispy_forms',
138139
'reversion',
139-
140+
140141
'app',
141142
)
142143

@@ -163,7 +164,7 @@
163164
'filters': ['require_debug_false'],
164165
'class': 'django.utils.log.AdminEmailHandler'
165166
},
166-
'console':{
167+
'console': {
167168
'level': 'DEBUG',
168169
'class': 'logging.StreamHandler'
169170
},

demo_app/demo/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
xversion.registe_models()
99

1010
urlpatterns = patterns('',
11-
url(r'', include(xadmin.site.urls)),
12-
)
11+
url(r'', include(xadmin.site.urls)),
12+
)

demo_app/manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if __name__ == "__main__":
66
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
77
sys.path.insert(0, os.path.join(PROJECT_ROOT, os.pardir))
8-
8+
99
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
1010

1111
from django.core.management import execute_from_command_line

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
author_email='[email protected]',
1414
url='http://www.xadmin.io',
1515
download_url='http://github.com/sshwsfc/django-xadmin/archive/master.zip',
16-
packages=['xadmin', 'xadmin.plugins', 'xadmin.templatetags', 'xadmin.tests', 'xadmin.views'],
16+
packages=['xadmin', 'xadmin.plugins', 'xadmin.templatetags',
17+
'xadmin.tests', 'xadmin.views'],
1718
include_package_data=True,
1819
zip_safe=False,
1920
keywords=['admin', 'django', 'xadmin', 'bootstrap'],

xadmin/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from xadmin.sites import AdminSite, site
22

3-
VERSION = [0,1,0]
3+
VERSION = [0, 1, 0]
4+
45

56
def autodiscover():
67
"""
@@ -33,4 +34,4 @@ def autodiscover():
3334
# doesn't have an admin module, we can ignore the error
3435
# attempting to import it, otherwise we want it to bubble up.
3536
if module_has_submodule(mod, 'adminx'):
36-
raise
37+
raise

0 commit comments

Comments
 (0)