Subversion Repositories SmartDukaan

Rev

Rev 144 | Rev 173 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 12-May-2010

@author: gaurav
'''
from datastore.DataDefinition import * #Phones, init, PhoneItem

from elixir import *
from datastore.DataDefinition import infibeam_data



class DataHelper:
    
    def __init__(self):
        init()
    
    def add_vendor(self,name,url):
        v = Vendor()
        v.v_name = name
        v.v_url = url
        session.commit() 
        
    def set_all_crawled(self,bval):
        for ph in self.get_all_phones():
            ph.is_crawled = bval
            
    def set_crawled(self,url,bval):
        for ph in self.get_all_phones():
            if ph.url == url:
                ph.is_crawled = bval
        session.commit()     
                
    def get_all_phones(self):
        phones = PhoneItem.query.all()
        return phones
    
    def get_all_vendors(self):
        vi = Vendor.query.all()
        return vi
        
        
    def add_new_phone(self, url, name, source):
        pi = PhoneItem()
        pi.name = name
        pi.url = url
        pi.source = source
        session.commit()
        
    def add_price(self,url,price):
        for ph in self.get_all_phones():
            if ph.url == url:
                ph.price = price
        session.commit()
        
    def add_infiphone(self,name,shown_price,final_price):
        ai = infibeam_data()
        ai.name = name
        ai.shown_price = shown_price
        ai.final_price = final_price
        session.commit()
    
    def add_univervendor(self,name,site):
        ai = univercell_data()
        ai.v_name = name
        ai.v_site = site
        session.commit()
    
    def get_all_univervendors(self):
        vi = univercell_data.query.all()
        return vi
        
    def add_new_univerphone(self,name,shown_price,final_price):
        ai = univercell_items()
        ai.p_title = name
        ai.p_shown_price = shown_price
        ai.p_final_price = final_price
        session.commit()