refactor: restructure codebase into modular architecture
- Split monolithic app.py (400+ lines) into organized modules - Extract models, forms, and commands into separate files - Implement Flask blueprints for route organization - Maintain full functionality with cleaner architecture - Update all templates to use new blueprint URLs - Enhance README with technical documentation Structure: ├── app.py (50 lines) - Flask app factory ├── models.py (62 lines) - SQLAlchemy models ├── forms.py (43 lines) - WTForms definitions ├── commands.py (74 lines) - CLI commands └── routes/ - Blueprint modules for each feature 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		
							
								
								
									
										55
									
								
								routes/assessments.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								routes/assessments.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| from flask import Blueprint, render_template, redirect, url_for, flash, request | ||||
| from models import db, Assessment, ClassGroup | ||||
| from forms import AssessmentForm | ||||
|  | ||||
| bp = Blueprint('assessments', __name__, url_prefix='/assessments') | ||||
|  | ||||
| @bp.route('/') | ||||
| def list(): | ||||
|     assessments = Assessment.query.join(ClassGroup).order_by(Assessment.date.desc()).all() | ||||
|     return render_template('assessments.html', assessments=assessments) | ||||
|  | ||||
| @bp.route('/new', methods=['GET', 'POST']) | ||||
| def new(): | ||||
|     form = AssessmentForm() | ||||
|     if form.validate_on_submit(): | ||||
|         assessment = Assessment( | ||||
|             title=form.title.data, | ||||
|             description=form.description.data, | ||||
|             date=form.date.data, | ||||
|             class_group_id=form.class_group_id.data, | ||||
|             coefficient=form.coefficient.data | ||||
|         ) | ||||
|         db.session.add(assessment) | ||||
|         db.session.commit() | ||||
|         flash('Évaluation créée avec succès !', 'success') | ||||
|         return redirect(url_for('assessments.detail', id=assessment.id)) | ||||
|     return render_template('assessment_form.html', form=form, title='Nouvelle évaluation') | ||||
|  | ||||
| @bp.route('/<int:id>') | ||||
| def detail(id): | ||||
|     assessment = Assessment.query.get_or_404(id) | ||||
|     return render_template('assessment_detail.html', assessment=assessment) | ||||
|  | ||||
| @bp.route('/<int:id>/edit', methods=['GET', 'POST']) | ||||
| def edit(id): | ||||
|     assessment = Assessment.query.get_or_404(id) | ||||
|     form = AssessmentForm(obj=assessment) | ||||
|     if form.validate_on_submit(): | ||||
|         assessment.title = form.title.data | ||||
|         assessment.description = form.description.data | ||||
|         assessment.date = form.date.data | ||||
|         assessment.class_group_id = form.class_group_id.data | ||||
|         assessment.coefficient = form.coefficient.data | ||||
|         db.session.commit() | ||||
|         flash('Évaluation modifiée avec succès !', 'success') | ||||
|         return redirect(url_for('assessments.detail', id=assessment.id)) | ||||
|     return render_template('assessment_form.html', form=form, title='Modifier l\'évaluation', assessment=assessment) | ||||
|  | ||||
| @bp.route('/<int:id>/delete', methods=['POST']) | ||||
| def delete(id): | ||||
|     assessment = Assessment.query.get_or_404(id) | ||||
|     db.session.delete(assessment) | ||||
|     db.session.commit() | ||||
|     flash('Évaluation supprimée avec succès !', 'success') | ||||
|     return redirect(url_for('assessments.list')) | ||||
		Reference in New Issue
	
	Block a user