コード例 #1
0
ファイル: reviews_test.py プロジェクト: giveme168/trip
    def setUp(self):
        user = User()
        user.is_superuser = 1
        user.username = '******'
        user.set_password('password2')
        user.email = '*****@*****.**'
        user.first_name = 'aa'
        user.is_active = 1
        user.save()
        self.user = user

        c = Client()
        self.c = c
        self.c.login( username='******', password='******')

        product = Products()
        product.name = '123123'
        product.price = 123
        product.price_type = 1
        product.total_price = 1*2
        product.order_time = datetime.datetime.strptime('2014-03-20','%Y-%m-%d')
        product.trip_start_time = datetime.datetime.strptime('2014-06-20','%Y-%m-%d')
        product.trip_end_time = datetime.datetime.strptime('2014-09-09','%Y-%m-%d')
        product.key_desc = '123'
        product.start_city = '123'
        product.end_city = '123'
        product.pics = ''
        product.trips = ''
        product.date_count = 4
        product.user = self.user
        product.save()

        self.product = product
コード例 #2
0
ファイル: product.py プロジェクト: giveme168/trip
def create(request):
    if request.method=='POST':
        name = request.REQUEST.get('name','')
        price = float(request.REQUEST.get('price',1))
        price_type = float(request.REQUEST.get('price_type',1))
        order_time = request.REQUEST.get('order_time',datetime.datetime.now().strftime('%Y-%m-%d'))
        trip_start_time = request.REQUEST.get('trip_start_time',datetime.datetime.now().strftime('%Y-%m-%d'))
        trip_end_time = request.REQUEST.get('trip_end_time',datetime.datetime.now().strftime('%Y-%m-%d'))
        key_desc = request.REQUEST.get('key_desc','')
        start_city = request.REQUEST.get('start_city','')
        end_city = request.REQUEST.get('end_city','')
        pics = request.REQUEST.get('pics','')
        trips = request.REQUEST.get('trips',json.dumps([]))
        
        product = Products()
        product.name = name
        product.price = price
        product.price_type = price_type
        product.total_price = price*price_type
        product.order_time = datetime.datetime.strptime(order_time,'%Y-%m-%d')
        product.trip_start_time = datetime.datetime.strptime(trip_start_time,'%Y-%m-%d')
        product.trip_end_time = datetime.datetime.strptime(trip_end_time,'%Y-%m-%d')
        product.key_desc = key_desc
        product.start_city = start_city
        product.end_city = end_city
        product.pics = pics
        product.trips = trips
        product.date_count = len(json.loads(trips))
        product.user = request.user
        try:
            product.save()
            return HttpResponseRedirect('/ink/product/index')
        except:
            return {}
    return {}
コード例 #3
0
ファイル: product.py プロジェクト: giveme168/trip
def rend_data(request):
    product = Products()
    product.name = u'海南七日游' 
    product.price = 1
    product.price_type = 1
    product.total_price = 1
    product.order_time = datetime.datetime.strptime('2014-03-31','%Y-%m-%d')
    product.trip_start_time = datetime.datetime.strptime('2014-06-15','%Y-%m-%d')
    product.trip_end_time = datetime.datetime.strptime('2014-09-15','%Y-%m-%d')
    product.key_desc = u'海南七日游'
    product.start_city = u'北京'
    product.end_city = u'海南'
    product.pics = ''
    product.trips = '游艇'
    product.date_count = len(json.loads(json.dumps([{'name':u'第一天'},{'name':u'第二天'}])))
    product.user = request.user
    try:
        product.save()
        return HttpResponseRedirect('/ink/product/index')
    except:
        return {}
    return {}
コード例 #4
0
ファイル: products.py プロジェクト: treejames/trip
def run():

    for product in PRODUCTS:
        # 导入产品详情
        pro = Products()
        pro.name = product["name"]
        pro.price_type = product["price_type"]
        pro.price_by_one = product["price_by_one"]
        pro.total_price_by_one = product["total_price_by_one"]
        pro.price_by_two = product["price_by_two"]
        pro.total_price_by_two = product["total_price_by_two"]
        pro.price_by_three = product["price_by_three"]
        pro.total_price_by_three = product["total_price_by_three"]
        pro.price_by_four = product["price_by_four"]
        pro.total_price_by_four = product["total_price_by_four"]
        pro.price_by_five = product["price_by_five"]
        pro.total_price_by_five = product["total_price_by_five"]
        pro.price_by_six = product["price_by_six"]
        pro.total_price_by_six = product["total_price_by_six"]
        pro.price_by_serven = product["price_by_serven"]
        pro.total_price_by_serven = product["total_price_by_serven"]
        pro.price_by_eight = product["price_by_eight"]
        pro.total_price_by_eight = product["total_price_by_eight"]
        pro.order_time = datetime.datetime.strptime(product["order_time"], "%Y-%m-%d")
        pro.trip_start_time = datetime.datetime.strptime(product["trip_start_time"], "%Y-%m-%d")
        pro.trip_end_time = datetime.datetime.strptime(product["trip_end_time"], "%Y-%m-%d")
        pro.key_desc = product["key_desc"]
        pro.start_city = product["start_city"]
        pro.end_country = product["end_country"]
        pro.end_city = product["end_city"]
        pro.language = product["language"]
        pro.tags = product["tags"]
        pro.pics = product["pics"]
        pro.trips = json.dumps(product["trips"])
        pro.date_count = product["date_count"]
        pro.user = User.objects.get(id=1)
        pro.body = json.dumps(product["body"])
        pro.status = 2
        pro.save()
        # 导入增值服务
        for service in product["add_service"]:
            pro_add_service = Product_Add_Service()
            pro_add_service.prodect = pro
            pro_add_service.content = service["content"]
            pro_add_service.price_type = service["price_type"]
            pro_add_service.price_by_one = service["price_by_one"]
            pro_add_service.body = json.dumps(service["body"])
            pro_add_service.save()

        tags = product["tags"].split("|")
        for tag in tags:
            stag = Special_Tags()
            stag.name = tag
            stag.name_en = tag
            try:
                stag.save()
            except:
                try:
                    stag = Special_Tags.objects.get(name=tag)
                except:
                    stag = None

            if stag:
                ptag = Product_Tags()
                ptag.prodect = pro
                ptag.tag = stag
                try:
                    ptag.save()
                except:
                    pass

    return