summaryrefslogtreecommitdiff
path: root/tests/foreign_object
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-09-20 17:51:25 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-09-21 22:20:42 +0200
commite542e81b39e8610b70cf1d68f95ece0279028765 (patch)
tree92da80cf497dbab79d05d5ec050927bfe107c153 /tests/foreign_object
parent2409a4241a07bcdb1be4f3c99bf1aacc87189ebf (diff)
downloaddjango-e542e81b39e8610b70cf1d68f95ece0279028765.tar.gz
Renamed descriptor classes for related objects.
The old names were downright confusing. Some seemed to mean the opposite of what the class actually did. The new names follow a consistent nomenclature: (Forward|Reverse)(ManyToOne|OneToOne|ManyToMany)Descriptor. I mentioned combinations that do not exist in the docstring in order to help people who would search for them in the code base.
Diffstat (limited to 'tests/foreign_object')
-rw-r--r--tests/foreign_object/models/article.py5
-rw-r--r--tests/foreign_object/models/empty_join.py10
2 files changed, 7 insertions, 8 deletions
diff --git a/tests/foreign_object/models/article.py b/tests/foreign_object/models/article.py
index f9e6f1fca4..f0c2f3fbac 100644
--- a/tests/foreign_object/models/article.py
+++ b/tests/foreign_object/models/article.py
@@ -1,11 +1,10 @@
from django.db import models
-from django.db.models.fields.related import \
- ReverseSingleRelatedObjectDescriptor
+from django.db.models.fields.related import ForwardManyToOneDescriptor
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language
-class ArticleTranslationDescriptor(ReverseSingleRelatedObjectDescriptor):
+class ArticleTranslationDescriptor(ForwardManyToOneDescriptor):
"""
The set of articletranslation should not set any local fields.
"""
diff --git a/tests/foreign_object/models/empty_join.py b/tests/foreign_object/models/empty_join.py
index 3bf121bf39..b8b05ea1c2 100644
--- a/tests/foreign_object/models/empty_join.py
+++ b/tests/foreign_object/models/empty_join.py
@@ -1,6 +1,6 @@
from django.db import models
from django.db.models.fields.related import (
- ForeignObjectRel, ForeignRelatedObjectsDescriptor,
+ ForeignObjectRel, ReverseManyToOneDescriptor,
)
from django.db.models.lookups import StartsWith
from django.db.models.query_utils import PathInfo
@@ -10,7 +10,7 @@ from django.utils.encoding import python_2_unicode_compatible
class CustomForeignObjectRel(ForeignObjectRel):
"""
Define some extra Field methods so this Rel acts more like a Field, which
- lets us use ForeignRelatedObjectsDescriptor in both directions.
+ lets us use ReverseManyToOneDescriptor in both directions.
"""
@property
def foreign_related_fields(self):
@@ -24,7 +24,7 @@ class StartsWithRelation(models.ForeignObject):
"""
A ForeignObject that uses StartsWith operator in its joins instead of
the default equality operator. This is logically a many-to-many relation
- and creates a ForeignRelatedObjectsDescriptor in both directions.
+ and creates a ReverseManyToOneDescriptor in both directions.
"""
auto_created = False
@@ -42,7 +42,7 @@ class StartsWithRelation(models.ForeignObject):
@property
def field(self):
"""
- Makes ForeignRelatedObjectsDescriptor work in both directions.
+ Makes ReverseManyToOneDescriptor work in both directions.
"""
return self.remote_field
@@ -66,7 +66,7 @@ class StartsWithRelation(models.ForeignObject):
def contribute_to_class(self, cls, name, virtual_only=False):
super(StartsWithRelation, self).contribute_to_class(cls, name, virtual_only)
- setattr(cls, self.name, ForeignRelatedObjectsDescriptor(self))
+ setattr(cls, self.name, ReverseManyToOneDescriptor(self))
class BrokenContainsRelation(StartsWithRelation):