diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-31 08:42:28 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-31 08:42:28 -0700 |
| commit | 726ded5708e4e8767e69a6f6f6a039e75667ce03 (patch) | |
| tree | f692a4abede11f50830f6935c086676f3f1db778 /django/contrib/contenttypes | |
| parent | a023a84c060eaaa4cf520c33d9c73adab7af3d30 (diff) | |
Started attackign the next flake8 violation
Diffstat (limited to 'django/contrib/contenttypes')
| -rw-r--r-- | django/contrib/contenttypes/generic.py | 8 | ||||
| -rw-r--r-- | django/contrib/contenttypes/models.py | 1 | ||||
| -rw-r--r-- | django/contrib/contenttypes/tests.py | 5 | ||||
| -rw-r--r-- | django/contrib/contenttypes/views.py | 1 |
4 files changed, 13 insertions, 2 deletions
diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index 950211f6c4..10d3f7d4a5 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -154,6 +154,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)): setattr(instance, self.fk_field, fk) setattr(instance, self.cache_attr, value) + class GenericRelation(ForeignObject): """Provides an accessor to generic related objects (e.g. comments)""" @@ -293,6 +294,7 @@ class ReverseGenericRelatedObjectsDescriptor(object): for obj in value: manager.add(obj) + def create_generic_related_manager(superclass): """ Factory function for a manager that subclasses 'superclass' (which is a @@ -390,11 +392,12 @@ def create_generic_related_manager(superclass): return GenericRelatedObjectManager -class GenericRel(ForeignObjectRel): +class GenericRel(ForeignObjectRel): def __init__(self, field, to, related_name=None, limit_choices_to=None): super(GenericRel, self).__init__(field, to, related_name, limit_choices_to) + class BaseGenericInlineFormSet(BaseModelFormSet): """ A formset for generic inline objects to a parent. @@ -475,6 +478,7 @@ def generic_inlineformset_factory(model, form=ModelForm, FormSet.for_concrete_model = for_concrete_model return FormSet + class GenericInlineModelAdmin(InlineModelAdmin): ct_field = "content_type" ct_fk_field = "object_id" @@ -516,8 +520,10 @@ class GenericInlineModelAdmin(InlineModelAdmin): return generic_inlineformset_factory(self.model, **defaults) + class GenericStackedInline(GenericInlineModelAdmin): template = 'admin/edit_inline/stacked.html' + class GenericTabularInline(GenericInlineModelAdmin): template = 'admin/edit_inline/tabular.html' diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 34d54441fe..75859bfa16 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_text, force_text from django.utils.encoding import python_2_unicode_compatible + class ContentTypeManager(models.Manager): # Cache to avoid re-looking up ContentType objects all over the place. diff --git a/django/contrib/contenttypes/tests.py b/django/contrib/contenttypes/tests.py index 3f648bd456..b73307d85f 100644 --- a/django/contrib/contenttypes/tests.py +++ b/django/contrib/contenttypes/tests.py @@ -15,10 +15,12 @@ from django.utils.encoding import python_2_unicode_compatible class ConcreteModel(models.Model): name = models.CharField(max_length=10) + class ProxyModel(ConcreteModel): class Meta: proxy = True + @python_2_unicode_compatible class FooWithoutUrl(models.Model): """ @@ -39,6 +41,7 @@ class FooWithUrl(FooWithoutUrl): def get_absolute_url(self): return "/users/%s/" % urlquote(self.name) + class FooWithBrokenAbsoluteUrl(FooWithoutUrl): """ Fake model defining a ``get_absolute_url`` method containing an error @@ -47,8 +50,8 @@ class FooWithBrokenAbsoluteUrl(FooWithoutUrl): def get_absolute_url(self): return "/users/%s/" % self.unknown_field -class ContentTypesTests(TestCase): +class ContentTypesTests(TestCase): def setUp(self): self.old_Site_meta_installed = Site._meta.installed ContentType.objects.clear_cache() diff --git a/django/contrib/contenttypes/views.py b/django/contrib/contenttypes/views.py index d2dc48ea08..7318cf4203 100644 --- a/django/contrib/contenttypes/views.py +++ b/django/contrib/contenttypes/views.py @@ -6,6 +6,7 @@ from django.contrib.sites.models import Site, get_current_site from django.core.exceptions import ObjectDoesNotExist from django.utils.translation import ugettext as _ + def shortcut(request, content_type_id, object_id): """ Redirect to an object's page based on a content-type ID and an object ID. |
