Complete v2.0 transformation: Production-ready Flask application
Major Changes: - Migrated from prototype to production architecture - Implemented modular Flask app with models/services/web layers - Added Docker containerization with docker-compose - Switched to Pipenv for dependency management - Built advanced parser extracting 63 real activities from INDEX_MASTER - Implemented SQLite FTS5 full-text search - Created minimalist, responsive web interface - Added comprehensive documentation and deployment guides Technical Improvements: - Clean separation of concerns (models, services, web) - Enhanced database schema with FTS5 indexing - Dynamic filters populated from real data - Production-ready configuration management - Security best practices implementation - Health monitoring and API endpoints Removed Legacy Files: - Old src/ directory structure - Static requirements.txt (replaced by Pipfile) - Test and debug files - Temporary cache files Current Status: - 63 activities indexed across 8 categories - Full-text search operational - Docker deployment ready - Production documentation complete 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
153
app/models/activity.py
Normal file
153
app/models/activity.py
Normal file
@@ -0,0 +1,153 @@
|
||||
"""
|
||||
Activity data model for INDEX-SISTEM-JOCURI v2.0
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Optional, Dict, Any
|
||||
import json
|
||||
|
||||
@dataclass
|
||||
class Activity:
|
||||
"""Activity data model with comprehensive fields"""
|
||||
|
||||
# Basic information
|
||||
name: str
|
||||
description: str
|
||||
rules: Optional[str] = None
|
||||
variations: Optional[str] = None
|
||||
|
||||
# Categories
|
||||
category: str = ""
|
||||
subcategory: Optional[str] = None
|
||||
|
||||
# Source information
|
||||
source_file: str = ""
|
||||
page_reference: Optional[str] = None
|
||||
|
||||
# Age and participants
|
||||
age_group_min: Optional[int] = None
|
||||
age_group_max: Optional[int] = None
|
||||
participants_min: Optional[int] = None
|
||||
participants_max: Optional[int] = None
|
||||
|
||||
# Duration
|
||||
duration_min: Optional[int] = None # minutes
|
||||
duration_max: Optional[int] = None # minutes
|
||||
|
||||
# Materials and setup
|
||||
materials_category: Optional[str] = None
|
||||
materials_list: Optional[str] = None
|
||||
skills_developed: Optional[str] = None
|
||||
difficulty_level: Optional[str] = None
|
||||
|
||||
# Search and metadata
|
||||
keywords: Optional[str] = None
|
||||
tags: List[str] = field(default_factory=list)
|
||||
popularity_score: int = 0
|
||||
|
||||
# Database fields
|
||||
id: Optional[int] = None
|
||||
created_at: Optional[str] = None
|
||||
updated_at: Optional[str] = None
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Convert activity to dictionary for database storage"""
|
||||
return {
|
||||
'name': self.name,
|
||||
'description': self.description,
|
||||
'rules': self.rules,
|
||||
'variations': self.variations,
|
||||
'category': self.category,
|
||||
'subcategory': self.subcategory,
|
||||
'source_file': self.source_file,
|
||||
'page_reference': self.page_reference,
|
||||
'age_group_min': self.age_group_min,
|
||||
'age_group_max': self.age_group_max,
|
||||
'participants_min': self.participants_min,
|
||||
'participants_max': self.participants_max,
|
||||
'duration_min': self.duration_min,
|
||||
'duration_max': self.duration_max,
|
||||
'materials_category': self.materials_category,
|
||||
'materials_list': self.materials_list,
|
||||
'skills_developed': self.skills_developed,
|
||||
'difficulty_level': self.difficulty_level,
|
||||
'keywords': self.keywords,
|
||||
'tags': json.dumps(self.tags) if self.tags else None,
|
||||
'popularity_score': self.popularity_score
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: Dict[str, Any]) -> 'Activity':
|
||||
"""Create activity from dictionary"""
|
||||
# Parse tags from JSON if present
|
||||
tags = []
|
||||
if data.get('tags'):
|
||||
try:
|
||||
tags = json.loads(data['tags'])
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
tags = []
|
||||
|
||||
return cls(
|
||||
id=data.get('id'),
|
||||
name=data.get('name', ''),
|
||||
description=data.get('description', ''),
|
||||
rules=data.get('rules'),
|
||||
variations=data.get('variations'),
|
||||
category=data.get('category', ''),
|
||||
subcategory=data.get('subcategory'),
|
||||
source_file=data.get('source_file', ''),
|
||||
page_reference=data.get('page_reference'),
|
||||
age_group_min=data.get('age_group_min'),
|
||||
age_group_max=data.get('age_group_max'),
|
||||
participants_min=data.get('participants_min'),
|
||||
participants_max=data.get('participants_max'),
|
||||
duration_min=data.get('duration_min'),
|
||||
duration_max=data.get('duration_max'),
|
||||
materials_category=data.get('materials_category'),
|
||||
materials_list=data.get('materials_list'),
|
||||
skills_developed=data.get('skills_developed'),
|
||||
difficulty_level=data.get('difficulty_level'),
|
||||
keywords=data.get('keywords'),
|
||||
tags=tags,
|
||||
popularity_score=data.get('popularity_score', 0),
|
||||
created_at=data.get('created_at'),
|
||||
updated_at=data.get('updated_at')
|
||||
)
|
||||
|
||||
def get_age_range_display(self) -> str:
|
||||
"""Get formatted age range for display"""
|
||||
if self.age_group_min and self.age_group_max:
|
||||
return f"{self.age_group_min}-{self.age_group_max} ani"
|
||||
elif self.age_group_min:
|
||||
return f"{self.age_group_min}+ ani"
|
||||
elif self.age_group_max:
|
||||
return f"până la {self.age_group_max} ani"
|
||||
return "toate vârstele"
|
||||
|
||||
def get_participants_display(self) -> str:
|
||||
"""Get formatted participants range for display"""
|
||||
if self.participants_min and self.participants_max:
|
||||
return f"{self.participants_min}-{self.participants_max} persoane"
|
||||
elif self.participants_min:
|
||||
return f"{self.participants_min}+ persoane"
|
||||
elif self.participants_max:
|
||||
return f"până la {self.participants_max} persoane"
|
||||
return "orice număr"
|
||||
|
||||
def get_duration_display(self) -> str:
|
||||
"""Get formatted duration for display"""
|
||||
if self.duration_min and self.duration_max:
|
||||
return f"{self.duration_min}-{self.duration_max} minute"
|
||||
elif self.duration_min:
|
||||
return f"{self.duration_min}+ minute"
|
||||
elif self.duration_max:
|
||||
return f"până la {self.duration_max} minute"
|
||||
return "durată variabilă"
|
||||
|
||||
def get_materials_display(self) -> str:
|
||||
"""Get formatted materials for display"""
|
||||
if self.materials_category:
|
||||
return self.materials_category
|
||||
elif self.materials_list:
|
||||
return self.materials_list[:100] + "..." if len(self.materials_list) > 100 else self.materials_list
|
||||
return "nu specificate"
|
||||
Reference in New Issue
Block a user