Beispiel #1
0
 def getVersions(self, state, id):
     q = Query()
     return q.searchResults(
         Eq(('entry_catalog', 'workflow_state'),
            state) &
         Eq(('entry_catalog', 'workflow_id'),
            id))     
Beispiel #2
0
 def organization(self):
     "Look-up the Organization object based on the organization attribute"
     try:
         results = Query().searchResults(
             query.Eq(('gum_catalog', 'organization_id'), self.o))
     except AssertionError, e:
         return None
Beispiel #3
0
def entriesInDateRange(from_, until):
    entries = Query().searchResults(
        query.And(query.Between(('entry_catalog', 'published'), from_, until),
                  query.Eq(('entry_catalog', 'workflow_state'), PUBLISHED)))
    
    return sorted(
        entries, key=lambda entry: entry.published, reverse=True
        )
Beispiel #4
0
def lastEntries(amount):
    entries = Query().searchResults(
        query.Eq(('entry_catalog', 'workflow_state'), PUBLISHED))
    result = sorted(entries, key=lambda entry: entry.published, reverse=True)
    if amount == -1:
        # Return all published entries
        return result
    return result[:amount]
Beispiel #5
0
    def update(self):
        if 'c' not in self.request.form:
            return

        self.c = self.request.form['c']

        self.entries = Query().searchResults((query.Eq(
            ('entry_catalog', 'workflow_state'), PUBLISHED) & AllOf(
                ('entry_catalog', 'categories'), [self.c])))
Beispiel #6
0
    def update(self):
        if 'q' not in self.request.form:
            return

        q = self.request.form['q'].strip()
        if not q:
            self.results = lastEntries(10)
            return

        entries = Query().searchResults((query.Eq(
            ('entry_catalog', 'workflow_state'), PUBLISHED) & (query.Text(
                ('entry_catalog', 'title'), q) | AllOf(
                    ('entry_catalog', 'categories'), [q]) | query.Text(
                        ('entry_catalog', 'content'), q))))
        self.results = list(islice(entries, 10))
Beispiel #7
0
    def update(self, q=None):
        if q is None:
            return self.redirect(self.application_url())

        q = q.strip()
        if not q:
            self.results = lastEntries(10)
            return

        entries = Query().searchResults((query.Eq(
            ('entry_catalog', 'workflow_state'), PUBLISHED) & (query.Text(
                ('entry_catalog', 'title'), q) | AllOf(
                    ('entry_catalog', 'categories'), [q]) | query.Text(
                        ('entry_catalog', 'content'), q))))
        self.results = list(islice(entries, 10))
Beispiel #8
0
 def hasVersionId(self, id):
     q = Query()
     result = q.searchResults(
         Eq(('entry_catalog', 'workflow_id'), id))
     return bool(len(result))
Beispiel #9
0
def allEntries(amount):
    entries = Query().searchResults(
        query.In(('entry_catalog', 'workflow_state'), (CREATED, )))

    return sorted(entries, key=lambda entry: entry.updated,
                  reverse=True)[:amount]
Beispiel #10
0
 def transcripts(self):
     "Transcript objects recording modifications made to this Group"
     transcripts = Query().searchResults(
         query.Eq( ('gum_catalog', 'dn'), self.dn )
         )
     return transcripts
Beispiel #11
0
 def transcripts(self):        
     transcripts = Query().searchResults(
         query.Eq( ('gum_catalog', 'dn'), self.request.form['dn'] )
         )
     return transcripts