Esempio n. 1
0
  def _ValidateUpdateFollowed(self, user_id, viewpoint_id, old_timestamp, new_timestamp):
    """Validate that an older Followed record was deleted and a newer created."""
    if old_timestamp is not None and \
       Followed._TruncateToDay(new_timestamp) > Followed._TruncateToDay(old_timestamp):
      db_key = DBKey(user_id, Followed.CreateSortKey(viewpoint_id, old_timestamp))
      self.ValidateDeleteDBObject(Followed, db_key)

    self.ValidateCreateDBObject(Followed,
                                user_id=user_id,
                                viewpoint_id=viewpoint_id,
                                sort_key=Followed.CreateSortKey(viewpoint_id, new_timestamp),
                                date_updated=Followed._TruncateToDay(new_timestamp))
Esempio n. 2
0
    def _Validate(follower_id, viewpoint_id, last_updated):
      sort_key = Followed.CreateSortKey(viewpoint_id, last_updated)
      self._validator.ValidateCreateDBObject(Followed,
                                             user_id=follower_id,
                                             sort_key=sort_key,
                                             date_updated=Followed._TruncateToDay(last_updated),
                                             viewpoint_id=viewpoint_id)

      invalidate = NotificationManager._CreateViewpointInvalidation(viewpoint_id)
      self._validator.ValidateNotification('dbchk add_followed',
                                           follower_id,
                                           self._op_dict,
                                           invalidate)