Skip to content

Commit 36b5e2e

Browse files
committed
Changed name from .rel to .remote_field for remote accessors.
- Legacy-Id: 14665
1 parent a4768bb commit 36b5e2e

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

ietf/api/management/commands/makeresources.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def handle_app_config(self, app, **options):
9696
for field in model._meta.fields:
9797
if isinstance(field, (models.ForeignKey, models.OneToOneField)):
9898
#debug.show('field.name')
99-
#debug.pprint('dir(field.rel.to)')
99+
#debug.pprint('dir(field.remote_field.to)')
100100
#exit()
101-
rel_app=field.rel.to._meta.app_label
102-
rel_model_name=field.rel.to.__name__
101+
rel_app=field.remote_field.to._meta.app_label
102+
rel_model_name=field.remote_field.to.__name__
103103
if rel_model_name == model_name:
104104
# foreign key to self class -- quote
105105
# the rmodel_name
@@ -111,10 +111,10 @@ def handle_app_config(self, app, **options):
111111
name=field.name,
112112
app=rel_app,
113113
module=rel_app.split('.')[-1],
114-
model=field.rel.to,
114+
model=field.remote_field.to,
115115
model_name=rel_model_name,
116116
rmodel_name=rmodel_name,
117-
resource_name=field.rel.to.__name__.lower(),
117+
resource_name=field.remote_field.to.__name__.lower(),
118118
))
119119
imports[rel_app]["module"] = rel_app
120120
imports[rel_app]["names"].append(rel_model_name)
@@ -124,10 +124,10 @@ def handle_app_config(self, app, **options):
124124
m2m_keys = []
125125
for field in model._meta.many_to_many:
126126
#debug.show('field.name')
127-
#debug.pprint('dir(field.rel.to)')
127+
#debug.pprint('dir(field.remote_field.to)')
128128
#exit()
129-
rel_app=field.rel.to._meta.app_label
130-
rel_model_name=field.rel.to.__name__
129+
rel_app=field.remote_field.to._meta.app_label
130+
rel_model_name=field.remote_field.to.__name__
131131
if rel_model_name == model_name:
132132
# foreign key to self class -- quote
133133
# the rmodel_name
@@ -139,10 +139,10 @@ def handle_app_config(self, app, **options):
139139
name=field.name,
140140
app=rel_app,
141141
module=rel_app.split('.')[-1],
142-
model=field.rel.to,
142+
model=field.remote_field.to,
143143
model_name=rel_model_name,
144144
rmodel_name=rmodel_name,
145-
resource_name=field.rel.to.__name__.lower(),
145+
resource_name=field.remote_field.to.__name__.lower(),
146146
))
147147
imports[rel_app]["module"] = rel_app
148148
imports[rel_app]["names"].append(rel_model_name)

ietf/doc/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ def get_model_fields_as_dict(obj):
4444

4545
# copy many to many
4646
for field in doc._meta.many_to_many:
47-
if field.rel.through and field.rel.through._meta.auto_created:
48-
setattr(dochist, field.name, getattr(doc, field.name).all())
47+
if field.remote_field.through and field.remote_field.through._meta.auto_created:
48+
hist_field = getattr(dochist, field.name)
49+
hist_field.clear()
50+
hist_field.set(getattr(doc, field.name).all())
4951

5052
# copy remaining tricky many to many
5153
def transfer_fields(obj, HistModel):

ietf/group/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def fill_in_wg_drafts(group):
192192
group.drafts.append(a)
193193
else:
194194
group.rfcs.append(a)
195-
a.rel = RelatedDocument.objects.filter(source=a.document,relationship_id__in=['obs','updates']).distinct()
195+
a.remote_field = RelatedDocument.objects.filter(source=a.document,relationship_id__in=['obs','updates']).distinct()
196196
a.invrel = RelatedDocument.objects.filter(target=a,relationship_id__in=['obs','updates']).distinct()
197197

198198

@@ -1112,7 +1112,8 @@ def customize_workflow(request, group_type=None, acronym=None):
11121112
group.groupstatetransitions_set.filter(state=state).delete()
11131113
else:
11141114
transitions, _ = GroupStateTransitions.objects.get_or_create(group=group, state=state)
1115-
transitions.next_states = next_states
1115+
transitions.next_states.clear()
1116+
transitions.next_states.set(next_states)
11161117

11171118
return redirect("ietf.group.views.customize_workflow", group_type=group.type_id, acronym=group.acronym)
11181119

ietf/utils/history.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,7 @@ def copy_many_to_many_for_history(history_obj, obj):
9191
"""Copy basic many-to-many fields from obj to history_obj."""
9292
# copy many to many
9393
for field in obj._meta.many_to_many:
94-
if field.rel.through and field.rel.through._meta.auto_created:
95-
setattr(history_obj, field.name, getattr(obj, field.name).all())
94+
if field.remote_field.through and field.remote_field.through._meta.auto_created:
95+
history_field = getattr(history_obj, field.name)
96+
history_field.clear()
97+
history_field.set(getattr(obj, field.name).all())

ietf/utils/management/commands/check_referential_integrity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ def check_reverse_field(field):
4646
raise
4747
if foreign_model == field.model:
4848
return
49-
foreign_field_name = field.rel.name
50-
foreign_accessor_name = field.rel.get_accessor_name()
49+
foreign_field_name = field.remote_field.name
50+
foreign_accessor_name = field.remote_field.get_accessor_name()
5151
if verbosity > 1:
52-
print " %s <- %s -> %s.%s" % (field.model.__name__, field.rel.through._meta.db_table, foreign_model.__module__, foreign_model.__name__),
52+
print " %s <- %s -> %s.%s" % (field.model.__name__, field.remote_field.through._meta.db_table, foreign_model.__module__, foreign_model.__name__),
5353
try:
5454
used = set(foreign_model.objects.values_list(foreign_field_name, flat=True))
5555
except FieldError:
@@ -66,7 +66,7 @@ def check_reverse_field(field):
6666
print " ok"
6767
else:
6868
if used - exists:
69-
print "\n%s.%s <- %s -> %s.%s ** Bad key values:\n " % (field.model.__module__, field.model.__name__, field.rel.through._meta.db_table, foreign_model.__module__, foreign_model.__name__), list(used - exists)
69+
print "\n%s.%s <- %s -> %s.%s ** Bad key values:\n " % (field.model.__module__, field.model.__name__, field.remote_field.through._meta.db_table, foreign_model.__module__, foreign_model.__name__), list(used - exists)
7070

7171
for conf in tqdm([ c for c in apps.get_app_configs() if c.name.startswith('ietf.')], desc='apps', disable=verbose):
7272
if verbosity > 1:

0 commit comments

Comments
 (0)