mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
magic-removal: More small code cleanups
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1727 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fc27500389
commit
5907e9337f
@ -1,10 +1,9 @@
|
||||
from django.db.models import signals
|
||||
from django.db.models.fields import Field, IntegerField
|
||||
from django.db.models.related import RelatedObject
|
||||
from django.utils.translation import gettext_lazy, string_concat
|
||||
from django.utils.functional import curry
|
||||
from django.core import formfields
|
||||
from django.db.models import signals
|
||||
|
||||
from django.dispatch import dispatcher
|
||||
|
||||
# Values for Relation.edit_inline.
|
||||
@ -21,7 +20,6 @@ class RelatedField(object):
|
||||
signal = signals.class_prepared,
|
||||
weak = False)
|
||||
|
||||
|
||||
def add_lookup(cls, rel_cls, field):
|
||||
name = field.rel.to
|
||||
module = rel_cls.__module__
|
||||
@ -31,12 +29,11 @@ class RelatedField(object):
|
||||
|
||||
def do_pending_lookups(cls, other_cls):
|
||||
key = (other_cls.__module__, other_cls.__name__)
|
||||
for (rel_cls,field) in cls.pending_lookups.setdefault(key,[]):
|
||||
for rel_cls, field in cls.pending_lookups.setdefault(key,[]):
|
||||
field.rel.to = other_cls
|
||||
field.do_related_class(other_cls, rel_cls)
|
||||
do_pending_lookups = classmethod(do_pending_lookups)
|
||||
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
sup = super(RelatedField, self)
|
||||
if hasattr(sup, 'contribute_to_class'):
|
||||
@ -59,7 +56,6 @@ class RelatedField(object):
|
||||
related = RelatedObject(other._meta, cls, self)
|
||||
self.contribute_to_related_class(other, related)
|
||||
|
||||
|
||||
#HACK
|
||||
class SharedMethods(RelatedField):
|
||||
def get_attname(self):
|
||||
@ -173,7 +169,6 @@ class ForeignKey(SharedMethods,Field):
|
||||
func = lambda self, *args, **kwargs: self._add_related(related.model, related.field, *args, **kwargs)
|
||||
setattr(cls, 'add_%s' % rel_obj_name, func)
|
||||
|
||||
|
||||
class OneToOneField(SharedMethods, IntegerField):
|
||||
def __init__(self, to, to_field=None, **kwargs):
|
||||
kwargs['verbose_name'] = kwargs.get('verbose_name', 'ID')
|
||||
@ -339,8 +334,6 @@ class ManyToManyFieldNew(RelatedField):
|
||||
M2M._meta.unique_together = ((id_to, id_from),)
|
||||
M2M.__name__ = "M2M_%s_%s_%s" % (self.name, self.from_.__name__, self.to.__name__)
|
||||
|
||||
|
||||
|
||||
class ManyToOne:
|
||||
def __init__(self, to, field_name, num_in_admin=3, min_num_in_admin=None,
|
||||
max_num_in_admin=None, num_extra_on_change=1, edit_inline=False,
|
||||
@ -372,7 +365,6 @@ class OneToOne(ManyToOne):
|
||||
self.lookup_overrides = lookup_overrides or {}
|
||||
self.raw_id_admin = raw_id_admin
|
||||
|
||||
|
||||
class ManyToMany:
|
||||
def __init__(self, to, singular=None, num_in_admin=0, related_name=None,
|
||||
filter_interface=None, limit_choices_to=None, raw_id_admin=False):
|
||||
|
@ -39,14 +39,12 @@ class ManipulatorDescriptor(object):
|
||||
return self.man
|
||||
|
||||
def get_base_manipulator(self, type):
|
||||
|
||||
if hasattr(type, 'MANIPULATOR'):
|
||||
man = type.MANIPULATOR
|
||||
else:
|
||||
man = self.empty
|
||||
return man
|
||||
|
||||
|
||||
class AutomaticManipulator(Manipulator):
|
||||
def _prepare(cls, model):
|
||||
cls.model = model
|
||||
@ -279,9 +277,6 @@ class ModelChangeManipulator(AutomaticManipulator):
|
||||
if self.opts.get_ordered_objects():
|
||||
self.fields.append(formfields.CommaSeparatedIntegerField(field_name="order_"))
|
||||
|
||||
|
||||
|
||||
|
||||
def manipulator_validator_unique_together(field_name_list, opts, self, field_data, all_data):
|
||||
from django.utils.text import get_text_list
|
||||
field_list = [opts.get_field(field_name) for field_name in field_name_list]
|
||||
|
Loading…
x
Reference in New Issue
Block a user