~richies/+junk/unishop

« back to all changes in this revision

Viewing changes to unishop/models.py

  • Committer: RichieS at GMail
  • Date: 2011-12-11 21:23:44 UTC
  • Revision ID: richies@gmail.com-20111211212344-3k5nk1109g7f0lo6
Add a product listing
Make basket work correctly
Add ability to remove items from basket

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
    #}
83
83
 
84
 
 
85
84
# The 'info' argument we're passing to the email_address and password columns
86
85
# contain metadata that Rum (http://python-rum.org/) can use generate an
87
86
# admin interface for your models.
106
105
                        info={'rum': {'field':'Password'}}, nullable=False)
107
106
    groups = relationship('Group', secondary=UserGroup.__table__,
108
107
                          backref='user')
109
 
    basket = relationship('ShopBasket')
110
108
    
111
109
    #{ Special methods
112
110
    def __init__(self, name):
217
215
    def __init__(self, name, category):
218
216
        self.name = name
219
217
        self.category = category
220
 
 
 
218
        
221
219
class ShopBasket(Base):
222
220
    __tablename__ = 'shop_basket'
223
221
    __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
226
224
    item_id = Column(Integer, ForeignKey('shop_item.id'), nullable=False)
227
225
    item = relationship(ShopItem)
228
226
    user_id = Column(Integer, ForeignKey('user.id'), nullable=False)
 
227
    user = relationship(User)
229
228
    
230
 
    def __init__(self, item):
 
229
    def __init__(self, item, user):
231
230
        self.item = item
 
231
        self.user = user
 
 
b'\\ No newline at end of file'