How to use the indico.core.db.db.relationship function in indico

To help you get started, weโ€™ve selected a few indico examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indico / indico / indico / modules / users / models / users.py View on Github external
is_deleted = db.Column(
        'is_deleted',
        db.Boolean,
        nullable=False,
        default=False
    )

    _affiliation = db.relationship(
        'UserAffiliation',
        lazy=False,
        uselist=False,
        cascade='all, delete-orphan',
        backref=db.backref('user', lazy=True)
    )

    _primary_email = db.relationship(
        'UserEmail',
        lazy=False,
        uselist=False,
        cascade='all, delete-orphan',
        primaryjoin='(User.id == UserEmail.user_id) & UserEmail.is_primary'
    )
    _secondary_emails = db.relationship(
        'UserEmail',
        lazy=True,
        cascade='all, delete-orphan',
        collection_class=set,
        primaryjoin='(User.id == UserEmail.user_id) & ~UserEmail.is_primary'
    )
    _all_emails = db.relationship(
        'UserEmail',
        lazy=True,
github indico / indico / indico / modules / events / sessions / models / types.py View on Github external
name = db.Column(
        db.String,
        nullable=False
    )
    code = db.Column(
        db.String,
        nullable=False,
        default=''
    )
    is_poster = db.Column(
        db.Boolean,
        nullable=False,
        default=False
    )

    event = db.relationship(
        'Event',
        lazy=True,
        backref=db.backref(
            'session_types',
            cascade='all, delete-orphan',
            lazy=True
        )
    )

    # relationship backrefs:
    # - sessions (Session.type)

    @return_ascii
    def __repr__(self):
        return format_repr(self, 'id', _text=self.name)
github indico / indico / indico / core / storage / models.py View on Github external
def all_files(cls):
        return db.relationship(
            cls.stored_file_class,
            primaryjoin=lambda: cls.id == getattr(cls.stored_file_class, cls.stored_file_fkey),
            foreign_keys=lambda: getattr(cls.stored_file_class, cls.stored_file_fkey),
            lazy=True,
            cascade='all, delete, delete-orphan',
            order_by=lambda: cls.stored_file_class.created_dt.desc(),
            backref=db.backref(
                getattr(cls.stored_file_class, 'version_of'),
                lazy=False
            )
github indico / indico / indico / modules / groups / models / groups.py View on Github external
{'schema': 'users'})

    #: the unique id of the group
    id = db.Column(
        db.Integer,
        primary_key=True
    )
    #: the name of the group
    name = db.Column(
        db.String,
        nullable=False,
        index=True
    )

    #: the users in the group
    members = db.relationship(
        'User',
        secondary='users.group_members',
        lazy=True,
        collection_class=set,
        backref=db.backref('local_groups', lazy=True, collection_class=set),
    )

    # relationship backrefs:
    # - in_attachment_acls (AttachmentPrincipal.local_group)
    # - in_attachment_folder_acls (AttachmentFolderPrincipal.local_group)
    # - in_blocking_acls (BlockingPrincipal.local_group)
    # - in_category_acls (CategoryPrincipal.local_group)
    # - in_contribution_acls (ContributionPrincipal.local_group)
    # - in_event_acls (EventPrincipal.local_group)
    # - in_event_settings_acls (EventSettingPrincipal.local_group)
    # - in_room_acls (RoomPrincipal.local_group)
github indico / indico / indico / modules / events / contributions / models / contributions.py View on Github external
db.Integer,
        nullable=False,
        default=0
    ))

    event = db.relationship(
        'Event',
        lazy=True,
        backref=db.backref(
            'contributions',
            primaryjoin='(Contribution.event_id == Event.id) & ~Contribution.is_deleted',
            cascade='all, delete-orphan',
            lazy=True
        )
    )
    session = db.relationship(
        'Session',
        lazy=True,
        backref=db.backref(
            'contributions',
            primaryjoin='(Contribution.session_id == Session.id) & ~Contribution.is_deleted',
            lazy=True
        )
    )
    session_block = db.relationship(
        'SessionBlock',
        lazy=True,
        foreign_keys=[session_block_id],
        backref=db.backref(
            'contributions',
            primaryjoin='(Contribution.session_block_id == SessionBlock.id) & ~Contribution.is_deleted',
            lazy=True
github indico / indico / indico / modules / events / registration / models / forms.py View on Github external
)
    #: Whether the notifications for this event are enabled
    notifications_enabled = db.Column(
        db.Boolean,
        nullable=False,
        default=False
    )
    #: List of emails that should be notified on specific events
    recipients_emails = db.Column(
        ARRAY(db.String),
        nullable=False,
        default=[]
    )

    #: The Event containing this registration form
    event_new = db.relationship(
        'Event',
        lazy=True,
        backref=db.backref(
            'registration_forms',
            lazy='dynamic'
        )
    )
    # The items (sections, text, fields) in the form
    form_items = db.relationship(
        'RegistrationFormItem',
        lazy=True,
        cascade='all, delete-orphan',
        order_by='RegistrationFormItem.position',
        backref=db.backref(
            'registration_form',
            lazy=True
github indico / indico / indico / modules / users / models / users.py View on Github external
lazy='dynamic',
        order_by='SuggestedCategory.score.desc()',
        cascade='all, delete-orphan',
        backref=db.backref('user', lazy=True)
    )
    #: the active API key of the user
    api_key = db.relationship(
        'APIKey',
        lazy=True,
        uselist=False,
        cascade='all, delete-orphan',
        primaryjoin='(User.id == APIKey.user_id) & APIKey.is_active',
        back_populates='user'
    )
    #: the previous API keys of the user
    old_api_keys = db.relationship(
        'APIKey',
        lazy=True,
        cascade='all, delete-orphan',
        order_by='APIKey.created_dt.desc()',
        primaryjoin='(User.id == APIKey.user_id) & ~APIKey.is_active',
        back_populates='user'
    )
    #: the identities used by this user
    identities = db.relationship(
        'Identity',
        lazy=True,
        cascade='all, delete-orphan',
        collection_class=set,
        backref=db.backref('user', lazy=False)
    )
github indico / indico / indico / modules / events / abstracts / models / abstracts.py View on Github external
)
    )
    submitted_for_tracks = db.relationship(
        'Track',
        secondary='event_abstracts.submitted_for_tracks',
        collection_class=set,
        backref=db.backref(
            'abstracts_submitted',
            primaryjoin='event_abstracts.submitted_for_tracks.c.track_id == Track.id',
            secondaryjoin='(event_abstracts.submitted_for_tracks.c.abstract_id == Abstract.id) & ~Abstract.is_deleted',
            collection_class=set,
            lazy=True,
            passive_deletes=True
        )
    )
    reviewed_for_tracks = db.relationship(
        'Track',
        secondary='event_abstracts.reviewed_for_tracks',
        collection_class=set,
        backref=db.backref(
            'abstracts_reviewed',
            primaryjoin='event_abstracts.reviewed_for_tracks.c.track_id == Track.id',
            secondaryjoin='(event_abstracts.reviewed_for_tracks.c.abstract_id == Abstract.id) & ~Abstract.is_deleted',
            collection_class=set,
            lazy=True,
            passive_deletes=True
        )
    )
    #: User who judged the abstract
    judge = db.relationship(
        'User',
        lazy=True,
github indico / indico / indico / modules / events / layout / models / images.py View on Github external
#: The ID of the file
    id = db.Column(
        db.Integer,
        primary_key=True
    )

    #: The event the image belongs to
    event_id = db.Column(
        db.Integer,
        db.ForeignKey('events.events.id'),
        nullable=False,
        index=True
    )

    event = db.relationship(
        'Event',
        lazy=False,
        backref=db.backref(
            'layout_images',
            lazy='dynamic'
        )
    )

    # relationship backrefs:
    # - legacy_mapping (LegacyImageMapping.image)

    @property
    def locator(self):
        return dict(self.event.locator, image_id=self.id, filename=self.filename)

    def _build_storage_path(self):
github indico / indico / indico / modules / events / abstracts / models / legacy.py View on Github external
'Contribution',
        lazy=True,
        uselist=False,
        primaryjoin='(Contribution.abstract_id == LegacyAbstract.id) & ~Contribution.is_deleted',
        foreign_keys='Contribution.abstract_id'
    )
    type = db.relationship(
        'ContributionType',
        lazy=True,
        foreign_keys=[type_id],
        backref=db.backref(
            'legacy_abstracts',
            lazy=True
        )
    )
    accepted_type = db.relationship(
        'ContributionType',
        lazy=True,
        foreign_keys=[accepted_type_id],
        backref=db.backref(
            'legacy_accepted_as_abstracts',
            lazy=True
        )
    )

    # relationship backrefs:
    # - judgments (Judgment.abstract)

    @locator_property
    def locator(self):
        return dict(self.event_new.locator, abstractId=self.friendly_id, confId=self.event_id)