Exemplo n.º 1
0
def start_element_mit(name, attrs):
    from mitdining.models import Category, MenuItem, Store, OptionPrice, StoreCategory
    global current_category, current_store
    print 'Start element:', name, attrs
    if name == 'item':
        # store menu item
        detail = option_prices(attrs['price'])
        if 'market' in attrs['price'].lower(): 
            m = MenuItem(name=attrs['name'], 
                    price=-1,
                    description=attrs['description'], 
                    category=current_category)
            m.save()
        elif len(detail)>1:
            m = MenuItem(name=attrs['name'],
                    price=-2,
                    description=attrs['description'],
                    category=current_category)
            m.save()
            o = OptionPrice(item=m, option_one=detail[0],
                                    price_one=detail[1],
                                    option_two=detail[2],
                                    price_two=detail[3])
            o.save()
        else:
            m = MenuItem(name=attrs['name'], 
                    price=strip_dollar(attrs['price']),
                    description=attrs['description'], 
                    category=current_category)
            m.save()
    elif name == 'category':
        #  category
        # create category
        c = Category(name=attrs['name'])
        if 'description' in attrs:
            c.description=attrs['description']
        c.store = current_store
        c.save() 
        current_category = c
    elif name == 'menu':
        s = Store(name=attrs['store'], store_category=StoreCategory.objects.get(name='House Dining'))
        s.save()
        current_store = s
Exemplo n.º 2
0
import restaurant
from legals.models import Store, Category, MenuItem, OptionPrice

s = restaurant.models.Store.objects.get(id=1)
s_new = Store(name=s.name, address=s.address, city=s.city, state=s.state, phone=s.phone)
s_new.save()

cats = restaurant.models.Category.objects.filter(store=s)
for c in cats:
    newc = Category(name=c.name, description=c.description)
    newc.save()
    # get old items
    items = c.menuitem_set.all()
    for i in items:
        # create new items
        m = MenuItem(name=i.name, price=i.price, description=i.description,
                    category=newc)
        m.save()
        # if it has multiple price
        if i.price == -2:
            p = i.optionprice_set.all()[0]
            o = OptionPrice(item=m, option_one=p.option_one, 
                    price_one=p.price_one, option_two=p.option_two,
                    price_two=p.price_two)
            o.save()
Exemplo n.º 3
0
m.price = 26.95
m.save()

m = MenuItem.objects.get(name="Filet Mignon 8 oz.")
m.price = 28.95
m.save()

m = MenuItem.objects.get(name="Oven Roasted Herbed Chicken")
m.description = "sweet potato mashed, broccoli and lemon butter sauce"
m.price = 18.95
m.save()

try:
    c = Category.objects.get(name="Completely Legal")
except Category.DoesNotExist:
    c = Category(name="Completely Legal", description="Chef Inspired Dinners")
    c.save()
try:
    MenuItem.objects.get(name="Legal's Signature Crab Cakes (Combo)")
except MenuItem.DoesNotExist:
    m = MenuItem(name="Legal's Signature Crab Cakes (Combo)", description="one crab cake, grilled shrimp and scallops; jumbo lump crab, mustard sauce, seasaonal salad (contains nuts)", price=26.95, category=c)
    m.save()

try:
    MenuItem.objects.get(name="Legal's Signature Crab Cakes (Dinner)")
except MenuItem.DoesNotExist:
    m = MenuItem(name="Legal's Signature Crab Cakes (Dinner)", description="two crab cakes; jumbo lump crab, mustard sauce, seasaonal salad (contains nuts)", price=27.95, category=c)
    m.save()

try:
    MenuItem.objects.get(name="Double Stuffed Baked Shrimp")