Commit Graph

828 Commits

Author SHA1 Message Date
2efc34e0d5 feat: Add Announcements and Insights links to admin menu
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:34:07 +01:00
c201aeceaf feat: Add Forum link to admin navigation menu
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:32:31 +01:00
36d988aee3 chore: Remove party emoji from forum reactions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:31:00 +01:00
e8586b3e4e feat: Add forum admin tools (analytics, search, move, merge)
New admin features:
- Analytics dashboard with stats, charts (Chart.js), user rankings
- CSV export of forum activity with date range
- Topic category move functionality
- Merge multiple topics into one
- Admin search across all posts (including deleted)
- User activity log with stats

New endpoints:
- GET /admin/forum/analytics
- GET /admin/forum/export-activity
- POST /admin/forum/topic/<id>/move
- POST /admin/forum/merge-topics
- GET /admin/forum/search
- GET /admin/forum/user/<id>/activity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:29:02 +01:00
c5f724f954 feat: Add forum search, markdown, user stats, and admin bulk actions
New features implemented:
- Forum search with title/content filtering
- Solution filter (topics with marked solutions)
- Quote reply functionality with @mention
- @mentions parsing and notifications
- Simple markdown formatting (bold, italic, code, quotes, lists)
- User forum statistics tooltip (topics, replies, solutions, reactions)
- Admin bulk actions (pin/unpin, lock/unlock, status change, delete)

Files changed:
- blueprints/forum/routes.py: user_forum_stats, admin_forum_bulk_action endpoints
- templates/forum/topic.html: user stats tooltips, markdown CSS
- templates/forum/index.html: search box, solution filter
- templates/admin/forum.html: bulk selection checkboxes and action bar
- utils/markdown.py: simple forum markdown parser
- utils/notifications.py: @mention notification parsing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:11:29 +01:00
f22342ea37 feat: Add forum modernization with reactions, subscriptions, and moderation
- Add edit tracking (24h limit), soft delete, and JSONB reactions to ForumTopic/ForumReply
- Create ForumTopicSubscription, ForumReport, ForumEditHistory models
- Add 15 new API endpoints for user actions and admin moderation
- Implement reactions (👍❤️🎉), topic subscriptions, content reporting
- Add solution marking, restore deleted content, edit history for admins
- Create forum_reports.html and forum_deleted.html admin templates
- Integrate notifications for replies, reactions, solutions, and reports
- Add SQL migration 024_forum_modernization.sql

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:55:40 +01:00
9dc5d58982 chore: Remove dead _old_* functions from app.py
Removed 33 dead functions that were left behind after migration to blueprints.
These were prefixed with _old_ and no longer referenced.

app.py: 4756 → 1523 lines (-3233, -68%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:11:10 +01:00
ff59872529 refactor: Move company/validation/enrichment API routes to blueprints
- Create blueprints/api/routes_company.py with 9 routes:
  - /api/companies, /api/connections
  - /api/check-email, /api/verify-nip, /api/verify-krs
  - /api/company/<id>/refresh-krs, /api/company/<id>/enrich-ai
  - /api/model-info, /api/admin/test-sanitization
- app.py: 5520 → 4756 lines (-764)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:08:36 +01:00
94dd5327bc refactor: Move audit dashboard routes to blueprints/audit
- Create new audit blueprint for user-facing audit dashboards
- Move /audit/seo/<slug>, /audit/social/<slug>, /audit/gbp/<slug>, /audit/it/<slug>
- Add endpoint aliases for backward compatibility
- app.py: 5860 → 5520 lines (-340)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:03:02 +01:00
b505427355 fix: Update url_for to use api. blueprint prefix for migrated endpoints
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:57:18 +01:00
8e3346178d refactor: Move GBP and Social Audit API routes to blueprints
- Create blueprints/api/routes_gbp_audit.py (4 routes)
- Create blueprints/api/routes_social_audit.py (1 route)
- app.py: 6354 → 5860 lines (-494 total this batch)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:54:54 +01:00
60c19ec188 refactor: Migrate SEO audit API routes to api blueprint
- Created blueprints/api/routes_seo_audit.py with 3 routes:
  - /api/seo/audit (GET)
  - /api/seo/audit/<slug> (GET)
  - /api/seo/audit (POST - trigger)
- Includes helper functions for building audit responses
- Removed ~420 lines from app.py (6770 -> 6348)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:48:43 +01:00
52e5395a04 refactor: Migrate contacts API routes to api blueprint
- Created blueprints/api/routes_contacts.py with 2 routes:
  - /api/contacts/ai-parse (POST)
  - /api/contacts/bulk-create (POST)
- Includes AI prompts for contact parsing
- Removed ~300 lines from app.py (7063 -> 6764)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:42:18 +01:00
eaadef0bc1 refactor: Migrate recommendations API routes to api blueprint
- Created blueprints/api/routes_recommendations.py with 4 routes:
  - /api/recommendations/<company_id> (GET)
  - /api/recommendations/create (POST)
  - /api/recommendations/<rec_id>/edit (POST)
  - /api/recommendations/<rec_id>/delete (POST)
- Removed ~320 lines from app.py (7378 -> 7057)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:39:48 +01:00
3c5795ee4a refactor: Migrate announcements routes to public blueprint
- Created blueprints/public/routes_announcements.py with 2 routes:
  - /ogloszenia (announcements_list)
  - /ogloszenia/<slug> (announcement_detail)
- Added endpoint aliases for backward compatibility
- Removed ~130 lines from app.py (7506 -> 7378)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:37:08 +01:00
0337d1a0bb refactor: Migrate analytics API routes to api blueprint
- Created blueprints/api/ with 6 routes:
  - /api/analytics/track
  - /api/analytics/heartbeat
  - /api/analytics/scroll
  - /api/analytics/error
  - /api/analytics/performance
  - /api/analytics/conversion
- Added CSRF exemption for analytics routes
- Removed ~230 lines from app.py (7729 -> 7506)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:35:08 +01:00
e6cca4ec19 refactor: Migrate KRS API routes to admin blueprint
- Created blueprints/admin/routes_krs_api.py with 3 routes:
  - /admin/krs-api/audit (POST)
  - /admin/krs-api/audit/batch (POST)
  - /admin/krs-api/pdf/<company_id>
- Updated templates to use new URL paths
- Added endpoint aliases for backward compatibility
- Removed ~420 lines from app.py (8150 -> 7729)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:31:36 +01:00
236e929d10 refactor: Migrate IT Audit routes to it_audit blueprint
- Created blueprints/it_audit/ with 5 routes:
  - /it-audit/form (it_audit_form)
  - /it-audit/save (it_audit_save)
  - /api/it-audit/matches/<company_id>
  - /api/it-audit/history/<company_id>
  - /api/it-audit/export
- Added endpoint aliases for backward compatibility
- Removed ~600 lines from app.py (8750 -> 8150)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:25:28 +01:00
ab15cf3cba refactor: Migrate ZOPK public routes to public blueprint
- Created blueprints/public/routes_zopk.py with 3 public routes:
  - /zopk (zopk_index)
  - /zopk/projekty/<slug> (zopk_project_detail)
  - /zopk/aktualnosci (zopk_news_list)
- Added endpoint aliases for backward compatibility
- Removed ZOPK public routes from app.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:19:53 +01:00
bdae7f5309 fix: Add ZOPK endpoint aliases for backward compatibility
Templates use url_for('admin_zopk') but blueprint endpoints are
'admin.admin_zopk'. Added aliases in blueprints/__init__.py.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:12:46 +01:00
f36aa07137 fix: Remove non-existent routes_ai_usage import
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:08:15 +01:00
49830855a2 refactor: Migrate ZOPK and Users API routes to admin blueprint
Major refactoring to reduce app.py size by ~22%:
- Move all ZOPK routes (47 endpoints) to 4 blueprint files:
  - routes_zopk_dashboard.py - main dashboard
  - routes_zopk_news.py - news management, scraping, AI evaluation
  - routes_zopk_knowledge.py - knowledge base, embeddings, graph
  - routes_zopk_timeline.py - milestones management
- Move Users API routes to routes_users_api.py:
  - /admin/users-api/ai-parse - AI-powered user parsing
  - /admin/users-api/bulk-create - bulk user creation
- Move notify-release to routes.py

app.py reduced from 11518 to 8916 lines (-22.6%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 17:05:36 +01:00
351c8fba75 refactor: Move admin_model_comparison routes to admin blueprint
- Created routes_model_comparison.py with model comparison functionality
- Updated base.html to use full blueprint name
- Added aliases for backward compatibility
- Commented old routes in app.py with _old_ prefix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:48:18 +01:00
532d666fa8 refactor: Move admin_ai_usage routes to admin blueprint
- Added admin_ai_usage and admin_ai_usage_user to routes_analytics.py
- Updated templates to use full blueprint names (admin.admin_ai_usage)
- Added aliases for backward compatibility
- Commented old routes in app.py with _old_ prefix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:43:28 +01:00
8909641ff3 refactor: Migrate analytics routes to blueprints
- Create new blueprints/admin/routes_analytics.py (~350 lines)
- Move admin_analytics and admin_analytics_export routes
- Update templates to use full blueprint names
- Add endpoint aliases for backward compatibility

Phase 6.2b - Analytics dashboard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:36:23 +01:00
9b9ae40932 refactor: Add ai-learning-status and chat-stats API to blueprints
- Add api_ai_learning_status and api_chat_stats to routes_insights.py
- Update chat_analytics template to use new API path
- Add endpoint aliases for backward compatibility

Phase 6.2b - AI API routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:31:29 +01:00
42f04e065f refactor: Migrate insights routes to blueprints
- Create new blueprints/admin/routes_insights.py
- Move 5 insights routes (dashboard + API endpoints)
- Update template to use new /admin/insights-api/* paths
- Add endpoint aliases for backward compatibility

Phase 6.2b - Insights routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:27:35 +01:00
54c1878d66 refactor: Migrate announcements routes to blueprints
- Create new blueprints/admin/routes_announcements.py
- Move 6 announcements routes to blueprint
- Update templates to use full blueprint names
- Add endpoint aliases for backward compatibility

Phase 6.2d - Announcements routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:41:49 +01:00
82162874b8 refactor: Migrate security routes to blueprints
- Create new blueprints/admin/routes_security.py
- Move 5 security routes: admin_security, acknowledge_security_alert,
  resolve_security_alert, unlock_account, api_geoip_stats
- Update templates to use full blueprint names
- Add endpoint aliases for backward compatibility

Phase 6.2d - Security routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:39:12 +01:00
470e2a8bb7 refactor: Migrate admin_it_audit to blueprints
- Move IT audit dashboard route to blueprints/admin/routes_audits.py
- Add ITAudit, ITCollaborationMatch imports
- Update base.html template to use full blueprint name
- Add endpoint alias for backward compatibility

Phase 6.2f continued

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:25:31 +01:00
806f9e730e refactor: Migrate digital_maturity_dashboard and admin_krs_audit to blueprints
- Move routes from app.py to blueprints/admin/routes_audits.py
- Add endpoint aliases for backward compatibility
- Update base.html template to use full blueprint names
- Comment old routes in app.py with _old_ prefix

Phase 6.2f of blueprint migration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:19:56 +01:00
9dedab2929 refactor: Faza 6.2e - Social Media do blueprintu admin
Przeniesiono 2 trasy do blueprints/admin/routes_social.py:
- admin_social_media (analytics dashboard)
- admin_social_audit (audit dashboard)

Zaktualizowano szablony:
- base.html, dashboard.html, social_audit_dashboard.html

Dodano aliasy dla kompatybilności wstecznej.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:07:51 +01:00
61a32d9bfa refactor: Faza 6.2c - Status, Health, Debug do blueprintu admin
Przeniesiono 9 tras do blueprints/admin/routes_status.py:
- admin_status, api_admin_status
- admin_health, api_admin_health
- debug_panel
- api_get_logs, api_logs_stream, api_clear_logs, api_test_log

Zaktualizowano szablony na pełne nazwy blueprintów:
- base.html: admin.admin_status, admin.admin_health
- health_dashboard.html: admin.admin_status

Dodano aliasy dla kompatybilności wstecznej.
Stare trasy w app.py oznaczone jako _old_* (do usunięcia po weryfikacji).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:59:15 +01:00
dd4eb52521 refactor: Aliasy admin_seo/gbp_audit + poprawka chat.chat_analytics
- Dodano aliasy w blueprints/__init__.py dla admin_seo i admin_gbp_audit
- Poprawiono url_for('chat_analytics') na url_for('chat.chat_analytics')
  (trasa już jest w blueprincie chat)

Minimalne, bezpieczne zmiany zgodne z metodologią.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:41:28 +01:00
978481ec00 refactor: Użycie pełnych nazw blueprintów w szablonach admin
Zamieniono url_for('admin_*') na url_for('admin.admin_*') dla tras
już przeniesionych do blueprintu admin. Zgodnie z metodologią
bezpiecznego wdrażania - pełne nazwy blueprintów są niezawodne,
aliasy mogą nie działać dla tras w oddzielnych plikach.

Zaktualizowane pliki:
- base.html (4 linki)
- dashboard.html (2 linki)
- calendar/admin.html (2 linki)
- calendar/admin_new.html (3 linki)
- calendar/index.html (1 link)
- admin/fees.html (2 linki)
- admin/analytics_dashboard.html (1 link)

Zapobiega awariom produkcji przy dalszym refaktoringu.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:33:25 +01:00
e116eeadc6 docs: Add safe deployment methodology after production incident
- Document incident 2026-01-31 (alias failure)
- New rule: Use full blueprint names, NOT aliases
- New procedure: Update templates BEFORE moving routes
- Enhanced checklist: Test page rendering, not just HTTP status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:29:24 +01:00
67d35c5d61 fix: Use full blueprint endpoint names in base.html
admin_seo -> admin.admin_seo
admin_gbp_audit -> admin.admin_gbp_audit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:24:52 +01:00
52ffdafd00 refactor: Remove dead SEO/GBP audit code from app.py
Removed 280 lines of dead code after moving to blueprint.
app.py: 11,774 → 11,494 lines (-280)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:20:07 +01:00
1384c7f090 refactor: Add SEO & GBP audit routes to admin blueprint (Phase 6.2a)
- Created blueprints/admin/routes_audits.py (2 routes)
- admin_seo, admin_gbp_audit moved from app.py
- Aliases created for backward compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:16:22 +01:00
ba0baf1305 fix: Correct template paths for admin calendar
- calendar/admin.html (not admin/calendar.html)
- calendar/admin_new.html (not admin/calendar_form.html)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:12:15 +01:00
80ec8dd949 docs: Update metrics after Phase 6.1 cleanup
app.py reduced from 12,600 to 11,774 lines (-826)
Total reduction: 24.4% from start

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:10:32 +01:00
3e834c168c refactor: Remove dead admin code after Phase 6.1 verification
Removed 831 lines of dead code (_old_* functions):
- Recommendations: 3 functions
- Users: 8 functions
- Fees: 5 functions
- Calendar admin: 3 functions

app.py: 12,605 → 11,774 lines (-831)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:09:42 +01:00
214eadeaf0 docs: Update refactoring status after Phase 6.1
- Admin blueprint Part 1 deployed (19 routes)
- Added metrics for blueprints/admin/routes.py (828 lines)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:06:08 +01:00
44268c5425 refactor: Extract admin blueprint Part 1 (Phase 6)
Moved 19 admin routes to blueprints/admin/:
- Recommendations: 3 routes (list, approve, reject)
- Users: 8 routes (list, add, toggle-admin, toggle-verified, update, assign-company, delete, reset-password)
- Fees: 5 routes (list, generate, mark-paid, bulk-mark-paid, export)
- Calendar admin: 3 routes (list, new, delete)

Note: AI-parse routes (/api/admin/users/ai-parse, ai-create) remain in app.py.

Aliases created for backward compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:05:06 +01:00
55718ed211 refactor: Extract chat blueprint (Phase 5)
- Create blueprints/chat/ with 9 routes:
  - chat, chat_settings, chat_start, chat_send_message
  - chat_get_history, chat_list_conversations, chat_delete_conversation
  - chat_feedback, chat_analytics
- Register chat blueprint with backward-compatible aliases
- Remove dead code from app.py (-458 lines)
- app.py: 13,058 → 12,600 lines (-3.5%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:54:08 +01:00
0f482cc4aa refactor: Extract messages + notifications blueprint (Phase 4)
- Create blueprints/messages/ with 11 routes:
  - messages_inbox, messages_sent, messages_new, messages_send
  - messages_view, messages_reply, api_unread_count
  - api_notifications, api_notification_mark_read
  - api_notifications_mark_all_read, api_notifications_unread_count
- Register messages blueprint with backward-compatible aliases
- Remove dead code from app.py (-340 lines)
- app.py: 13,398 → 13,058 lines (-2.5%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:47:55 +01:00
ad2262388b refactor: Extract forum blueprint (Phase 3)
- Create blueprints/forum/ with 10 routes:
  - forum_index, forum_new_topic, forum_topic, forum_reply
  - admin_forum, admin_forum_pin, admin_forum_lock
  - admin_forum_delete_topic, admin_forum_delete_reply
  - admin_forum_change_status
- Register forum blueprint with backward-compatible aliases
- Remove dead code from app.py (-422 lines)
- app.py: 13,820 → 13,398 lines (-3.1%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:42:18 +01:00
e06d3b172d docs: Mark Phase 2a as deployed to production
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:34:37 +01:00
0ccb1093b8 docs: Update refactoring status after Phase 2a completion
- Phase 2a marked as complete (DEV ready)
- Updated metrics: 15,577 → 13,820 lines (-11.3%)
- Documented Alias Bridge methodology
- Updated harmonogram

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:30:31 +01:00
cdd050a0ef refactor(phase2a): Cleanup dead code after blueprint migration
Removed 31 _old_ functions from app.py that were migrated to blueprints.

Stats:
- Lines removed: 1,757 (11.3% reduction)
- app.py: 15,577 → 13,820 lines

All endpoints tested and working:
- Public: /, /login, /register, /health, /release-notes
- Protected: /dashboard, /search, /kalendarz/, /chat
- Aliases: url_for('login') = url_for('auth.login')

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 07:29:31 +01:00