🔍 Code Extractor

function extend_review_deadline_v1

Maturity: 50

Extends the deadline of a review cycle by updating its due date and returns a success status with a message.

File:
/tf/active/vicechatdev/CDocs single class/controllers/review_controller.py
Lines:
1846 - 1852
Complexity:
simple

Purpose

This function is used in a document management system to modify the deadline of an existing review cycle. It delegates to a controller's update_due_date method to perform the actual update and provides user feedback through a structured response. The function is decorated with log_controller_action to track this administrative action for audit purposes.

Source Code

def extend_review_deadline(user: DocUser, review_uid: str, new_due_date: datetime) -> Dict[str, Any]:
    """Extend a review cycle's deadline."""
    success = _controller.update_due_date(
        cycle_uid=review_uid,
        due_date=new_due_date
    )
    return {"success": success, "message": "Review deadline extended successfully" if success else "Failed to extend review deadline"}

Parameters

Name Type Default Kind
user DocUser - positional_or_keyword
review_uid str - positional_or_keyword
new_due_date datetime - positional_or_keyword

Parameter Details

user: A DocUser object representing the authenticated user performing the deadline extension. This parameter is likely used by the decorator for logging and permission checking, though not directly used in the function body.

review_uid: A string containing the unique identifier (UID) of the review cycle whose deadline needs to be extended. This is passed to the controller as 'cycle_uid'.

new_due_date: A datetime object representing the new deadline for the review cycle. This should be a future date/time that extends beyond the current deadline.

Return Value

Type: Dict[str, Any]

Returns a dictionary with two keys: 'success' (boolean indicating whether the deadline extension succeeded) and 'message' (string containing either 'Review deadline extended successfully' if success is True, or 'Failed to extend review deadline' if success is False). Type: Dict[str, Any] where 'success' is bool and 'message' is str.

Dependencies

  • CDocs

Required Imports

from typing import Dict, Any
from datetime import datetime
from CDocs.models.user_extensions import DocUser
from CDocs.controllers import log_controller_action

Usage Example

from datetime import datetime, timedelta
from CDocs.models.user_extensions import DocUser
from your_module import extend_review_deadline

# Assume user and review_uid are already obtained
user = DocUser.query.get(user_id)
review_uid = 'review-12345'

# Extend deadline by 7 days from now
new_deadline = datetime.now() + timedelta(days=7)

result = extend_review_deadline(
    user=user,
    review_uid=review_uid,
    new_due_date=new_deadline
)

if result['success']:
    print(f"Success: {result['message']}")
else:
    print(f"Error: {result['message']}")

Best Practices

  • Ensure the user has appropriate permissions to extend review deadlines before calling this function
  • Validate that new_due_date is in the future and later than the current deadline before calling
  • Always check the 'success' field in the returned dictionary before proceeding with dependent operations
  • The function is decorated with log_controller_action, so all calls are automatically logged for audit purposes
  • Handle the case where success is False appropriately in your application logic
  • Consider wrapping this call in a try-except block to handle potential exceptions from the underlying controller
  • Ensure the review_uid exists before calling to avoid ResourceNotFoundError

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function extend_approval_deadline_v2 83.6% similar

    Extends the deadline of an existing approval cycle by updating its due date through the approval controller.

    From: /tf/active/vicechatdev/CDocs single class/controllers/approval_controller.py
  • function extend_review_deadline 80.0% similar

    Extends the deadline for a document review cycle, validating permissions and business rules, then notifying active reviewers of the change.

    From: /tf/active/vicechatdev/CDocs/controllers/review_controller.py
  • function extend_approval_deadline_v1 73.2% similar

    Extends the deadline of an active approval cycle, validates permissions, logs the change, and notifies pending approvers of the new due date.

    From: /tf/active/vicechatdev/CDocs/controllers/approval_controller_bis.py
  • function extend_approval_deadline 68.1% similar

    Extends the deadline for an active approval cycle, validating permissions and business rules, then notifying affected approvers.

    From: /tf/active/vicechatdev/CDocs/controllers/approval_controller.py
  • function complete_review_v1 67.9% similar

    Completes a document review cycle by recording a decision and optional comments, then returns the operation status.

    From: /tf/active/vicechatdev/CDocs single class/controllers/review_controller.py
← Back to Browse