Permalink
Browse files

PEP8

Signed-off-by: Jason Myers <jason@jasonamyers.com>
  • Loading branch information...
1 parent 8eec2d9 commit 3f115776e1ffaf7b48976f88faf36c423e544d1d @jasonamyers jasonamyers committed Nov 2, 2013
@@ -58,6 +58,7 @@ class ArticleInline(admin.TabularInline):
})
)
+
class ChapterInline(admin.TabularInline):
model = Chapter
@@ -578,24 +579,30 @@ class AdminOrderedFieldAdmin(admin.ModelAdmin):
ordering = ('order',)
list_display = ('stuff', 'order')
+
class AdminOrderedModelMethodAdmin(admin.ModelAdmin):
ordering = ('order',)
list_display = ('stuff', 'some_order')
+
class AdminOrderedAdminMethodAdmin(admin.ModelAdmin):
def some_admin_order(self, obj):
return obj.order
some_admin_order.admin_order_field = 'order'
ordering = ('order',)
list_display = ('stuff', 'some_admin_order')
+
def admin_ordered_callable(obj):
return obj.order
admin_ordered_callable.admin_order_field = 'order'
+
+
class AdminOrderedCallableAdmin(admin.ModelAdmin):
ordering = ('order',)
list_display = ('stuff', admin_ordered_callable)
+
class ReportAdmin(admin.ModelAdmin):
def extra(self, request):
return HttpResponse()
@@ -612,6 +619,7 @@ def get_urls(self):
class CustomTemplateBooleanFieldListFilter(BooleanFieldListFilter):
template = 'custom_filter_template.html'
+
class CustomTemplateFilterColorAdmin(admin.ModelAdmin):
list_filter = (('warm', CustomTemplateBooleanFieldListFilter),)
@@ -628,12 +636,14 @@ class RelatedPrepopulatedInline1(admin.StackedInline):
prepopulated_fields = {'slug1': ['name', 'pubdate'],
'slug2': ['status', 'name']}
+
class RelatedPrepopulatedInline2(admin.TabularInline):
model = RelatedPrepopulated
extra = 1
prepopulated_fields = {'slug1': ['name', 'pubdate'],
'slug2': ['status', 'name']}
+
class MainPrepopulatedAdmin(admin.ModelAdmin):
inlines = [RelatedPrepopulatedInline1, RelatedPrepopulatedInline2]
fieldsets = (
@@ -712,14 +722,17 @@ class FormWithoutHiddenField(forms.ModelForm):
first = forms.CharField()
second = forms.CharField()
+
class FormWithoutVisibleField(forms.ModelForm):
first = forms.CharField(widget=forms.HiddenInput)
second = forms.CharField(widget=forms.HiddenInput)
+
class FormWithVisibleAndHiddenField(forms.ModelForm):
first = forms.CharField(widget=forms.HiddenInput)
second = forms.CharField()
+
class EmptyModelVisibleAdmin(admin.ModelAdmin):
form = FormWithoutHiddenField
fieldsets = (
@@ -728,39 +741,48 @@ class EmptyModelVisibleAdmin(admin.ModelAdmin):
}),
)
+
class EmptyModelHiddenAdmin(admin.ModelAdmin):
form = FormWithoutVisibleField
fieldsets = EmptyModelVisibleAdmin.fieldsets
+
class EmptyModelMixinAdmin(admin.ModelAdmin):
form = FormWithVisibleAndHiddenField
fieldsets = EmptyModelVisibleAdmin.fieldsets
+
class CityInlineAdmin(admin.TabularInline):
model = City
view_on_site = False
+
class StateAdmin(admin.ModelAdmin):
inlines = [CityInlineAdmin]
+
class RestaurantInlineAdmin(admin.TabularInline):
model = Restaurant
view_on_site = True
+
class CityAdmin(admin.ModelAdmin):
inlines = [RestaurantInlineAdmin]
view_on_site = True
+
class WorkerAdmin(admin.ModelAdmin):
def view_on_site(self, obj):
return '/worker/%s/%s/' % (obj.surname, obj.name)
+
class WorkerInlineAdmin(admin.TabularInline):
model = Worker
def view_on_site(self, obj):
return '/worker_inline/%s/%s/' % (obj.surname, obj.name)
+
class RestaurantAdmin(admin.ModelAdmin):
inlines = [WorkerInlineAdmin]
view_on_site = False
@@ -44,7 +44,7 @@ def _inner(*args, **kwargs):
vary_on_cookie,
# django.views.decorators.cache
- cache_page(60*15),
+ cache_page(60 * 15),
cache_control(private=True),
never_cache,
@@ -65,6 +65,7 @@ def _inner(*args, **kwargs):
fully_decorated = full_decorator(fully_decorated)
+
class DecoratorsTest(TestCase):
def test_attributes(self):
@@ -10,6 +10,7 @@ class Secondary(models.Model):
first = models.CharField(max_length=50)
second = models.CharField(max_length=50)
+
@python_2_unicode_compatible
class Primary(models.Model):
name = models.CharField(max_length=50)
@@ -19,12 +20,15 @@ class Primary(models.Model):
def __str__(self):
return self.name
+
class Child(Primary):
pass
+
class BigChild(Primary):
other = models.CharField(max_length=50)
+
class ChildProxy(Child):
class Meta:
proxy = True
@@ -16,13 +16,16 @@ class Item(models.Model):
def __str__(self):
return self.name
+
class RelatedItem(models.Model):
item = models.ForeignKey(Item)
+
class Child(models.Model):
name = models.CharField(max_length=10)
value = models.IntegerField()
+
@python_2_unicode_compatible
class Leaf(models.Model):
name = models.CharField(max_length=10)
@@ -33,14 +36,17 @@ class Leaf(models.Model):
def __str__(self):
return self.name
+
class ResolveThis(models.Model):
num = models.FloatField()
name = models.CharField(max_length=16)
+
class Proxy(Item):
class Meta:
proxy = True
+
@python_2_unicode_compatible
class SimpleItem(models.Model):
name = models.CharField(max_length=15)
@@ -49,29 +55,37 @@ class SimpleItem(models.Model):
def __str__(self):
return self.name
+
class Feature(models.Model):
item = models.ForeignKey(SimpleItem)
+
class SpecialFeature(models.Model):
feature = models.ForeignKey(Feature)
+
class OneToOneItem(models.Model):
item = models.OneToOneField(Item, related_name="one_to_one_item")
name = models.CharField(max_length=15)
+
class ItemAndSimpleItem(models.Model):
item = models.ForeignKey(Item)
simple = models.ForeignKey(SimpleItem)
+
class Profile(models.Model):
profile1 = models.CharField(max_length=1000, default='profile1')
+
class Location(models.Model):
location1 = models.CharField(max_length=1000, default='location1')
+
class Item(models.Model):
pass
+
class Request(models.Model):
profile = models.ForeignKey(Profile, null=True, blank=True)
location = models.ForeignKey(Location)
@@ -185,6 +185,7 @@ class Meta:
model = BetterWriter
fields = '__all__'
+
class WriterProfileForm(forms.ModelForm):
class Meta:
model = WriterProfile
@@ -234,6 +235,7 @@ class Meta:
# model forms for testing work on #9321:
+
class StatusNoteForm(forms.ModelForm):
class Meta:
model = ArticleStatusNote
@@ -295,7 +297,7 @@ class Meta:
fields = '__all__'
self.assertIsInstance(ReplaceField.base_fields['url'],
- forms.fields.BooleanField)
+ forms.fields.BooleanField)
def test_replace_field_variant_2(self):
# Should have the same result as before,
@@ -308,7 +310,7 @@ class Meta:
fields = ['url']
self.assertIsInstance(ReplaceField.base_fields['url'],
- forms.fields.BooleanField)
+ forms.fields.BooleanField)
def test_replace_field_variant_3(self):
# Should have the same result as before,
@@ -321,7 +323,7 @@ class Meta:
fields = [] # url will still appear, since it is explicit above
self.assertIsInstance(ReplaceField.base_fields['url'],
- forms.fields.BooleanField)
+ forms.fields.BooleanField)
def test_override_field(self):
class WriterForm(forms.ModelForm):
@@ -583,6 +585,7 @@ class Meta:
fields = ('name', 'slug')
model = Category
+
class IncompleteCategoryFormWithExclude(forms.ModelForm):
"""
A form that replaces the model's url field with a custom one. This should
@@ -788,6 +791,7 @@ def test_unique_for_date_with_nullable_date(self):
"slug": "Django 1.0"}, instance=p)
self.assertTrue(form.is_valid())
+
class ModelToDictTests(TestCase):
"""
Tests for forms.models.model_to_dict
@@ -824,6 +828,7 @@ def test_model_to_dict_many_to_many(self):
# Ensure many-to-many relation appears as a list
self.assertIsInstance(d['categories'], list)
+
class OldFormForXTests(TestCase):
def test_base_form(self):
self.assertEqual(Category.objects.count(), 0)
@@ -11,6 +11,7 @@
class Person(models.Model):
name = models.CharField(max_length=100)
+
class Triple(models.Model):
left = models.IntegerField()
middle = models.IntegerField()
@@ -19,9 +20,11 @@ class Triple(models.Model):
class Meta:
unique_together = (('left', 'middle'), ('middle', 'right'))
+
class FilePathModel(models.Model):
path = models.FilePathField(path=os.path.dirname(upath(__file__)), match=".*\.py$", blank=True)
+
@python_2_unicode_compatible
class Publication(models.Model):
title = models.CharField(max_length=30)
@@ -30,6 +33,7 @@ class Publication(models.Model):
def __str__(self):
return self.title
+
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
@@ -38,36 +42,44 @@ class Article(models.Model):
def __str__(self):
return self.headline
+
class CustomFileField(models.FileField):
def save_form_data(self, instance, data):
been_here = getattr(self, 'been_saved', False)
assert not been_here, "save_form_data called more than once"
setattr(self, 'been_saved', True)
+
class CustomFF(models.Model):
f = CustomFileField(upload_to='unused', blank=True)
+
class RealPerson(models.Model):
name = models.CharField(max_length=100)
def clean(self):
if self.name.lower() == 'anonymous':
raise ValidationError("Please specify a real name.")
+
class Author(models.Model):
publication = models.OneToOneField(Publication, null=True, blank=True)
full_name = models.CharField(max_length=255)
+
class Author1(models.Model):
publication = models.OneToOneField(Publication, null=False)
full_name = models.CharField(max_length=255)
+
class Homepage(models.Model):
url = models.URLField()
+
class Document(models.Model):
myfile = models.FileField(upload_to='unused', blank=True)
+
class Edition(models.Model):
author = models.ForeignKey(Person)
publication = models.ForeignKey(Publication)
Oops, something went wrong.

0 comments on commit 3f11577

Please sign in to comment.