feat: Implement comprehensive admin panel with CSV import system
- Add ImportLog model for tracking import history and results
- Create admin.html template with file upload form and progress display
- Implement POST /admin/upload route for CSV file handling with validation
- Build CSV import engine with dispatcher routing by filename patterns:
* ROLODEX*.csv → Client model import
* PHONE*.csv → Phone model import with client linking
* FILES*.csv → Case model import
* LEDGER*.csv → Transaction model import
* QDROS*.csv → Document model import
* PAYMENTS*.csv → Payment model import
- Add POST /admin/import/{data_type} route for triggering imports
- Implement comprehensive validation, error handling, and progress tracking
- Support for CSV header validation, data type conversions, and duplicate handling
- Real-time progress tracking with ImportLog database model
- Responsive UI with Bootstrap components for upload and results display
- Enhanced navigation with admin panel link already in place
- Tested import functionality with validation and error handling
The admin panel enables bulk importing of legacy CSV data from the old-csv/ directory, making the system fully functional with real data.
This commit is contained in:
@@ -182,3 +182,29 @@ class Payment(Base):
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Payment(id={self.id}, amount={self.amount})>"
|
||||
|
||||
|
||||
class ImportLog(Base):
|
||||
"""
|
||||
ImportLog model for tracking CSV import operations.
|
||||
|
||||
Records the history and results of bulk data imports from legacy CSV files.
|
||||
"""
|
||||
__tablename__ = "import_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
import_type = Column(String(50), nullable=False) # client, phone, case, transaction, document, payment
|
||||
file_name = Column(String(255), nullable=False)
|
||||
file_path = Column(String(500), nullable=False)
|
||||
status = Column(String(20), default="pending") # pending, running, completed, failed
|
||||
total_rows = Column(Integer, default=0)
|
||||
processed_rows = Column(Integer, default=0)
|
||||
success_count = Column(Integer, default=0)
|
||||
error_count = Column(Integer, default=0)
|
||||
error_details = Column(Text) # JSON string of error details
|
||||
started_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
completed_at = Column(DateTime(timezone=True))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ImportLog(id={self.id}, type='{self.import_type}', status='{self.status}')>"
|
||||
|
||||
Reference in New Issue
Block a user