dddp/models.py
def get_object(model, meteor_id, *args, **kwargs):
    """Return an object for the given meteor_id."""
    # Django model._meta is now public API -> pylint: disable=W0212
    meta = model._meta
    if isinstance(meta.pk, AleaIdField):
        # meteor_id is the primary key
        return model.objects.filter(*args, **kwargs).get(pk=meteor_id)

    alea_unique_fields = [
        field
        for field in meta.local_fields
        if isinstance(field, AleaIdField) and field.unique and not field.null
    ]
    if len(alea_unique_fields) == 1:
        return model.objects.filter(*args, **kwargs).get(**{
            alea_unique_fields[0].name: meteor_id,
        })

    return model.objects.filter(*args, **kwargs).get(
        pk=get_object_id(model, meteor_id),
    )
def get_object(model, meteor_id, *args, **kwargs):
    """Return an object for the given meteor_id."""
    # Django model._meta is now public API -> pylint: disable=W0212
    meta = model._meta
    if isinstance(meta.pk, AleaIdField):
        # meteor_id is the primary key
        return model.objects.filter(*args, **kwargs).get(pk=meteor_id)

    alea_unique_fields = [
        field
        for field in meta.local_fields
        if isinstance(field, AleaIdField) and field.unique and not field.null
    ]
    if len(alea_unique_fields) == 1:
        return model.objects.filter(*args, **kwargs).get(**{
            alea_unique_fields[0].name: meteor_id,
        })

    return model.objects.filter(*args, **kwargs).get(
        pk=get_object_id(model, meteor_id),
    )
Return an object for the given meteor_id.