Esempio n. 1
0
 def contribution_count(cls):
     from indico.modules.events.contributions.models.contributions import Contribution
     query = (db.select([
         db.func.count(Contribution.id)
     ]).where((Contribution.session_block_id == cls.id)
              & ~Contribution.is_deleted).correlate_except(Contribution))
     return db.column_property(query, deferred=True)
Esempio n. 2
0
 def subcontribution_count(cls):
     from indico.modules.events.contributions.models.subcontributions import SubContribution
     query = (db.select([
         db.func.count(SubContribution.id)
     ]).where((SubContribution.contribution_id == cls.id)
              & ~SubContribution.is_deleted).correlate_except(
                  SubContribution).scalar_subquery())
     return db.column_property(query, deferred=True)
Esempio n. 3
0
 def attachment_count(cls):
     from indico.modules.attachments.models.attachments import Attachment
     from indico.modules.attachments.models.folders import AttachmentFolder
     query = (db.select([db.func.count(Attachment.id)])
              .select_from(db.join(Attachment, AttachmentFolder, Attachment.folder_id == AttachmentFolder.id))
              .where(db.and_(
                  ~AttachmentFolder.is_deleted,
                  ~Attachment.is_deleted,
                  (getattr(AttachmentFolder, cls.ATTACHMENT_FOLDER_ID_COLUMN) == cls.id)
              ))
              .correlate_except(AttachmentFolder, Attachment))
     return db.column_property(query, deferred=True)
Esempio n. 4
0
def _make_attachment_count_column_property(cls):
    from indico.modules.attachments.models.attachments import Attachment
    from indico.modules.attachments.models.folders import AttachmentFolder
    assert cls.attachment_count is None
    query = (db.select([db.func.count(Attachment.id)])
             .select_from(db.join(Attachment, AttachmentFolder, Attachment.folder_id == AttachmentFolder.id))
             .where(db.and_(
                 ~AttachmentFolder.is_deleted,
                 ~Attachment.is_deleted,
                 (getattr(AttachmentFolder, cls.ATTACHMENT_FOLDER_ID_COLUMN) == cls.id)
             ))
             .correlate_except(AttachmentFolder, Attachment))
    cls.attachment_count = db.column_property(query, deferred=True)
Esempio n. 5
0
 def _paper_revision_count(cls):
     query = (db.select([db.func.count(PaperRevision.id)])
              .where(PaperRevision._contribution_id == cls.id)
              .correlate_except(PaperRevision))
     return db.column_property(query, deferred=True)
Esempio n. 6
0
 def is_scheduled(cls):
     from indico.modules.events.timetable.models.entries import TimetableEntry
     query = (db.exists([1])
              .where(TimetableEntry.contribution_id == cls.id)
              .correlate_except(TimetableEntry))
     return db.column_property(query, deferred=True)
Esempio n. 7
0
 def subcontribution_count(cls):
     from indico.modules.events.contributions.models.subcontributions import SubContribution
     query = (db.select([db.func.count(SubContribution.id)])
              .where((SubContribution.contribution_id == cls.id) & ~SubContribution.is_deleted)
              .correlate_except(SubContribution))
     return db.column_property(query, deferred=True)
Esempio n. 8
0
 def is_scheduled(cls):
     from indico.modules.events.timetable.models.entries import TimetableEntry
     query = (db.exists([1])
              .where(TimetableEntry.contribution_id == cls.id)
              .correlate_except(TimetableEntry))
     return db.column_property(query, deferred=True)
Esempio n. 9
0
 def _paper_revision_count(cls):
     query = (db.select([db.func.count(PaperRevision.id)])
              .where(PaperRevision._contribution_id == cls.id)
              .correlate_except(PaperRevision))
     return db.column_property(query, deferred=True)