Ejemplo n.º 1
0
 def comments(self, start=None, end=None, limit=25):
     from server.models.comment import Comment
     if not self.hasThread():
         return []
     db = core.connect(Comment.db(self.id))
     return Comment.joinData(
         core.objects(Comment.by_created(db, limit=limit)))
Ejemplo n.º 2
0
 def hasThread(self):
     from server.models.comment import Comment
     try:
         server = core.sharedServer()
         thread = server[Comment.db(self.id)]
         return thread != None
     except Exception:
         return False
Ejemplo n.º 3
0
 def hasThread(self):
     from server.models.comment import Comment
     try:
         server = core.sharedServer()
         thread = server[Comment.db(self.id)]
         return thread != None
     except Exception:
         return False
Ejemplo n.º 4
0
 def subscribe(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     if not self.isSubscribed(aShift):
         db.create({
             "_id": "user:%s" % self.id,
             "shiftId": aShift.id,
             "type": "subscription",
             "userId": self.id,
         })
Ejemplo n.º 5
0
 def subscribe(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     if not self.isSubscribed(aShift):
         db.create({
             "_id": "user:%s" % self.id,
             "shiftId": aShift.id,
             "type": "subscription",
             "userId": self.id,
             })
Ejemplo n.º 6
0
 def testCreate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # create new comment
     newComment = Comment.create(self.fakejohn.id, newShift.id, "1st comment!")
     # shift comment db should now exist
     self.assertNotEqual(core.connect(Comment.db(newShift.id)), None)
     # shift should have thread
     self.assertTrue(newShift.hasThread())
     # should be a comment count of 1 for shift
     count = newShift.commentCount()
     self.assertEqual(count, 1)
     # should be one message in fakemary's inbox from fakejohn
     messages = self.fakemary.messages()
     self.assertEqual(len(messages), 1)
     # delete the comment
     # TODO: separate fixture - David
     newComment.delete()
     # delete the thread
     newShift.deleteThread()
Ejemplo n.º 7
0
 def testCreate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private": False})
     # create new comment
     newComment = Comment.create(self.fakejohn.id, newShift.id,
                                 "1st comment!")
     # shift comment db should now exist
     self.assertNotEqual(core.connect(Comment.db(newShift.id)), None)
     # shift should have thread
     self.assertTrue(newShift.hasThread())
     # should be a comment count of 1 for shift
     count = newShift.commentCount()
     self.assertEqual(count, 1)
     # should be one message in fakemary's inbox from fakejohn
     messages = self.fakemary.messages()
     self.assertEqual(len(messages), 1)
     # delete the comment
     # TODO: separate fixture - David
     newComment.delete()
     # delete the thread
     newShift.deleteThread()
Ejemplo n.º 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))
Ejemplo n.º 9
0
 def deleteThread(self):
     from server.models.comment import Comment
     server = core.sharedServer()
     # TODO - use bulk API to delete all comment stubs - David
     del server[Comment.db(self.id)]
Ejemplo n.º 10
0
 def comments(self, start=None, end=None, limit=25):
     from server.models.comment import Comment
     if not self.hasThread():
         return []
     db = core.connect(Comment.db(self.id))
     return Comment.joinData(core.objects(Comment.by_created(db, limit=limit)))
Ejemplo n.º 11
0
 def unsubscribe(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     if self.isSubscribed(aShift):
         del db["user:%s" % self.id]
Ejemplo n.º 12
0
 def isSubscribed(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     return db.get("user:%s" % self.id) != None
Ejemplo n.º 13
0
 def unsubscribe(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     if self.isSubscribed(aShift):
         del db["user:%s" % self.id]
Ejemplo n.º 14
0
 def isSubscribed(self, aShift):
     from server.models.comment import Comment
     db = core.connect(Comment.db(aShift.id))
     return db.get("user:%s" % self.id) != None
Ejemplo n.º 15
0
 def subscribers(self):
     from server.models.comment import Comment
     db = core.connect(Comment.db(self.id))
     return core.values(Comment.all_subscribed(db))
Ejemplo n.º 16
0
 def deleteThread(self):
     from server.models.comment import Comment
     server = core.sharedServer()
     # TODO - use bulk API to delete all comment stubs - David
     del server[Comment.db(self.id)]