当前位置: 首页>>代码示例>>Python>>正文


Python Gift.get_brand_list方法代码示例

本文整理汇总了Python中apps.gift.models.Gift.get_brand_list方法的典型用法代码示例。如果您正苦于以下问题:Python Gift.get_brand_list方法的具体用法?Python Gift.get_brand_list怎么用?Python Gift.get_brand_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apps.gift.models.Gift的用法示例。


在下文中一共展示了Gift.get_brand_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_menu

# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get_brand_list [as 别名]
def get_menu(request):
    filters = request.session.get('filters', [])
    if request.user.is_admin:
        return render_to_response(
        'categories_view.html',
        {
            'subcategories': Gift.get_subcategories_list(filters, is_admin=True),
            'brand_list': Gift.get_brand_list(filters, is_admin=True)
        })
    return render_to_response(
        'categories_view.html',
        {
            'subcategories': Gift.get_subcategories_list(filters),
            'brand_list': Gift.get_brand_list(filters)
        })
开发者ID:gmist,项目名称:five-studio,代码行数:17,代码来源:views.py

示例2: select_filters

# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get_brand_list [as 别名]
def select_filters(request):
    if request.method == 'POST':
        selected_brands = request.form.getlist('brands')
        brands_gifts = []
        if selected_brands:
            brands_gifts = [gift.key() for gift in Gift.all().filter('brand in', selected_brands)]

        subcategories_gifts = []
        selected_subcategories = request.form.getlist('subcategories')
        if selected_subcategories:
            subcategories_gifts = [gift.key() for gift in Gift.all().filter('subcategory in', selected_subcategories)]

        selected_groups = request.form.getlist('groups')
        groups_gifts = []
        if selected_groups:
            groups_gifts = [gift.key() for gift in Gift.all().filter('group in', selected_groups)]

        selected_dates = request.form.getlist('receipt_dates')
        dates_gift = []
        if selected_dates and len(selected_dates) == 2:
            date_from = string.strip(min(selected_dates))
            date_to = string.strip(max(selected_dates))

            if date_from:
                try:
                    date_from = datetime.date(datetime.strptime(date_from, '%Y-%m-%d'))
                except ValueError:
                    date_from = ''

            if date_to:
                try:
                    date_to = datetime.date(datetime.strptime(date_to, '%Y-%m-%d'))
                except ValueError:
                    date_to = ''

            if date_from and date_to:
                dates_gift = [gift.key() for gift in Gift.all().filter('receipt_date >=', date_from).filter('receipt_date <=', date_to)]
            else:
                if date_from:
                    dates_gift = [gift.key() for gift in Gift.all().filter('receipt_date =', date_from)]
                else:
                    if date_to:
                        dates_gift = [gift.key() for gift in Gift.all().filter('receipt_date =', date_to)]


        gifts = set(brands_gifts + subcategories_gifts + groups_gifts + dates_gift)
        request.session['mass_edit_items'] = gifts
        return redirect('/admin/mass_edit/edit/')

    request.session['mass_edit_items'] = 0
    brands = Gift.get_brand_list(is_admin=True)
    subcategories = Gift.get_subcategories_list()
    return render_to_response('admin/mass_edit/select_filters.html', {'brands':brands, 'subcategories':subcategories})
开发者ID:gmist,项目名称:five-studio,代码行数:55,代码来源:views.py

示例3: index

# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get_brand_list [as 别名]
def index(request):
    brands = Gift.get_brand_list()
    brands_gifts = {}
    for brand in brands:
        if brands_gifts.get(brand):
            continue
        gifts = Gift.get_brand(brand)
        if not gifts:
            continue
        gift = gifts.get()
        if gift:
            brands_gifts[brand] = gift
        else:
            brands_gifts[brand] = None
    return render_to_response('brands/index.html', {
        'brands': brands,
        'brands_gifts': brands_gifts
    })
开发者ID:gmist,项目名称:five-studio,代码行数:20,代码来源:views.py

示例4: mass_selection_edit

# 需要导入模块: from apps.gift.models import Gift [as 别名]
# 或者: from apps.gift.models.Gift import get_brand_list [as 别名]
def mass_selection_edit(request):
    if request.method == 'POST':
        new_brand_name = string.strip(request.values.get('new_brand_name'))
        new_presentation_id = string.strip(request.values.get('new_presentation_id'))
        new_youtube_id = string.strip(request.values.get('new_youtube_id'))
        new_subcategory = string.strip(request.values.get('new_subcategory'))
        new_group = string.strip(request.values.get('new_group'))
        new_receipt_date = string.strip(request.values.get('new_receipt_date', ''))
        if new_receipt_date:
            try:
                new_receipt_date = datetime.date(datetime.strptime(new_receipt_date, '%Y-%m-%d'))
            except ValueError:
                new_receipt_date = ''

        gifts_ids = request.session['mass_edit_items']
        gifts_array = []
        for gift_id in gifts_ids:
            gift = Gift.get(gift_id)
            if gift:
                gifts_array.append(gift)

        if not gifts_array:
            return redirect('/admin/mass_edit/select_filters/')

        flag_brand_change = False
        flag_groups_change = False

        for gift in gifts_array:
            flag = False
            if new_brand_name and new_brand_name != gift.name:
                gift.brand = new_brand_name
                flag = flag_brand_change = True

            if new_presentation_id and new_presentation_id != gift.presentation_id:
                gift.presentation_id = new_presentation_id
                flag = True

            if new_youtube_id and new_youtube_id != gift.youtube_id:
                gift.youtube_id = new_youtube_id
                flag = True

            if new_subcategory and new_subcategory != gift.subcategory:
                gift.subcategory = new_subcategory
                flag = True
                flag_groups_change = True

            if new_group and new_group != gift.group:
                gift.group = new_group
                flag = True
                flag_groups_change = True

            if new_receipt_date and new_receipt_date != gift.receipt_date:
                gift.receipt_date = new_receipt_date
                flag = True

            if flag:
                gift.put()
        if flag_brand_change:
            Gift.get_brand_list(force=True, is_admin=True)
        if flag_groups_change:
            Gift.get_subcategories_list(force=True)
        request.session['mass_edit_items'] = 0
        return redirect('/admin/mass_edit/select_filters/')
    count = len(request.session['mass_edit_items'])
    return render_to_response('admin/mass_edit/edit.html', {'count':count})
开发者ID:gmist,项目名称:five-studio,代码行数:67,代码来源:views.py


注:本文中的apps.gift.models.Gift.get_brand_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。