Exemple #1
0
def s3_ownerstamp():
    """
        Record ownership meta-fields
    """

    auth = current.auth
    utable = auth.settings.table_user

    # Individual user who owns the record
    s3_meta_owned_by_user = S3ReusableField("owned_by_user", utable,
                                            readable=False,
                                            writable=False,
                                            requires=None,
                                            default=current.session.auth.user.id
                                                        if auth.is_logged_in()
                                                        else None,
                                            represent=lambda id: \
                                                id and s3_auth_user_represent(id) or \
                                                       current.messages.UNKNOWN_OPT,
                                            ondelete="RESTRICT")

    # Role of users who collectively own the record
    s3_meta_owned_by_group = S3ReusableField("owned_by_group",
                                             "integer",
                                             readable=False,
                                             writable=False,
                                             requires=None,
                                             default=None,
                                             represent=s3_auth_group_represent)

    # Person Entity owning the record
    s3_meta_owned_by_entity = S3ReusableField("owned_by_entity", "integer",
                                              readable=False,
                                              writable=False,
                                              requires=None,
                                              default=None,
                                              # use a lambda here as we don't
                                              # want the model to be loaded yet
                                              represent=lambda val: \
                                                        current.s3db.pr_pentity_represent(val))

    # Person Entity controlling access to this record
    s3_meta_realm_entity = S3ReusableField("realm_entity", "integer",
                                              readable=False,
                                              writable=False,
                                              requires=None,
                                              default=None,
                                              # use a lambda here as we don't
                                              # want the model to be loaded yet
                                              represent=lambda val: \
                                                        current.s3db.pr_pentity_represent(val))
    return (
        s3_meta_owned_by_user(),
        s3_meta_owned_by_group(),
        s3_meta_owned_by_entity(),  # retained for migration
        s3_meta_realm_entity())
Exemple #2
0
def s3_ownerstamp():
    """
        Record ownership meta-fields
    """

    auth = current.auth
    utable = auth.settings.table_user

    # Individual user who owns the record
    s3_meta_owned_by_user = S3ReusableField("owned_by_user", utable,
                                            readable=False,
                                            writable=False,
                                            requires=None,
                                            default=current.session.auth.user.id
                                                        if auth.is_logged_in()
                                                        else None,
                                            represent=lambda id: \
                                                id and s3_auth_user_represent(id) or \
                                                       current.messages.UNKNOWN_OPT,
                                            ondelete="RESTRICT")

    # Role of users who collectively own the record
    s3_meta_owned_by_group = S3ReusableField("owned_by_group", "integer",
                                             readable=False,
                                             writable=False,
                                             requires=None,
                                             default=None,
                                             represent=s3_auth_group_represent)

    # Person Entity owning the record
    s3_meta_owned_by_entity = S3ReusableField("owned_by_entity", "integer",
                                              readable=False,
                                              writable=False,
                                              requires=None,
                                              default=None,
                                              # use a lambda here as we don't
                                              # want the model to be loaded yet
                                              represent=lambda val: \
                                                        current.s3db.pr_pentity_represent(val))

    # Person Entity controlling access to this record
    s3_meta_realm_entity = S3ReusableField("realm_entity", "integer",
                                              readable=False,
                                              writable=False,
                                              requires=None,
                                              default=None,
                                              # use a lambda here as we don't
                                              # want the model to be loaded yet
                                              represent=lambda val: \
                                                        current.s3db.pr_pentity_represent(val))
    return (s3_meta_owned_by_user(),
            s3_meta_owned_by_group(),
            s3_meta_owned_by_entity(), # retained for migration
            s3_meta_realm_entity())
Exemple #3
0
def s3_ownerstamp():
    """
        Record ownership meta-fields
    """

    db = current.db
    auth = current.auth
    session = current.session

    # Individual user who owns the record
    s3_meta_owned_by_user = S3ReusableField(
        "owned_by_user",
        db.auth_user,
        readable=False,
        writable=False,
        requires=None,
        default=session.auth.user.id if auth.is_logged_in() else None,
        represent=lambda id: id and s3_auth_user_represent(id) or current.messages.UNKNOWN_OPT,
        ondelete="RESTRICT",
    )

    # Role of users who collectively own the record
    s3_meta_owned_by_group = S3ReusableField(
        "owned_by_group",
        "integer",
        readable=False,
        writable=False,
        requires=None,
        default=None,
        represent=s3_auth_group_represent,
    )

    # Person Entity owning the record
    s3_meta_owned_by_entity = S3ReusableField(
        "owned_by_entity",
        "integer",
        readable=False,
        writable=False,
        requires=None,
        default=None,
        # use a lambda here as we don't
        # want the model to be loaded yet
        represent=lambda val: current.s3db.pr_pentity_represent(val),
    )
    return (s3_meta_owned_by_user(), s3_meta_owned_by_group(), s3_meta_owned_by_entity())