#!/usr/bin/env python3 """ Import Kalendarza Izby NORDA 2026 do NordaBiz ============================================= Źródło: Kalendarz Izby NORDA 2026.docx (Artur Wiertel) Status: Omówiony na Radzie 07.01.2026, brak sprzeciwu Importuje: - 11 Rad Izby (luty-grudzień, 07.01 już istnieje) - 11 Chwil dla Biznesu (styczeń-listopad) - 4 wydarzenia specjalne (rajd, festyn, żagle, bal) Uruchomienie: python3 scripts/import_calendar_2026.py python3 scripts/import_calendar_2026.py --dry-run """ import os import sys from datetime import date, time from sqlalchemy import create_engine, text from sqlalchemy.orm import sessionmaker # Konfiguracja DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://nordabiz_app:CHANGE_ME@127.0.0.1:5432/nordabiz') SOURCE = "kalendarz_norda_2026" SOURCE_NOTE = "Kalendarz Izby NORDA 2026 - propozycja Artura Wiertela, omówiony na Radzie Izby 07.01.2026 (bez sprzeciwu)" # ============================================================ # DANE DO IMPORTU # ============================================================ # Rady Izby - 1. środa miesiąca, 16:00 (07.01 już istnieje) RADY_IZBY = [ # (data, opis) (date(2026, 2, 4), "Rada Izby NORDA - luty 2026"), (date(2026, 3, 4), "Rada Izby NORDA - marzec 2026"), (date(2026, 4, 1), "Rada Izby NORDA - kwiecień 2026"), (date(2026, 5, 6), "Rada Izby NORDA - maj 2026"), (date(2026, 6, 3), "Rada Izby NORDA - czerwiec 2026"), (date(2026, 7, 1), "Rada Izby NORDA - lipiec 2026"), (date(2026, 8, 5), "Rada Izby NORDA - sierpień 2026"), (date(2026, 9, 2), "Rada Izby NORDA - wrzesień 2026"), (date(2026, 10, 7), "Rada Izby NORDA - październik 2026"), (date(2026, 11, 4), "Rada Izby NORDA - listopad 2026"), (date(2026, 12, 2), "Rada Izby NORDA - grudzień 2026"), ] # Chwila dla Biznesu - ostatni czwartek miesiąca, 19:00, Hotel Olimp CHWILA_DLA_BIZNESU = [ (date(2026, 1, 29), "Chwila dla Biznesu - styczeń 2026"), (date(2026, 2, 26), "Chwila dla Biznesu - luty 2026"), (date(2026, 3, 26), "Chwila dla Biznesu - marzec 2026"), (date(2026, 4, 30), "Chwila dla Biznesu - kwiecień 2026"), (date(2026, 5, 28), "Chwila dla Biznesu - maj 2026"), (date(2026, 6, 25), "Chwila dla Biznesu - czerwiec 2026"), (date(2026, 7, 30), "Chwila dla Biznesu - lipiec 2026"), (date(2026, 8, 27), "Chwila dla Biznesu - sierpień 2026"), (date(2026, 9, 24), "Chwila dla Biznesu - wrzesień 2026"), (date(2026, 10, 29), "Chwila dla Biznesu - październik 2026"), (date(2026, 11, 26), "Chwila dla Biznesu - listopad 2026"), ] # Wydarzenia specjalne WYDARZENIA_SPECJALNE = [ { "title": "Rajd Rowerowy NORDA 2026", "event_date": date(2026, 5, 29), "event_type": "other", "time_start": time(10, 0), "time_end": time(15, 0), "location": "Start: Wejherowo (do ustalenia)", "description": "Coroczny rajd rowerowy członków Izby NORDA. Ostatni piątek maja.", }, { "title": "Festyn \"Norda na zielono\" - Park Majkowskiego", "event_date": date(2026, 6, 13), "event_type": "other", "time_start": time(10, 0), "time_end": time(18, 0), "location": "Park Majkowskiego, Wejherowo", "description": "Festyn ekologiczny we współpracy z Ekofabryką. Promocja firm członkowskich.", }, { "title": "Integracyjne Żagle w Chorwacji", "event_date": date(2026, 9, 12), "event_type": "other", "time_start": None, "time_end": None, "location": "Chorwacja (szczegóły do ustalenia)", "description": "Wyjazd integracyjny członków Izby. 12-19 września 2026. Propozycja omówiona na Radzie.", }, { "title": "Bal Integracyjny NORDA 2026", "event_date": date(2026, 11, 21), "event_type": "other", "time_start": time(18, 0), "time_end": time(23, 59), "location": "Do ustalenia", "description": "Coroczny bal integracyjny członków Izby NORDA.", "is_featured": True, }, ] def main(): dry_run = '--dry-run' in sys.argv print("=" * 60) print("IMPORT KALENDARZA NORDA 2026") print(f"Źródło: {SOURCE}") if dry_run: print("TRYB: DRY-RUN (bez zapisu)") print("=" * 60) engine = create_engine(DATABASE_URL) Session = sessionmaker(bind=engine) session = Session() try: added = 0 skipped = 0 # 1. Import Rad Izby print("\n[1/3] Rady Izby (meeting)") for event_date, title in RADY_IZBY: # Sprawdź czy już istnieje existing = session.execute( text("SELECT id FROM norda_events WHERE event_date = :d AND title LIKE '%Rada%'"), {"d": event_date} ).fetchone() if existing: print(f" → Pominięto (istnieje): {event_date} - {title}") skipped += 1 continue if not dry_run: session.execute( text(""" INSERT INTO norda_events (title, description, event_type, event_date, time_start, location, source, source_note, created_at) VALUES (:title, :desc, 'meeting', :event_date, :time_start, :location, :source, :source_note, NOW()) """), { "title": title, "desc": "Cykliczne spotkanie Rady Izby NORDA. Pierwsza środa miesiąca.", "event_date": event_date, "time_start": time(16, 0), "location": "Biuro Izby NORDA, Wejherowo", "source": SOURCE, "source_note": SOURCE_NOTE, } ) print(f" ✓ Dodano: {event_date} - {title}") added += 1 # 2. Import Chwil dla Biznesu print("\n[2/3] Chwila dla Biznesu (networking)") for event_date, title in CHWILA_DLA_BIZNESU: # Sprawdź czy już istnieje existing = session.execute( text("SELECT id FROM norda_events WHERE event_date = :d AND title LIKE '%Chwila%'"), {"d": event_date} ).fetchone() if existing: print(f" → Pominięto (istnieje): {event_date} - {title}") skipped += 1 continue if not dry_run: session.execute( text(""" INSERT INTO norda_events (title, description, event_type, event_date, time_start, location, source, source_note, created_at) VALUES (:title, :desc, 'networking', :event_date, :time_start, :location, :source, :source_note, NOW()) """), { "title": title, "desc": "Cykliczne spotkanie networkingowe członków Izby. Ostatni czwartek miesiąca, godz. 19:00.", "event_date": event_date, "time_start": time(19, 0), "location": "Hotel Olimp, Wejherowo", "source": SOURCE, "source_note": SOURCE_NOTE, } ) print(f" ✓ Dodano: {event_date} - {title}") added += 1 # 3. Import wydarzeń specjalnych print("\n[3/3] Wydarzenia specjalne") for event in WYDARZENIA_SPECJALNE: # Sprawdź czy już istnieje (po dacie i tytule) existing = session.execute( text("SELECT id FROM norda_events WHERE event_date = :d"), {"d": event["event_date"]} ).fetchone() if existing: print(f" → Pominięto (istnieje): {event['event_date']} - {event['title']}") skipped += 1 continue if not dry_run: session.execute( text(""" INSERT INTO norda_events (title, description, event_type, event_date, time_start, time_end, location, is_featured, source, source_note, created_at) VALUES (:title, :desc, :event_type, :event_date, :time_start, :time_end, :location, :is_featured, :source, :source_note, NOW()) """), { "title": event["title"], "desc": event["description"], "event_type": event["event_type"], "event_date": event["event_date"], "time_start": event.get("time_start"), "time_end": event.get("time_end"), "location": event["location"], "is_featured": event.get("is_featured", False), "source": SOURCE, "source_note": SOURCE_NOTE, } ) print(f" ✓ Dodano: {event['event_date']} - {event['title']}") added += 1 if not dry_run: session.commit() # Podsumowanie print("\n" + "=" * 60) print("PODSUMOWANIE") print("=" * 60) print(f" Dodano: {added}") print(f" Pominięto (już istnieją): {skipped}") if dry_run: print("\n [DRY-RUN] Żadne dane nie zostały zapisane.") else: print("\n✅ Import zakończony pomyślnie!") except Exception as e: session.rollback() print(f"\n❌ Błąd: {e}") sys.exit(1) finally: session.close() if __name__ == "__main__": main()