Transform relation into a model or fully-qualified model string of the form "app_label.ModelName", relative to scope_model. The relation argument can be: * RECURSIVE_RELATIONSHIP_CONSTANT, i.e. the string "self", in which case the model argument will be returned. *
(scope_model, relation)
| 50 | |
| 51 | |
| 52 | def resolve_relation(scope_model, relation): |
| 53 | """ |
| 54 | Transform relation into a model or fully-qualified model string of the form |
| 55 | "app_label.ModelName", relative to scope_model. |
| 56 | |
| 57 | The relation argument can be: |
| 58 | * RECURSIVE_RELATIONSHIP_CONSTANT, i.e. the string "self", in which case |
| 59 | the model argument will be returned. |
| 60 | * A bare model name without an app_label, in which case scope_model's |
| 61 | app_label will be prepended. |
| 62 | * An "app_label.ModelName" string. |
| 63 | * A model class, which will be returned unchanged. |
| 64 | """ |
| 65 | # Check for recursive relations |
| 66 | if relation == RECURSIVE_RELATIONSHIP_CONSTANT: |
| 67 | relation = scope_model |
| 68 | |
| 69 | # Look for an "app.Model" relation |
| 70 | if isinstance(relation, str): |
| 71 | if "." not in relation: |
| 72 | relation = "%s.%s" % (scope_model._meta.app_label, relation) |
| 73 | |
| 74 | return relation |
| 75 | |
| 76 | |
| 77 | def lazy_related_operation(function, model, *related_models, **kwargs): |
no outgoing calls
no test coverage detected