コード例 #1
0
ファイル: views.py プロジェクト: ChungHanWong/indiv
def purchase () :
    current_user = get_jwt_identity()
    purchased_artwork = Picture.select().where(Picture.buyer_id==current_user)
    bidding_artwork = Picture.select().where((Picture.bidder_id== current_user) & (Picture.buyer_id == None) )
    purchased_info = []
    for p in purchased_artwork : 
        art_art = {}
        art_art['name'] = p.name
        art_art['category'] = p.category
        art_art['description'] = p.description
        art = Picture.get(Picture.name == p.name).profilepic_url
        art_art['image'] = art
        art_art['id'] = p.id
        art_art['price'] = p.price
        art_art['paid'] = p.paid
        purchased_info.append(art_art)
    
    bidding_info = []

    for b in bidding_artwork :
        bid_bid = {}
        bid_bid['name'] = b.name
        bid_bid['category'] = b.category
        bid_bid['description'] = b.description
        art = Picture.get(Picture.name == b.name).profilepic_url
        bid_bid['image'] = art
        bid_bid['id'] = b.id
        bid_bid['price'] = b.price
        bid_bid['paid'] = b.paid
        bidding_info.append(bid_bid)


    return jsonify(purchase=purchased_info, bid =bidding_info)
コード例 #2
0
ファイル: views.py プロジェクト: ChungHanWong/indiv
def otherprofiles(id):
    user = User.get(User.id == id)

    allinfo = {}
    allinfo['username'] = user.username
    allinfo['bio'] = user.bio
    allinfo['profilepic'] = user.profilepic_url

    allpic = Picture.select().where(Picture.artist_id == id)
    pics_info = []
    for a in allpic:
        picpic = {}
        picpic['name'] = a.name
        picpic['category'] = a.category
        picpic['description'] = a.description
        paint = Picture.get(Picture.name == a.name).profilepic_url
        picpic['image'] = paint
        picpic['id'] = a.id
        picpic['price'] = a.price
        picpic['sold'] = a.sold
        if a.bidder_id:
            user = User.get(User.id == a.bidder_id)
            picpic['bidder_name'] = user.username
            pics_info.append(picpic)
        else:
            picpic['bidder_name'] = "None"
            pics_info.append(picpic)

    allinfo['artwork'] = pics_info

    return jsonify(allinfo)
コード例 #3
0
ファイル: views.py プロジェクト: ChungHanWong/indiv
def sold () :
    pic_id = request.form.get('id')
    picture = Picture.get(Picture.id == pic_id)
    picture.buyer_id = picture.bidder_id
    picture.sold = True
    picture.save()
    return jsonify(message="You Have Accepted the Bidder's Offer")
コード例 #4
0
def detail(id):
    a = Picture.get(Picture.id == id)
    artist = a.artist_id
    user = User.get(User.id == artist)
    artist_name = user.username
    picpic = {}
    picpic['name'] = a.name
    picpic['category'] = a.category
    picpic['description'] = a.description
    paint = Picture.get(Picture.name == a.name).profilepic_url
    picpic['image'] = paint
    picpic['price'] = a.price
    picpic['artist'] = artist_name
    picpic['artist_id'] = str(artist)
    picpic['sold'] = a.sold
    return jsonify(picpic)
コード例 #5
0
	def get(self):
		key = self.request.path.split('/')[-1]
		picture = Picture.get(key)
		if not picture:
			self.error(404)
			return
		self.response.headers['Content-Type'] = picture.content_type.__str__()
		self.response.out.write(picture.picture)
コード例 #6
0
ファイル: views.py プロジェクト: ChungHanWong/indiv
def paid () :
    pic_id = request.form.get('id')
    picture = Picture.get(Picture.id == pic_id)
    picture.paid = True
    
    picture.save()
    return jsonify(message="You Purchased the Artwork!")
    
コード例 #7
0
def bid():
    description = request.form.get('description')
    price = request.form.get('price')
    bidprice = int(price)
    user_id = request.form.get('id')
    pic = Picture.get(Picture.description == description)
    currentprice = int(pic.price)
    if currentprice < bidprice:
        pic.price = price
        pic.bidder_id = user_id
        pic.save()
        return jsonify(message="You are currently the highest bidder")
    else:
        return jsonify(message="You are not the highest bidder")
コード例 #8
0
def offer():
    allpic = Picture.select()
    pics_info = []
    for a in allpic:
        picpic = {}
        picpic['name'] = a.name
        picpic['category'] = a.category
        picpic['description'] = a.description
        paint = Picture.get(Picture.name == a.name).profilepic_url
        picpic['image'] = paint
        picpic['id'] = a.id
        pics_info.append(picpic)

    return jsonify(pics_info)
コード例 #9
0
ファイル: views.py プロジェクト: ChungHanWong/indiv
def profile():
    current_user = get_jwt_identity()

    allpic = Picture.select().where(Picture.artist_id == current_user)
    pics_info = []
    for a in allpic:
        picpic = {}
        picpic['name'] = a.name
        picpic['category'] = a.category
        picpic['description'] = a.description
        paint = Picture.get(Picture.name == a.name).profilepic_url
        picpic['image'] = paint
        picpic['id'] = a.id
        picpic['price'] = a.price
        picpic['sold'] = a.sold
        if a.bidder_id:
            user = User.get(User.id == a.bidder_id)
            picpic['bidder_name'] = user.username
            pics_info.append(picpic)
        else:
            picpic['bidder_name'] = "None"
            pics_info.append(picpic)

    # purchased_artwork = Picture.select().where(Picture.buyer_id==current_user)
    # purchased_info = []
    # for p in purchased_artwork :
    #     art_art = {}
    #     art_art['name'] = p.name
    #     art_art['category'] = p.category
    #     art_art['description'] = p.description
    #     art = Picture.get(Picture.name == p.name).profilepic_url
    #     art_art['image'] = art
    #     art_art['id'] = p.id
    #     art_art['price'] = p.price
    #     purchased_info.append(art_art)

    return jsonify(artwork=pics_info)
コード例 #10
0
def delete():
    pic_id = request.form.get('id')
    picture = Picture.get(Picture.id == pic_id)
    picture.delete_instance()
    return jsonify(message="Artwork Deleted")