예제 #1
0
파일: mock.py 프로젝트: nubela/unifide-plop
def gen_org_info():
    org_info = OrgInfo()
    org_info.address = loremipsum.sentence(max_char=20)
    org_info.name = loremipsum.sentence(max_char=20)
    org_info.description = loremipsum.paragraph()
    org_info.email = "*****@*****.**"
    save(org_info)
예제 #2
0
파일: mock.py 프로젝트: nubela/unifide-plop
def gen_discounts(model, existing_path_lis=[]):
    """
    Generate discounts for individual containers from a model
    """
    if existing_path_lis is None: existing_path_lis = []

    for container_name, attr_dic in model.items():
        path_lis = existing_path_lis + [container_name]
        container_obj = items.container_from_path(path_lis)

        discount_obj = Discount()
        discount_obj.coll_name = items.Container.coll_name()
        discount_obj.obj_id = container_obj._id
        discount_obj.discount_lifetime_type = DiscountLifetime.FOREVER
        discount_obj.name = loremipsum.sentence(max_char=30)
        discount_obj.description = loremipsum.paragraph()
        discount_obj.status = DiscountStatus.ENABLED

        if ContainerAttr.DISCOUNT_PERCENTAGE in attr_dic:
            perc = attr_dic[ContainerAttr.DISCOUNT_PERCENTAGE]
            discount_obj.discount_percentage = perc
            discount_obj.save()

        if ContainerAttr.DISCOUNT_ABSOLUTE in attr_dic:
            amount = attr_dic[ContainerAttr.DISCOUNT_ABSOLUTE]
            discount_obj.absolute_discounted_price = amount
            discount_obj.save()

        #gen recursive models
        if "containers" in model: gen_discounts(model["containers"], path_lis)
예제 #3
0
파일: mock.py 프로젝트: nubela/unifide-plop
def gen_articles(total_items=20):
    for _ in range(total_items):
        basic_attr = {
            "name": loremipsum.sentence(max_char=choice(range(10, 20))),
            "image": None,
            "description": loremipsum.paragraph(),
        }
        publish_datetime = __gen_random_datetime(MOCK_DATE_RANGE_DAYS)
        items.save_item(basic_attr, ARTICLE_PATH, publish_datetime)
예제 #4
0
파일: mock.py 프로젝트: nubela/unifide-plop
def _spawn_items(pl):
    items_to_cr8 = [loremipsum.sentence(30) for _ in range(choice(range(10, 20)))]
    all_items = []
    for item_name in items_to_cr8:
        i = Item()
        i.name = item_name
        i.description = loremipsum.paragraph()
        i.price = choice(range(1, 100))
        i.container_id = container_from_path(pl)._id
        i._id = i.save()
        all_items += [i]
    return all_items
예제 #5
0
파일: mock.py 프로젝트: nubela/unifide-plop
def new_item_coupon(coupon_code, value, obj_id):
    c = Coupon()
    c.coupon_scope = CouponScope.ITEM_ONLY
    c.coll_name = items.Item.coll_name()
    c.obj_id = obj_id
    c.coupon_code = coupon_code
    c.coupon_value = value
    c.valid_times = 1
    c.coupon_lifetime_type = CouponLifetime.FOREVER
    c.user_scope = CouponUserScope.ALL
    c.name = loremipsum.sentence()
    c.description = loremipsum.paragraph()
    c.status = CouponStatus.AVAILABLE
    c.save()
예제 #6
0
파일: mock.py 프로젝트: nubela/unifide-plop
def gen_container_coupon(coupon_code, value, container_id):
    c = Coupon()
    c.coupon_scope = CouponScope.CONTAINER_WIDE
    c.coll_name = items.Container.coll_name()
    c.obj_id = container_id
    c.coupon_code = coupon_code
    c.coupon_value = value
    c.valid_times = 1
    c.coupon_lifetime_type = CouponLifetime.FOREVER
    c.user_scope = CouponUserScope.ALL
    c.name = loremipsum.sentence()
    c.description = loremipsum.paragraph()
    c.status = CouponStatus.AVAILABLE
    c.save()
예제 #7
0
파일: mock.py 프로젝트: nubela/unifide-plop
def _spawn_items_containers(pl):
    containers_to_cr8 = [loremipsum.sentence(30) for _ in range(choice(range(1, 3)))]
    all_pl = map(lambda x: pl + [x], containers_to_cr8)
    items_to_cr8 = [loremipsum.sentence(30) for _ in range(choice(range(5, 10)))]

    for item_name in items_to_cr8:
        i = Item()
        i.name = item_name
        i.description = loremipsum.paragraph()
        i.price = choice(range(1, 100))
        i.container_id = container_from_path(pl)._id
        i.save()
    for container_pl_to_cr8 in all_pl:
        save_container_path(container_pl_to_cr8)
    return all_pl
예제 #8
0
파일: mock.py 프로젝트: nubela/unifide-plop
def gen_items(total_items=5):
    container_obj = items.container_from_path(GEN_ITEM_PATH_LIS)
    if container_obj is None:
        container_obj = items.save_container_path(GEN_ITEM_PATH_LIS)

    item_lis = []
    for _ in range(total_items):
        dic = {
            "name": loremipsum.sentence(max_char=choice(range(10, 20))),
            "media": None,
            "description": loremipsum.paragraph(max_char=choice(range(40, 100))),
            "quantity": choice(range(1, 20)),
            "price": choice(range(1, 20)),
            "container_id": container_obj.obj_id(),
        }
        item_obj = items.Item.unserialize(dic)
        item_obj._id = items.save(item_obj)
        item_lis += [item_obj]

    return item_lis
예제 #9
0
파일: utils.py 프로젝트: oxeed/blog
def random_text(paragraphs=1):
    token = random_char_seq(24)
    return token + "".join([loremipsum.paragraph() for i in range(paragraphs)])