-
Notifications
You must be signed in to change notification settings - Fork 1
/
Item.py
70 lines (62 loc) · 2.1 KB
/
Item.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Supporting Code for Frank's List,
an open source webapp for buying and
selling items across college campuses.
@author(s):
Jasper Katzban, Olin '23
Jonas Kazlauskas, Olin '23
Kelly Yen, Olin '23
"""
from datetime import datetime
class Item:
"""Class to represent an item to be listed"""
def __init__(self, name, price, description, category, images, quality, userid, sellername, selleremail, school, itemid):
"""Create an Item object with relevant attributes
Attributes:
name: string, name of item
price: int, price of item in us whole dollars
description: string, description of item
category: string, which category item belongs to
images: list of links to image sources
seller: string, the id of the user who's selling this item
itemid: string. the itemid of this item
quality: string, the condition of item (used, new, etc.)
post_date: date, the day that this item was posted
seller_name: string, the first name and last initial of the seller
schoo: the school that the seller goes to
seller_email: string, the seller's email address
buyers: a list of people who are interested in buying the item
available: boolean, represening if item is available for purchase
"""
self.name = name
self.price = price
self.description = description
self.category = category
self.images = images
self.seller = userid
self.itemid = itemid
self.quality = quality
self.post_date = datetime.now()
self.seller_name = sellername
self.school = school
self.seller_email = selleremail
self.buyers = []
self.available = True
def to_dict(self):
items_dict={
'name' : self.name,
'price' : self.price,
'description' : self.description,
'category' : self.category,
'images' : self.images,
'seller' : self.seller,
'seller_email' : self.seller_email,
'seller_name' : self.seller_name,
'school' : self.school,
'id' : self.itemid,
'post_date' : self.post_date,
'available' : self.available,
'quality' : self.quality,
'buyers' : self.buyers,
}
return items_dict