Esempio 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)))
Esempio 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
Esempio 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
Esempio 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,
         })
Esempio 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,
             })
 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()
 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()
Esempio 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))
Esempio 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)]
Esempio 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)))
Esempio 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]
Esempio 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
Esempio 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]
Esempio 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
Esempio 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))
Esempio 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)]