function extend_approval_deadline_v2
Extends the deadline of an existing approval cycle by updating its due date through the approval controller.
/tf/active/vicechatdev/CDocs single class/controllers/approval_controller.py
2014 - 2020
simple
Purpose
This function allows authorized users to modify the due date of an approval cycle, typically used when more time is needed for document review and approval processes. It delegates the actual update operation to an underlying controller and returns a success/failure response with an appropriate message.
Source Code
def extend_approval_deadline(user: DocUser, approval_uid: str, new_due_date: datetime) -> Dict[str, Any]:
"""Extend an approval cycle's deadline."""
success = _controller.update_due_date(
cycle_uid=approval_uid,
due_date=new_due_date
)
return {"success": success, "message": "Approval deadline extended successfully" if success else "Failed to extend approval deadline"}
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
user |
DocUser | - | positional_or_keyword |
approval_uid |
str | - | positional_or_keyword |
new_due_date |
datetime | - | positional_or_keyword |
Parameter Details
user: DocUser object representing the authenticated user performing the deadline extension. This user must have appropriate permissions to modify approval cycles.
approval_uid: String containing the unique identifier (UID) of the approval cycle whose deadline needs to be extended. Must correspond to an existing approval cycle in the system.
new_due_date: datetime object specifying the new deadline for the approval cycle. Should be a future date/time and typically later than the current due date.
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 'Approval deadline extended successfully' if success is True, or 'Failed to extend approval deadline' if success is False). Type: Dict[str, Any]
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_approval_deadline
# Assume user and approval_uid are already obtained
user = DocUser.get_by_id('user123')
approval_uid = 'approval-abc-123'
# Extend deadline by 7 days from now
new_deadline = datetime.now() + timedelta(days=7)
result = extend_approval_deadline(
user=user,
approval_uid=approval_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 before calling this function (the log_controller_action decorator may handle this)
- Validate that new_due_date is in the future and later than the current due date before calling
- Always check the 'success' field in the returned dictionary before proceeding with dependent operations
- Handle the case where the approval_uid does not exist (may raise ResourceNotFoundError from controller)
- Consider timezone awareness when creating the new_due_date datetime object
- Log or notify relevant stakeholders when deadlines are extended
- The function is decorated with log_controller_action which will automatically log the action for audit purposes
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function extend_review_deadline_v1 83.6% similar
-
function extend_approval_deadline_v1 79.7% similar
-
function extend_approval_deadline 75.5% similar
-
function complete_approval_v2 71.6% similar
-
function create_approval_cycle_v2 69.6% similar