class ContentStatus
An enumeration class that defines the possible status values for content generation and editing workflows.
/tf/active/vicechatdev/vice_ai/models.py
22 - 27
simple
Purpose
ContentStatus is an Enum class that provides a standardized set of status values to track the lifecycle of content through generation, review, and approval stages. It ensures type safety and consistency when managing content state across an application, preventing invalid status values and providing clear semantic meaning to content workflow stages.
Source Code
class ContentStatus(Enum):
"""Status of content generation/editing"""
DRAFT = "draft"
GENERATED = "generated"
REVIEWED = "reviewed"
APPROVED = "approved"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Enum | - |
Parameter Details
bases: Inherits from Enum base class, which provides enumeration functionality. No constructor parameters are needed as Enum members are defined as class attributes.
Return Value
Instantiation returns a ContentStatus enum member. Each member has a 'name' attribute (e.g., 'DRAFT') and a 'value' attribute (e.g., 'draft'). Accessing members returns the enum instance itself, which can be compared for equality and used in conditional logic.
Class Interface
Methods
ContentStatus.DRAFT
Purpose: Represents content in draft state, typically the initial status when content is first created
Returns: ContentStatus enum member with value 'draft'
ContentStatus.GENERATED
Purpose: Represents content that has been automatically generated but not yet reviewed
Returns: ContentStatus enum member with value 'generated'
ContentStatus.REVIEWED
Purpose: Represents content that has undergone review but is not yet approved
Returns: ContentStatus enum member with value 'reviewed'
ContentStatus.APPROVED
Purpose: Represents content that has been approved and is ready for publication or final use
Returns: ContentStatus enum member with value 'approved'
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
DRAFT |
ContentStatus | Enum member representing draft status with string value 'draft' | class |
GENERATED |
ContentStatus | Enum member representing generated status with string value 'generated' | class |
REVIEWED |
ContentStatus | Enum member representing reviewed status with string value 'reviewed' | class |
APPROVED |
ContentStatus | Enum member representing approved status with string value 'approved' | class |
name |
str | The uppercase name of the enum member (e.g., 'DRAFT', 'GENERATED') | instance |
value |
str | The lowercase string value associated with the enum member (e.g., 'draft', 'generated') | instance |
Dependencies
enum
Required Imports
from enum import Enum
Usage Example
from enum import Enum
class ContentStatus(Enum):
DRAFT = "draft"
GENERATED = "generated"
REVIEWED = "reviewed"
APPROVED = "approved"
# Access enum members
status = ContentStatus.DRAFT
print(status) # ContentStatus.DRAFT
print(status.value) # "draft"
print(status.name) # "DRAFT"
# Compare statuses
if status == ContentStatus.DRAFT:
print("Content is in draft state")
# Get status from string value
status_from_value = ContentStatus("generated")
print(status_from_value) # ContentStatus.GENERATED
# Iterate over all statuses
for status in ContentStatus:
print(f"{status.name}: {status.value}")
# Use in function signatures for type hints
def update_content(content_id: str, status: ContentStatus) -> None:
print(f"Updating content {content_id} to {status.value}")
update_content("123", ContentStatus.APPROVED)
Best Practices
- Use ContentStatus members directly (e.g., ContentStatus.DRAFT) rather than string literals to ensure type safety
- Compare enum members using identity (==) or 'is' operator for exact matches
- Access the string value using the .value attribute when storing in databases or serializing to JSON
- Use the .name attribute to get the uppercase constant name
- Leverage type hints with ContentStatus in function signatures to enforce valid status values
- When deserializing from strings, use ContentStatus(string_value) to convert back to enum member
- Enum members are immutable and singleton - each member is created once and reused
- Do not instantiate ContentStatus directly; access predefined members as class attributes
- Consider using ContentStatus in state machines or workflow engines to track content lifecycle
- The enum provides four distinct stages: DRAFT (initial creation), GENERATED (AI/automated generation complete), REVIEWED (human review complete), and APPROVED (final approval for publication)
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class AnalysisStatus_v1 69.5% similar
-
class AnalysisStatus 67.5% similar
-
class SectionType 54.7% similar
-
function is_editable_status 50.9% similar
-
function is_valid_status_transition 50.4% similar