コード例 #1
0
 def adminable(cls, userId, dbname=True):
     from server.models.group import Group
     db = core.connect()
     ids = core.values(Permission.by_adminable(db, key=userId))
     if dbname:
         return [Group.db(id) for id in ids]
     else:
         return ids
コード例 #2
0
 def adminable(cls, userId, dbname=True):
     from server.models.group import Group
     db = core.connect()
     ids = core.values(Permission.by_adminable(db, key=userId))
     if dbname:
         return [Group.db(id) for id in ids]
     else:
         return ids
コード例 #3
0
ファイル: ssuser.py プロジェクト: omunroe-com/shiftspace
 def followers(self, start=None, end=None, limit=25):
     from server.models.follow import Follow
     if not start:
         start = [self.id]
     if not end:
         end = [self.id, {}]
     results = Follow.followers_by_created(core.connect(), limit=limit)
     userIds = core.values(results[start:end])
     return core.fetch(keys=userIds)
コード例 #4
0
ファイル: ssuser.py プロジェクト: gmatters/shiftspace
 def followers(self, start=None, end=None, limit=25):
     from server.models.follow import Follow
     if not start:
         start = [self.id]
     if not end:
         end = [self.id, {}]
     results = Follow.followers_by_created(core.connect(), limit=limit)
     userIds = core.values(results[start:end])
     return core.fetch(keys=userIds)
コード例 #5
0
ファイル: shift.py プロジェクト: electrikfreak/shiftspace
    def shifts(cls, user, byHref=None, byDomain=None, byFollowing=False, byGroups=False, bySpace=None, start=0, limit=25, filter=False, query=None, all=False):
        from server.models.ssuser import SSUser
        db = core.connect("shiftspace/shared")
        lucene = core.lucene()
        queryString = ""
        # TODO: validate all fields - David
        
        if byHref or byDomain:
            if byHref:
                queryString = "hrefExact:\"%s_HREF_EXACT\"" % byHref
            elif byDomain:
                queryString = "domain:\"%s\""% byDomain
            if bySpace:
                queryString = queryString + " spaceName:" + bySpace
            queryString = queryString + " AND ((draft:false AND private:false)"
            if user:
                queryString = queryString + " OR createdBy:%s" % user.id
                dbs = user.readable()
                dbs.append(SSUser.db(user.id))
                dbsStr = " ".join(dbs)
                queryString = queryString + ((" OR (draft:false%s)" % ((len(dbs) > 0 and (" AND dbs:(%s)" % dbsStr)) or "")))
            queryString = queryString + ")"
        elif byFollowing:
            from server.models.follow import Follow
            # FIXME: impossible to make this scale in a simple way for many followers w/o p2p - David 12/2/09
            # when p2p we can tag the shift as a follow shift when we get it
            results = Follow.following_by_created(core.connect())
            following = " ".join(core.values(results[[user.id]:[user.id, {}]]))
            queryString = "(draft:false AND private:false AND createdBy:(%s)) OR dbs:(%s)" % (following, SSUser.db(user.id))
        elif byGroups:
            from server.models.group import Group
            queryString = "dbs:(%s)" % " ".join(user.readable())
        if filter:
            queryString = queryString + " AND " + core.dictToQuery(query)

        print queryString
        try:
            if all:
                rows = lucene.search(db, "shifts", q=queryString, include_docs=True, sort="\modified")
            else:
                rows = lucene.search(db, "shifts", q=queryString, include_docs=True, sort="\modified", skip=start, limit=limit)
        except Exception, err:
            print err
            return []
コード例 #6
0
ファイル: shift.py プロジェクト: electrikfreak/shiftspace
 def subscribers(self):
     from server.models.comment import Comment
     db = core.connect(Comment.db(self.id))
     return core.values(Comment.all_subscribed(db))
コード例 #7
0
    def shifts(cls,
               user,
               byHref=None,
               byDomain=None,
               byFollowing=False,
               byGroups=False,
               bySpace=None,
               start=0,
               limit=25,
               filter=False,
               query=None,
               all=False):
        from server.models.ssuser import SSUser
        db = core.connect("shiftspace/shared")
        lucene = core.lucene()
        queryString = ""
        # TODO: validate all fields - David

        if byHref or byDomain:
            if byHref:
                queryString = "hrefExact:\"%s_HREF_EXACT\"" % byHref
            elif byDomain:
                queryString = "domain:\"%s\"" % byDomain
            if bySpace:
                queryString = queryString + " spaceName:" + bySpace
            queryString = queryString + " AND ((draft:false AND private:false)"
            if user:
                queryString = queryString + " OR createdBy:%s" % user.id
                dbs = user.readable()
                dbs.append(SSUser.db(user.id))
                dbsStr = " ".join(dbs)
                queryString = queryString + ((" OR (draft:false%s)" % (
                    (len(dbs) > 0 and (" AND dbs:(%s)" % dbsStr)) or "")))
            queryString = queryString + ")"
        elif byFollowing:
            from server.models.follow import Follow
            # FIXME: impossible to make this scale in a simple way for many followers w/o p2p - David 12/2/09
            # when p2p we can tag the shift as a follow shift when we get it
            results = Follow.following_by_created(core.connect())
            following = " ".join(core.values(results[[user.id]:[user.id, {}]]))
            queryString = "(draft:false AND private:false AND createdBy:(%s)) OR dbs:(%s)" % (
                following, SSUser.db(user.id))
        elif byGroups:
            from server.models.group import Group
            queryString = "dbs:(%s)" % " ".join(user.readable())
        if filter:
            queryString = queryString + " AND " + core.dictToQuery(query)

        print queryString
        try:
            if all:
                rows = lucene.search(db,
                                     "shifts",
                                     q=queryString,
                                     include_docs=True,
                                     sort="\modified")
            else:
                rows = lucene.search(db,
                                     "shifts",
                                     q=queryString,
                                     include_docs=True,
                                     sort="\modified",
                                     skip=start,
                                     limit=limit)
        except Exception, err:
            print err
            return []
コード例 #8
0
 def subscribers(self):
     from server.models.comment import Comment
     db = core.connect(Comment.db(self.id))
     return core.values(Comment.all_subscribed(db))