Exemple #1
0
 def delete(self):
     res = db.fetchone("DELETE FROM posts.comments "
                      "WHERE post_id=%s AND comment_id=%s "
                      "RETURNING files;",
                      [unb26(self.post.id), self.id])
     if res and res['files']:
         for f in res['files']:
             remove_attach(f)
         redis = RedisPool(settings.storage_socket)
         redis.decr('cmnt_cnt.%s' % unb26(self.post.id))
Exemple #2
0
    def delete(self):
        res = db.fetchone(
            "DELETE FROM posts.comments " "WHERE post_id=%s AND comment_id=%s " "RETURNING files;",
            [unb26(self.post.id), self.id],
        )
        if res and res["files"]:
            for f in res["files"]:
                remove_attach(f)
            redis = RedisPool(settings.storage_socket)
            redis.decr("cmnt_cnt.%s" % unb26(self.post.id))

        try:
            es = elasticsearch.Elasticsearch()
            try:
                es.delete(index="point-comments", doc_type="post", id="%s-%s" % (self.post.id, self.id))
            except elasticsearch.exceptions.NotFoundError:
                pass
        except elasticsearch.ConnectionError, e:
            log.error("Elasticsearch: %s" % e)
Exemple #3
0
    def delete(self):
        res = db.fetchone("DELETE FROM posts.comments "
                         "WHERE post_id=%s AND comment_id=%s "
                         "RETURNING files;",
                         [unb26(self.post.id), self.id])
        if res and res['files']:
            for f in res['files']:
                remove_attach(f)
            redis = RedisPool(settings.storage_socket)
            redis.decr('cmnt_cnt.%s' % unb26(self.post.id))

        try:
            es = elasticsearch.Elasticsearch()
            try:
                es.delete(index='point-comments', doc_type='post',
                          id='%s-%s' % (self.post.id, self.id))
            except elasticsearch.exceptions.NotFoundError:
                pass
        except elasticsearch.ConnectionError, e:
            log.error('Elasticsearch: %s' % e)
Exemple #4
0
def gen_invite():
    redis = RedisPool(settings.storage_socket)
    icnt = redis.decr('icnt:%s' % env.user.id)
    if icnt < 0:
        return 'Invitation limit exceeded'

    key = sha1('%s%s' % (randint(1000000, 9999999),
                         datetime.now().isoformat())).hexdigest()

    redis.set('invite:%s' % key, 1)
    redis.expire('invite:%s' % key, 3600*48)

    return key
Exemple #5
0
def gen_invite():
    redis = RedisPool(settings.storage_socket)
    icnt = redis.decr('icnt:%s' % env.user.id)
    if icnt < 0:
        return 'Invitation limit exceeded'

    key = sha1(
        '%s%s' %
        (randint(1000000, 9999999), datetime.now().isoformat())).hexdigest()

    redis.set('invite:%s' % key, 1)
    redis.expire('invite:%s' % key, 3600 * 48)

    return key