Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
144 ashish 1
'''
2
Created on 12-May-2010
3
 
4
@author: gaurav
5
'''
6
from datastore.DataDefinition import * #Phones, init, PhoneItem
7
 
8
from elixir import *
9
from datastore.DataDefinition import infibeam_data
10
 
11
 
12
 
13
class DataHelper:
14
 
15
    def __init__(self):
16
        init()
17
 
18
    def add_vendor(self,name,url):
19
        v = Vendor()
20
        v.v_name = name
21
        v.v_url = url
22
        session.commit() 
23
 
24
    def set_all_crawled(self,bval):
25
        for ph in self.get_all_phones():
26
            ph.is_crawled = bval
27
 
28
    def set_crawled(self,url,bval):
29
        for ph in self.get_all_phones():
30
            if ph.url == url:
31
                ph.is_crawled = bval
32
        session.commit()     
33
 
34
    def get_all_phones(self):
35
        phones = PhoneItem.query.all()
36
        return phones
37
 
38
    def get_all_vendors(self):
39
        vi = Vendor.query.all()
40
        return vi
41
 
42
 
43
    def add_new_phone(self, url, name, source):
44
        pi = PhoneItem()
45
        pi.name = name
46
        pi.url = url
47
        pi.source = source
48
        session.commit()
49
 
50
    def add_price(self,url,price):
51
        for ph in self.get_all_phones():
52
            if ph.url == url:
53
                ph.price = price
54
        session.commit()
55
 
56
    def add_infiphone(self,name,shown_price,final_price):
57
        ai = infibeam_data()
58
        ai.name = name
59
        ai.shown_price = shown_price
60
        ai.final_price = final_price
61
        session.commit()
150 ashish 62
 
63
    def add_univervendor(self,name,site):
64
        ai = univercell_data()
65
        ai.v_name = name
66
        ai.v_site = site
67
        session.commit()
68
 
69
    def get_all_univervendors(self):
70
        vi = univercell_data.query.all()
71
        return vi
72
 
73
    def add_new_univerphone(self,name,shown_price,final_price):
74
        ai = univercell_items()
75
        ai.p_title = name
76
        ai.p_shown_price = shown_price
77
        ai.p_final_price = final_price
78
        session.commit()
79
 
80
 
144 ashish 81