Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Replace ~20 remaining is_admin references across backend, templates and scripts with proper SystemRole checks. Column is_admin stays as deprecated (synced by set_role()) until DB migration removes it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
102 lines
3.6 KiB
Python
102 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Rejestracja uczestników z WhatsApp na wydarzenie Chwila dla Biznesu
|
|
Tworzy konta użytkowników (bez powiadomień) i zapisuje na wydarzenie.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import secrets
|
|
from datetime import datetime
|
|
|
|
# Dodaj ścieżkę do modułów
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from database import SessionLocal, Company, User, EventAttendee
|
|
from werkzeug.security import generate_password_hash
|
|
|
|
def main():
|
|
db = SessionLocal()
|
|
|
|
# Dane do utworzenia (imię z WhatsApp, firma, email)
|
|
attendees_data = [
|
|
("Marcin Bulczak", "Renk Hurtownie", "sekretariat@renk.pl"),
|
|
("Agnieszka (Aga)", "Your Welcome", "agnieszka@yourewelcome.pl"),
|
|
("Bartosz (Bartek)", "TERMO", "biuro@termocenter.pl"),
|
|
("Daniel", "Stalpunkt", "biuro.pomorze@stalpunkt.com"),
|
|
("Paweł Cioban", "Kancelaria Ostrowski i Wspólnicy", "p.cioban@ostrowski-legal.net"),
|
|
("Sławomir Grula", "Usługi Ogólnobudowlane Sławomir Grula", "slawek1055@onet.pl"),
|
|
("Artur Czajkowski (Arturo)", "Family Art", "artczaj@gmail.com"),
|
|
]
|
|
|
|
event_id = 28
|
|
|
|
print("Tworzę konta użytkowników...")
|
|
print("=" * 60)
|
|
|
|
try:
|
|
for name, company_name, email in attendees_data:
|
|
# Sprawdź czy użytkownik już istnieje
|
|
existing_user = db.query(User).filter(User.email == email).first()
|
|
if existing_user:
|
|
print(f"→ {name}: konto już istnieje (ID {existing_user.id})")
|
|
user_id = existing_user.id
|
|
else:
|
|
# Znajdź firmę
|
|
company = db.query(Company).filter(Company.name == company_name).first()
|
|
|
|
# Utwórz użytkownika
|
|
temp_password = secrets.token_urlsafe(16)
|
|
user = User(
|
|
email=email,
|
|
name=name,
|
|
password_hash=generate_password_hash(temp_password),
|
|
is_active=True,
|
|
company_id=company.id if company else None,
|
|
created_at=datetime.now()
|
|
)
|
|
db.add(user)
|
|
db.flush()
|
|
print(f"✓ {name}: utworzono konto (ID {user.id}) - {company_name}")
|
|
user_id = user.id
|
|
|
|
# Zapisz na wydarzenie
|
|
existing_attendee = db.query(EventAttendee).filter(
|
|
EventAttendee.event_id == event_id,
|
|
EventAttendee.user_id == user_id
|
|
).first()
|
|
|
|
if existing_attendee:
|
|
print(f" → już zapisany na wydarzenie")
|
|
else:
|
|
attendee = EventAttendee(
|
|
event_id=event_id,
|
|
user_id=user_id,
|
|
registered_at=datetime.now()
|
|
)
|
|
db.add(attendee)
|
|
print(f" → zapisano na wydarzenie 28")
|
|
|
|
db.commit()
|
|
|
|
# Podsumowanie
|
|
print()
|
|
print("=" * 60)
|
|
attendees = db.query(EventAttendee).filter(EventAttendee.event_id == event_id).all()
|
|
print(f"Uczestnicy wydarzenia 28 ({len(attendees)} osób):")
|
|
for a in attendees:
|
|
user = db.query(User).filter(User.id == a.user_id).first()
|
|
company = db.query(Company).filter(Company.id == user.company_id).first() if user.company_id else None
|
|
company_name = company.name if company else "-"
|
|
print(f" • {user.name} ({company_name})")
|
|
|
|
except Exception as e:
|
|
db.rollback()
|
|
print(f"Błąd: {e}")
|
|
raise
|
|
finally:
|
|
db.close()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|