Example #1
0
def can_user_set_workspace_public(func, workspace, user):
    """Check if the user is the owner of the workspace.

    Args:
        func:
        workspace:
        user:

    Returns:

    """
    if user.is_superuser:
        return func(workspace, user)

    _check_is_owner_workspace(workspace, user)

    publish_perm = permissions_api.get_by_codename(rights.publish_data)
    if not user.has_perm(
        publish_perm.content_type.app_label + "." + publish_perm.codename
    ):
        raise AccessControlError(
            "You don't have enough rights to set public this workspace."
        )

    return func(workspace, user)
Example #2
0
def has_perm_publish_data(user):
    """ Does the user have the permission to publish a data.

    Args:
        user

    Returns
    """
    publish_perm = permissions_api.get_by_codename(rights.publish_data)
    if not user.has_perm(publish_perm.content_type.app_label + '.' + publish_perm.codename):
        raise AccessControlError("The user doesn't have enough rights to publish this data.")
Example #3
0
def has_perm_publish(user, codename):
    """Does the user have the permission to publish.

    Args:
        user
        codename

    Returns
    """
    publish_perm = permissions_api.get_by_codename(codename)
    if not user.has_perm(
        publish_perm.content_type.app_label + "." + publish_perm.codename
    ):
        raise AccessControlError("The user doesn't have enough rights to publish.")
Example #4
0
 def add_publish_perm(user):
     publish_perm = permissions_api.get_by_codename(rights.publish_data)
     user.user_permissions.add(publish_perm)
     user.save()