function update_reviewer_permissions
Updates file access permissions for reviewers associated with a review cycle by delegating to the main document permission management function.
/tf/active/vicechatdev/CDocs/controllers/share_controller.py
786 - 813
simple
Purpose
This function serves as a specialized wrapper for updating reviewer permissions when a review cycle changes. It retrieves the document associated with the review cycle and delegates to the manage_document_permissions function to handle the actual permission updates. It includes error handling and validation to ensure the document exists before attempting permission updates.
Source Code
def update_reviewer_permissions(review_cycle: ReviewCycle) -> Dict[str, Any]:
"""
Update permissions specifically for reviewers when a review cycle changes.
Args:
review_cycle: The review cycle that has been updated
Returns:
Dict: Result of permission updates
"""
try:
# Get document and current version
document = review_cycle.document
if not document:
return {
'success': False,
'message': 'Document not found for review cycle'
}
# Just use the main permission management function
return manage_document_permissions(document)
except Exception as e:
logger.error(f"Error updating reviewer permissions: {str(e)}")
return {
'success': False,
'message': f'Error updating reviewer permissions: {str(e)}'
}
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
review_cycle |
ReviewCycle | - | positional_or_keyword |
Parameter Details
review_cycle: A ReviewCycle model instance representing the review cycle that has been updated. This object must have a 'document' attribute that references the associated ControlledDocument. The function uses this to retrieve the document for which permissions need to be updated.
Return Value
Type: Dict[str, Any]
Returns a dictionary with keys 'success' (boolean) and 'message' (string). On success, returns the result from manage_document_permissions function. On failure (document not found or exception), returns {'success': False, 'message': '<error description>'}. The exact structure of successful returns depends on the manage_document_permissions implementation.
Dependencies
loggingtypingostracebackCDocs.models.documentCDocs.models.user_extensionsCDocs.models.reviewCDocs.models.approvalCDocs.controllers.filecloud_controllerCDocs.models.document_statusCDocs.dbCDocs.controllers.document_controller
Required Imports
import logging
from typing import Dict, Any
from CDocs.models.review import ReviewCycle
from CDocs.controllers.filecloud_controller import manage_document_permissions
Usage Example
from CDocs.models.review import ReviewCycle
from CDocs.db import db_operations as db
# Assume review_cycle is a ReviewCycle instance retrieved from database
review_cycle = db.get_review_cycle_by_id(cycle_id=123)
# Update permissions for reviewers
result = update_reviewer_permissions(review_cycle)
if result['success']:
print('Reviewer permissions updated successfully')
else:
print(f"Failed to update permissions: {result['message']}")
Best Practices
- Always check the 'success' key in the returned dictionary before proceeding with dependent operations
- Ensure the review_cycle object has a valid document association before calling this function
- This function is a thin wrapper - consider calling manage_document_permissions directly if you already have the document object
- Monitor logs for errors as exceptions are caught and logged but not re-raised
- The function delegates to manage_document_permissions, so understand that function's behavior for complete permission management logic
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function update_approver_permissions 82.2% similar
-
function close_review_cycle 71.2% similar
-
function add_reviewer_to_active_review 69.3% similar
-
function create_review_cycle 68.3% similar
-
function get_review_cycle 67.1% similar