def _get_next_friendly_id(context): """Get the next friendly id for a registration.""" from indico.modules.events import Event event_id = context.current_parameters['event_id'] assert event_id is not None return increment_and_get(Event._last_friendly_registration_id, Event.id == event_id)
def _get_next_friendly_id(context): """Get the next friendly id for a sub-contribution.""" from indico.modules.events.contributions.models.contributions import Contribution contribution_id = context.current_parameters['contribution_id'] assert contribution_id is not None return increment_and_get(Contribution._last_friendly_subcontribution_id, Contribution.id == contribution_id)
def _get_next_friendly_id(context): """Get the next friendly id for a survey submission.""" from indico.modules.events.surveys.models.surveys import Survey survey_id = context.current_parameters['survey_id'] assert survey_id is not None return increment_and_get(Survey._last_friendly_submission_id, Survey.id == survey_id)
def _get_next_friendly_id(context): """Get the next friendly id for a registration.""" from indico.modules.events import Event event_id = context.current_parameters["event_id"] assert event_id is not None return increment_and_get(Event._last_friendly_registration_id, Event.id == event_id)
def _get_next_friendly_id(context): """Get the next friendly id for a contribution.""" from indico.modules.events import Event event_id = context.current_parameters['event_id'] # Check first if there is a pre-allocated friendly id # (and use it in that case) friendly_ids = g.get('friendly_ids', {}).get(Contribution, {}).get(event_id, []) if friendly_ids: return friendly_ids.pop(0) assert event_id is not None return increment_and_get(Event._last_friendly_contribution_id, Event.id == event_id)
def _get_next_friendly_id(context): """Get the next friendly id for a contribution.""" from indico.modules.events import Event event_id = context.current_parameters['event_id'] # Check first if there is a pre-allocated friendly id # (and use it in that case) friendly_ids = g.get('friendly_ids', {}).get(Contribution, {}).get(event_id, []) if friendly_ids: return friendly_ids.pop(0) assert event_id is not None return increment_and_get(Event._last_friendly_contribution_id, Event.id == event_id)
def allocate_friendly_ids(cls, event, n): """Allocate n Contribution friendly_ids. This is needed so that we can allocate all IDs in one go. Not doing so could result in DB deadlocks. All operations that create more than one contribution should use this method. :param event: the :class:`Event` in question :param n: the number of ids to pre-allocate """ from indico.modules.events import Event fid = increment_and_get(Event._last_friendly_contribution_id, Event.id == event.id, n) friendly_ids = g.setdefault('friendly_ids', {}) friendly_ids.setdefault(cls, {})[event.id] = range(fid - n + 1, fid + 1)
def allocate_friendly_ids(cls, event, n): """Allocate n Contribution friendly_ids. This is needed so that we can allocate all IDs in one go. Not doing so could result in DB deadlocks. All operations that create more than one contribution should use this method. :param event: the :class:`Event` in question :param n: the number of ids to pre-allocate """ from indico.modules.events import Event fid = increment_and_get(Event._last_friendly_contribution_id, Event.id == event.id, n) friendly_ids = g.setdefault('friendly_ids', {}) friendly_ids.setdefault(cls, {})[event.id] = range(fid - n + 1, fid + 1)
def _get_next_friendly_id(context): """Get the next friendly id for a sub-contribution.""" from indico.modules.events.contributions.models.contributions import Contribution contribution_id = context.current_parameters['contribution_id'] assert contribution_id is not None return increment_and_get(Contribution._last_friendly_subcontribution_id, Contribution.id == contribution_id)
def _get_next_friendly_id(context): """Get the next friendly id for a survey submission.""" from indico.modules.events.surveys.models.surveys import Survey survey_id = context.current_parameters['survey_id'] assert survey_id is not None return increment_and_get(Survey._last_friendly_submission_id, Survey.id == survey_id)