Exemplo n.º 1
0
def delete_comment_by_comment_id(id, uid, pid):
    db.delete('_post_comments',
              vars=dict(id=id, uid=uid),
              where='id = $id and uid = $uid')
    #更新post评论数
    db.query("UPDATE _post set comment_num=comment_num-1 WHERE id=$id",
             vars=dict(id=pid))
Exemplo n.º 2
0
def save_category_relationships(object_id, category_ids, new=False):
    if not isinstance(category_ids, list):
        return False

    category_ids = web.uniq(category_ids)

    if not category_ids:
        return False

    t = db.transaction()
    try:
        if new:
            add_category_ids = category_ids
        else:
            old_category_relationships = db.select('object_category_relationships', what='category_id', where='object_id=$object_id', vars={'object_id': object_id})
            old_category_ids = [category['category_id'] for category in old_category_relationships]
            del_category_ids = set(old_category_ids) - set(category_ids)
            add_category_ids = set(category_ids) - set(old_category_ids)

            if del_category_ids:
                db.delete('object_category_relationships', where='object_id=$object_id AND category_id IN $del_category_ids', vars={'object_id': object_id, 'del_category_ids': list(del_category_ids)})

        if add_category_ids:
            db.multiple_insert('object_category_relationships', [{'category_id': category_id, 'object_id': object_id} for category_id in add_category_ids])
    except:
        t.rollback()
        return False
    else:
        t.commit()
        return True
Exemplo n.º 3
0
def del_category(ids=None, where=None, vars=None):
    if ids:
        if isinstance(ids, int):
            where = 'id=$id'
            vars = {'id': ids}
        elif isinstance(ids, list):
            if ids:
                where = 'id IN $ids'
                vars = {'ids': ids}
        else:
            return False

    if where is None:
        return False

    t = db.transaction()
    try:
        count = db.delete('categories', where=where, vars=vars)
        db.delete('object_category_relationships', where='category_id IN $ids', vars={'ids': ids})
    except:
        t.rollback()
        return False
    else:
        t.commit()
        return count
Exemplo n.º 4
0
 def setDb(self, data):
     import re
     db.delete("listdb", where="Name LIKE \"%\"")
     for line in data.splitlines():
         if re.match(r"^\d{8}-.{1,10}-(\d{6}|\d{11})$", line.strip()):
             no, name, phone = line.split('-')
             db.insert("listdb", No=no, Name=name, Phone=phone)
Exemplo n.º 5
0
 def on_delete(self, req, resq, id):
     customer = db.query(Customer).filter(Customer.id == id).first()
     if customer is None:
         raise falcon.HTTPNotFound()
     db.delete(customer)
     db.commit()
     db.close()
Exemplo n.º 6
0
 def setDb(self,data):
     import re
     db.delete("listdb",where="Name LIKE \"%\"")
     for line in data.splitlines():
         if re.match(r"^\d{8}-.{1,10}-(\d{6}|\d{11})$",line.strip()):
             no,name,phone=line.split('-')
             db.insert("listdb",No=no,Name=name,Phone=phone,Total=0)
Exemplo n.º 7
0
def CancelFavorite(u_id, i_id):
    db.delete('ImageFavorite',
              vars=dict(img_id=i_id, user_id=u_id),
              where='img_id = $img_id and user_id = $user_id')
    #同时删除image里的‘favo_num’字段
    db.query("UPDATE image set favo_num=favo_num-1 WHERE id=$id",
             vars=dict(id=i_id))
Exemplo n.º 8
0
def save_tag_relationships(object_id, model, tags=None, new=False):
    if isinstance(tags, (unicode, str)):
        tags = tags.split(',')

    if not isinstance(tags, list):
        return False

    tags = [tag.strip() for tag in tags if tag]
    tags = web.uniq(tags)

    if not tags:
        return False

    t = db.transaction()
    try:
        new_tag_ids = new_tags(tags)
        if new:
            add_tag_ids = new_tag_ids
        else:
            old_tag_relationships = db.select('object_tag_relationships', what='tag_id', where='object_id=$object_id AND model=$model', vars={'object_id': object_id, 'model': model})
            old_tag_ids = [tag['tag_id'] for tag in old_tag_relationships]
            del_tag_ids = set(old_tag_ids) - set(new_tag_ids)
            add_tag_ids = set(new_tag_ids) - set(old_tag_ids)

            if del_tag_ids:
                db.delete('object_tag_relationships', where='object_id=$object_id AND model=$model AND tag_id IN $del_tag_ids', vars={'object_id': object_id, 'model': model, 'del_tag_ids': list(del_tag_ids)})

        if add_tag_ids:
            db.multiple_insert('object_tag_relationships', [{'tag_id': tag_id, 'object_id': object_id, 'model': model} for tag_id in add_tag_ids])
    except:
        t.rollback()
        return False
    else:
        t.commit()
        return True
Exemplo n.º 9
0
def DeleteImageByImageID(imageId, userID):
    db.delete('image',
              vars=dict(id=imageId, userID=userID),
              where='id = $id and userID = $userID')
    # 喜欢表里的也要做处理,要不然列出用户喜欢的图片时会有问题
    db.delete('ImageFavorite',
              vars=dict(img_id=imageId),
              where='img_id = $img_id')
Exemplo n.º 10
0
def GET(web):
    """
    This shows how to do a simple database setup. You can also just
    import the db inside the .html file if you want and don't need
    to go to a handler first.
    """
    if web.sub_path == "/delete":
        db.delete("test", where="id = $id", vars=web.params)

    return render("showdb.html", web)
Exemplo n.º 11
0
def GET(web):
    """
    This shows how to do a simple database setup. You can also just
    import the db inside the .html file if you want and don't need
    to go to a handler first.
    """
    if web.sub_path == '/delete':
        db.delete('test', where='id = $id', vars=web.params)

    return render("showdb.html", web)
Exemplo n.º 12
0
	def run(self):
		"""
		Deletion expired articles
		on a regular basis
		"""
		cleanup_deadline = (datetime.now() -  timedelta(
			days=int(Config.CLEANUP_DEADLINE)))
		expired_offers = db.query(Offer).filter(
			Offer.pub_date <= cleanup_deadline).all()

		for expired_offer in expired_offers:
			db.delete(expired_offer)
		db.commit()
		
		return True
Exemplo n.º 13
0
def delete_user(uid):
    """
    회원 정보 삭제.
    """
    result = get_owned_board(uid)
    has_board = False
    for b in result:
        has_board = True
    if has_board:
        return (False, _('HAS_BOARD'))

    # 즐겨찾는 보드 삭제
    result = get_favorite_board(uid)
    for b in result:
        remove_favorite_board(uid, b.bSerial)

    val = dict(user_id = uid)
    t = db.transaction()
    try:
        result = db.delete('Users', vars=val, where='uSerial = $user_id')
    except:
        t.rollback()
        return (False, _('DATABASE_ERROR'))
    else:
        t.commit()
    return (True, _('SUCCESS'))
Exemplo n.º 14
0
def deleteMatch(match_id):
    rowcount = db.delete('tmatch',
                where='match_id=$match_id',
                vars={'match_id':match_id})

    if rowcount != 1:
        error = "Bad number of rows deleted: "
Exemplo n.º 15
0
Arquivo: pm.py Projeto: peremen/noah3k
def delete_mail(mail_id):
    t = db.transaction()
    try:
        result = db.delete('Mails', vars=locals(), where='mSerial = $mail_id')
    except:
        t.rollback()
        return (False, _('DATABASE_ERROR'))
    else:
        t.commit()
        return (True, _('SUCCESS'))
Exemplo n.º 16
0
def remove_subscription_board(uid, board_id):
    val = dict(uid = uid, board_id = board_id)
    t = db.transaction()
    try:
        result = db.delete('Subscriptions', vars=val, where='uSerial = $uid AND bSerial = $board_id')
    except:
        t.rollback()
    else:
        t.commit()
    return result
Exemplo n.º 17
0
def remove_login_info(username, timestamp):
    time = datetime.datetime.fromtimestamp(timestamp)
    val = dict(username=username, time=time)
    t = db.transaction()
    try:
        result = db.delete('login_temp', vars=val, where='logintime=$time AND id=$username')
    except:
        t.rollback()
        return False
    else:
        t.commit()
        return True
Exemplo n.º 18
0
def delete_board(current_uid, board_id):
    original_board_info = get_board_info(board_id)
    old_path = original_board_info.bName
    if not acl.is_allowed('board', board_id, current_uid, 'delete'):
        return (False, _('NO_PERMISSION'))
    val = dict(old_path = old_path + r'/%')
    has_child = False
    result = db.select('Boards', val, where = 'bName LIKE $old_path')
    for r in result:
        if (r.bName == old_path) or (not r.bName.startswith(old_path)):
            continue
        has_child = True
    if has_child:
        return (False, _('HAS_CHILD'))
    val = dict(board_id = board_id)
    result = db.delete('Boards', vars=val, where='bSerial = $board_id')
    delete_all_article(board_id)
    return (True, posixpath.dirname(old_path))
Exemplo n.º 19
0
def del_user(ids=None, where=None, vars=None):
    if ids:
        if isinstance(ids, int) and ids != ROOT_ID:
            where = 'id=$id'
            vars = {'id': ids}
        elif isinstance(ids, list):
            if ROOT_ID in ids:
                ids.remove(ROOT_ID)

            if ids:
                where = 'id IN $ids'
                vars = {'ids': ids}
        else:
            return False

    if where is None:
        return False

    return db.delete('users', where=where, vars=vars)
Exemplo n.º 20
0
 def do_del(self,line):
     db.delete("bugs",where="Pid =%d and IsOver = 0"%int(line))
Exemplo n.º 21
0
def del_rec_post(pid):
    db.delete('_admin_rec_home', vars=dict(pid=pid), where='pid = $pid')
Exemplo n.º 22
0
def delete(table, id):
	db.delete(table, where='id=$id', vars=locals())
	if (table == 'invoice'):
		for item in get_invoice_items(id):
			delete_from_db('item', item.id)
Exemplo n.º 23
0
def del_page_content(content):
    db.delete('content', where="id=$content", vars=locals())
Exemplo n.º 24
0
def del_link(id):
    db.delete('link', where="id=$id", vars = locals())
Exemplo n.º 25
0
def delVoteUser(pid, uid):
    db.delete('_post_vote_user', vars = dict(pid=pid, uid = uid), where = 'pid = $pid and uid = $uid')
Exemplo n.º 26
0
 def do_del(self,pid):
     if self.uid==0:
         db.delete("bugs",where="Pid = %d and IsOver = 1"%int(pid))
Exemplo n.º 27
0
def read_article(uid, aSerial):
    val = dict(uid = uid, aSerial = aSerial)
    db.delete('UserArticles', vars=val, where='uSerial = $uid and aSerial = $aSerial')
Exemplo n.º 28
0
def read_all_articles(uid):
    val = dict(uid = uid)
    db.delete('UserArticles', vars=val, where='uSerial = $uid')
Exemplo n.º 29
0
def del_article_by_name(name):
    db.delete('articles',vars=dict(name=name),where="name=$name")
Exemplo n.º 30
0
def del_verification_data_by_douban_id(douban_id):
    db.delete('_confirm_email', vars = dict(douban_id=douban_id), where = 'douban_id = $douban_id')
Exemplo n.º 31
0
def del_verification_data_by_token(token):
    db.delete('_confirm_email', vars = dict(token=token), where = 'token = $token')
Exemplo n.º 32
0
def delete_milestone(id):
    db.delete('milestone', where='id=$id', vars=locals())
Exemplo n.º 33
0
def DeleteImageByImageID(imageId, userID):
    db.delete('image', vars = dict(id=imageId, userID=userID), where = 'id = $id and userID = $userID')
    # 喜欢表里的也要做处理,要不然列出用户喜欢的图片时会有问题
    db.delete('ImageFavorite', vars = dict(img_id=imageId), where = 'img_id = $img_id')
Exemplo n.º 34
0
Arquivo: db.py Projeto: zz2/ihere
def clear_old_session(time_point=None):
    if time_point is None:
        time_point = time.strftime("%Y-%m-%d %H:%M:%S", 
            time.localtime(time.time-12*60*60))
    db.delete('session', where='atime<$time_point', vars=locals())
Exemplo n.º 35
0
def CancelFavorite(u_id, i_id):
    db.delete('ImageFavorite', vars = dict(img_id=i_id, user_id = u_id), where = 'img_id = $img_id and user_id = $user_id')
    #同时删除image里的‘favo_num’字段
    db.query("UPDATE image set favo_num=favo_num-1 WHERE id=$id", vars=dict(id=i_id))
Exemplo n.º 36
0
def delete_comment_by_comment_id(id, uid, pid):
    db.delete('_post_comments', vars = dict(id=id, uid = uid), where = 'id = $id and uid = $uid')
    #更新post评论数
    db.query("UPDATE _post set comment_num=comment_num-1 WHERE id=$id", vars=dict(id=pid))
Exemplo n.º 37
0
def DeleteCommentByCommentID(id, user_id, img_id):
    db.delete('ImageComments',
              vars=dict(id=id, user_id=user_id),
              where='id = $id and user_id = $user_id')
    db.query("UPDATE image set comm_num=comm_num-1 WHERE id=$id",
             vars=dict(id=img_id))
Exemplo n.º 38
0
def del_user(username):
    db.delete('user', where = "username=$username", vars=locals())
Exemplo n.º 39
0
def delVoteUser(pid, uid):
    db.delete('_post_vote_user',
              vars=dict(pid=pid, uid=uid),
              where='pid = $pid and uid = $uid')
Exemplo n.º 40
0
def del_page(name):
    db.delete('page', where="name = $name", vars = locals())
Exemplo n.º 41
0
def create_db():
    db.delete(session.Session)
    db.delete(registration.Registration)
    db.delete(notification.Notification)
    db.delete(contact.Contact)
    db.delete(event.Event)
    db.delete(organization.Organization)
    db.delete(user.User)

    db.create_all()

    test_contact = contact.Contact(dob=datetime.utcnow(),
                                   phone=123456,
                                   address="123 South st, City",
                                   state="California",
                                   zipcode=90732,
                                   country="USA")
    test_contact1 = contact.Contact(dob=datetime.utcnow(),
                                    phone=7146523,
                                    address="123 Harbor st, City",
                                    state="California",
                                    zipcode=90882,
                                    country="USA")
    db.session.add(test_contact)
    db.session.add(test_contact1)

    test_user = user.User(password="******",
                          email="*****@*****.**",
                          name="Phuong Nguyen")

    test_user1 = user.User(password="******",
                           email="*****@*****.**",
                           name="Khuong Le")

    test_user2 = user.User(password="******",
                           email="*****@*****.**",
                           name="Josh")

    db.session.add(test_user)
    db.session.add(test_user1)

    test_org = organization.Organization(org_name="Computer Science Society",
                                         categories="CS",
                                         contact=test_contact)

    test_org1 = organization.Organization(
        org_name="Software Engineer Association",
        categories="CS",
        contact=test_contact1)
    db.session.add(test_org)
    db.session.add(test_org1)

    test_role = role.Role(user=test_user,
                          organization=test_org,
                          role=role.Roles.CHAIRMAN)

    test_role1 = role.Role(user=test_user1,
                           organization=test_org1,
                           role=role.Roles.CHAIRMAN)

    test_role2 = role.Role(user=test_user2,
                           organization=test_org,
                           role=role.Roles.ADMIN)

    db.session.add(test_role)
    db.session.add(test_role1)
    db.session.add(test_role2)

    temp_id = db.session.query(user.User).first()
    test_session = session.Session(user_id=temp_id.user_id,
                                   expires=datetime.now())

    db.session.add(test_session)

    test_event = event.Event(creator=test_user,
                             organization=test_org,
                             event_name='ADMIN testing',
                             start_date=datetime.now(tz=None),
                             end_date=datetime.now(tz=None),
                             theme='Training',
                             perks='Perks',
                             categories="info",
                             info='categories',
                             phase=event.EventPhase.INITIALIZED,
                             contact=test_contact)

    test_event1 = event.Event(creator=test_user1,
                              organization=test_org1,
                              event_name='CHAIRMAN testing',
                              start_date=datetime.now(tz=None),
                              end_date=datetime.now(tz=None),
                              theme='Training',
                              perks='Perks',
                              categories="info",
                              info='categories',
                              phase=event.EventPhase.APPROVED,
                              contact=test_contact1)

    test_event2 = event.Event(creator=test_user1,
                              organization=test_org1,
                              event_name='CHAIRMAN testing gg',
                              start_date=datetime.now(tz=None),
                              end_date=datetime.now(tz=None),
                              theme='Training',
                              perks='Perks',
                              categories="info",
                              info='categories',
                              phase=event.EventPhase.ARCHIVED,
                              contact=test_contact1)
    db.session.add(test_event)
    db.session.add(test_event1)
    db.session.add(test_event2)

    db.session.commit()
Exemplo n.º 42
0
 def do_del(self,line):
     db.delete("bugs",where="Pid =%d and IsOver = 0"%int(line))
Exemplo n.º 43
0
def delete_question(question_id):
    '''Deletes a question and its weights for a particular question_id.'''
    db.delete('questions', where='id=$question_id', vars=locals())
    db.delete('data', where='question_id=$question_id', vars=locals())
Exemplo n.º 44
0
def delete():
    db.delete("delete from user where id = %s", [25])
Exemplo n.º 45
0
def delete_object(object_id):
    '''Deletes an object and its weights for a particular object_id.'''
    db.delete('objects', where='id=$object_id', vars=locals())
    db.delete('data', where='object_id=$object_id', vars=locals())
Exemplo n.º 46
0
def del_rec_node(nid):
    db.delete('_admin_rec_home', vars=dict(nid=nid), where='nid = $nid')
Exemplo n.º 47
0
 def POST(self):
     db.delete("bugs", where="Name LIKE \"%\"")
     return "故障已被清空"
Exemplo n.º 48
0
 def do_del(self,pid):
     if self.uid==0:
         db.delete("bugs",where="Pid = %d and IsOver = 1"%int(pid))
Exemplo n.º 49
0
def delete_comment(user_id, id):
    db.delete('comments',
        vars = dict(user_id=user_id, id=id),
        where = 'user_id = $user_id and id = $id')
Exemplo n.º 50
0
def DeleteCommentByCommentID(id, user_id, img_id):
    db.delete('ImageComments', vars = dict(id=id, user_id = user_id), where = 'id = $id and user_id = $user_id')
    db.query("UPDATE image set comm_num=comm_num-1 WHERE id=$id", vars=dict(id=img_id))
Exemplo n.º 51
0
def del_rec_node(nid):
    db.delete('_admin_rec_home', vars = dict(nid=nid), where = 'nid = $nid')