django_program.pretalx.sync

Synchronization service for importing Pretalx data into Django models.

Provides PretalxSyncService which orchestrates the import of speakers, talks, and schedule slots from a Pretalx event into the corresponding Django models. Each sync method is idempotent and uses bulk operations for performance.

Classes

PretalxSyncService

Synchronizes speaker, talk, and schedule data from Pretalx to Django models.

class django_program.pretalx.sync.PretalxSyncService[source]

Bases: object

Synchronizes speaker, talk, and schedule data from Pretalx to Django models.

Builds a PretalxClient from the conference’s pretalx_event_slug and the global Pretalx configuration, then provides methods to sync each entity type individually or all at once.

Parameters:

conference (Conference) – The conference whose Pretalx data should be synced.

Raises:

ValueError – If the conference has no pretalx_event_slug configured.

__init__(conference)[source]

Initialize the sync service for the given conference.

Parameters:

conference (Conference) – The conference whose Pretalx data should be synced.

Raises:

ValueError – If the conference has no pretalx_event_slug configured.

sync_rooms()[source]

Fetch rooms from Pretalx and upsert into the database.

Return type:

int

Returns:

The number of rooms synced.

sync_speakers()[source]

Fetch speakers from Pretalx and upsert into the database.

Uses bulk operations for performance and delegates to sync_speakers_iter() which yields progress dicts.

Return type:

int

Returns:

The number of speakers synced.

sync_speakers_iter()[source]

Bulk sync speakers from Pretalx, yielding progress updates.

Yields:

A {"phase": "fetching"} dict before the API call, dicts with current/total keys during processing, and a final dict with count when complete.

Return type:

Iterator[dict[str, int | str]]

sync_talks()[source]

Fetch talks from Pretalx and upsert into the database.

Uses bulk operations for performance and delegates to sync_talks_iter() which yields progress dicts.

Return type:

int

Returns:

The number of talks synced.

sync_talks_iter()[source]

Bulk sync talks from Pretalx, yielding progress updates.

Yields:

A {"phase": "fetching"} dict before the API call, dicts with current/total keys during processing, and a final dict with count when complete.

Return type:

Iterator[dict[str, int | str]]

sync_schedule(*, allow_large_deletions=False)[source]

Fetch schedule slots from Pretalx and upsert into the database.

Slots that no longer appear in the Pretalx schedule are deleted after the sync completes.

Parameters:

allow_large_deletions (bool) – When True, bypasses the schedule-drop safety guard and permits large stale-slot deletions.

Return type:

tuple[int, int]

Returns:

A tuple of (synced_count, unscheduled_count) where unscheduled_count is the number of talks that still have no scheduled slot after the sync.

apply_type_defaults()[source]

Apply SubmissionTypeDefault records to unscheduled talks.

For each configured submission type default, finds talks of that type that have no room assigned and applies the default room and time slot.

Return type:

int

Returns:

The number of talks that were modified by type defaults.

sync_all(*, allow_large_deletions=False)[source]

Run all sync operations in dependency order.

Return type:

dict[str, int]

Returns:

A mapping of entity type to the number synced. The schedule_slots key contains only the synced count; unscheduled_talks is added when any talks lack a slot. type_defaults_applied is added when type defaults modify any talks.

Parameters:

allow_large_deletions (bool)