Esempio n. 1
0
def user_top_right_menu(context):
    request = context['request']
    user = request.user
    menu_list = []

    url_name = request.resolver_match.url_name

    if user.is_authenticated() and not user.is_shop_manager:
        item = MenuItem(title='Зарегистрировать магазин', href=reverse('discount:shop-create'))
        if url_name == 'shop-create':
            item.cls = 'active'
        else:
            item.cls = 'inactive'
        menu_list.append(item)

    return {'menu_list': menu_list}
Esempio n. 2
0
def user_top_right_menu(context):
    request = context["request"]
    user = request.user
    menu_list = []

    url_name = request.resolver_match.url_name

    if user.is_authenticated() and not user.is_shop_manager:
        item = MenuItem(title="Зарегистрировать магазин", href=reverse("discount:shop-create"))
        if url_name == "shop-create":
            item.cls = "active"
        else:
            item.cls = "inactive"
        menu_list.append(item)

    return {"menu_list": menu_list}
Esempio n. 3
0
def get_top_menu(context):
    #active_menu_item = context.get('active_menu_item', None)
    request = context.get('request')
    menu_items = []
    url_name = request.resolver_match.url_name
    user = context['request'].user
    contacts_item = MenuItem(title='Контакты', href=reverse('discount:contacts-page'))

    #if user.is_authenticated() and not user.is_shop_manager:
    #    add_shop_item = MenuItem(title='Зарегистрировать магазин', href=reverse('discount:shop-create'))
    #    if url_name == 'shop-create':
    #        add_shop_item.cls = ' active'
    #    menu_items.append(add_shop_item)

    #conditions_item = MenuItem(title='Условия сотрудничества', href=reverse('discount:conditions-page'))
    help_item = MenuItem(title='Как мы работаем', href=reverse('discount:help-page'))

    #TODO Переделать после старта покупателей
    if context['request'].session.get('shop_offer', None) is not None:
        item = MenuItem(title='Предложение для магазинов', href=reverse('discount:shop-offer'), cls='shop-offer-menu-item')
        menu_items.append(item)

    if url_name == 'contacts-page':
        contacts_item.cls = ' active'
    #if active_menu_item == 'conditions-page':
    #    conditions_item.cls = ' active'
    if url_name == 'help-page':
        help_item.cls = ' active'

    menu_items.append(contacts_item)
    #menu_items.append(conditions_item)
    menu_items.append(help_item)

    return {'menu_items': menu_items}
Esempio n. 4
0
def get_left_menu(context):
    category = context.get("category", None)
    # active_menu_item = context.get('active_menu_item', None)
    user = context["request"].user
    if not category:  # Главная
        return
    else:
        full_menu_list = MenuItem.get_partial_menu_list(category)
    return {"full_menu_list": full_menu_list, "user": user}
Esempio n. 5
0
def get_left_menu(context):
    category = context.get('category', None)
    #active_menu_item = context.get('active_menu_item', None)
    user = context['request'].user
    if not category: #Главная
        return
    else:
        full_menu_list = MenuItem.get_partial_menu_list(category)
    return {'full_menu_list': full_menu_list, 'user': user}
Esempio n. 6
0
def get_user_top_menu_list(context):
    request = context["request"]
    user = request.user
    full_menu_list = []

    url_name = request.resolver_match.url_name

    if user.is_authenticated() and not user.is_shop_manager:

        item = MenuItem(
            title=models.ProductToCart.get_subscribed_count_text(user), href=reverse("discount:product-list-code")
        )
        if url_name == "product-list-code":
            item.cls = "active"
        item.link_class = "code-list-menu"
        full_menu_list.append(item)

        item = MenuItem(
            title=models.ProductToCart.get_finished_count_text(user),
            href=reverse("discount:product-list-finished-code"),
        )
        if url_name == "product-list-finished-code":
            item.cls = "active"
        item.link_class = "finished-list-menu"
        full_menu_list.append(item)

    if user.is_shop_manager:

        shop = user.get_shop
        item = MenuItem(
            title="Страница магазина: {0}".format(shop.title),
            href=reverse("discount:shop-detail", kwargs={"pk": shop.pk}),
        )
        full_menu_list.append(item)

        item = MenuItem(title="Акции магазина", href=reverse("discount:product-list-shop"))
        full_menu_list.append(item)

        item = MenuItem(title="Добавить акцию", href=reverse("discount:product-create"))
        full_menu_list.append(item)

        item = MenuItem(title="Инструкции по работе с сайтом", href=reverse("discount:shop-instructions"))
        full_menu_list.append(item)
    return full_menu_list
Esempio n. 7
0
def get_top_menu(context):
    # active_menu_item = context.get('active_menu_item', None)
    request = context.get("request")
    menu_items = []
    url_name = request.resolver_match.url_name
    user = context["request"].user
    contacts_item = MenuItem(title="Контакты", href=reverse("discount:contacts-page"))

    # if user.is_authenticated() and not user.is_shop_manager:
    #    add_shop_item = MenuItem(title='Зарегистрировать магазин', href=reverse('discount:shop-create'))
    #    if url_name == 'shop-create':
    #        add_shop_item.cls = ' active'
    #    menu_items.append(add_shop_item)

    # conditions_item = MenuItem(title='Условия сотрудничества', href=reverse('discount:conditions-page'))
    help_item = MenuItem(title="Как мы работаем", href=reverse("discount:help-page"))

    # TODO Переделать после старта покупателей
    if context["request"].session.get("shop_offer", None) is not None:
        item = MenuItem(
            title="Предложение для магазинов", href=reverse("discount:shop-offer"), cls="shop-offer-menu-item"
        )
        menu_items.append(item)

    if url_name == "contacts-page":
        contacts_item.cls = " active"
    # if active_menu_item == 'conditions-page':
    #    conditions_item.cls = ' active'
    if url_name == "help-page":
        help_item.cls = " active"

    menu_items.append(contacts_item)
    # menu_items.append(conditions_item)
    menu_items.append(help_item)

    return {"menu_items": menu_items}
Esempio n. 8
0
def get_bottom_menu(context):
    user = context["request"].user
    active_menu_item = context.get("active_menu_item", None)
    menu_items = {}
    contacts_item = MenuItem(title="Контакты", href=reverse("discount:contacts-page"))
    # conditions_item = MenuItem(title='Условия сотрудничества', href=reverse('discount:conditions-page'))
    help_item = MenuItem(title="Как мы работаем", href=reverse("discount:help-page"))
    if context["request"].session.get("shop_offer", None):
        shop_offer_item = MenuItem(title="Предложение для магазинов", href=reverse("discount:shop-offer"))
        menu_items["shop_offer"] = shop_offer_item

    product_types = []
    product_types.append(
        MenuItem(title="Женщинам", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_WOMEN}))
    )
    product_types.append(
        MenuItem(title="Мужчинам", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_MEN}))
    )
    product_types.append(
        MenuItem(title="Детям", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_CHILDREN}))
    )
    product_types.append(
        MenuItem(title="Обувь", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_SHOES}))
    )
    product_types.append(
        MenuItem(
            title="Аксессуары", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_ACCESSORIES})
        )
    )
    product_types.append(
        MenuItem(title="Игрушки", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_TOYS}))
    )
    product_types.append(
        MenuItem(title="Красота", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_BEAUTY}))
    )
    product_types.append(
        MenuItem(title="Спорт", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_SPORT}))
    )
    product_types.append(
        MenuItem(title="Товары для дома", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_HOME}))
    )
    product_types.append(
        MenuItem(
            title="Ювелирные изделия", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_JEWELRY})
        )
    )
    product_types.append(
        MenuItem(
            title="Family Look", href=reverse("discount:product-list", kwargs={"alias": settings.ALIAS_FAMILY_LOOK})
        )
    )

    if not user.is_shop_manager:
        favourite = MenuItem(title="Корзина", href=reverse("discount:cart-view"))
        menu_items["favourite"] = favourite
    if user.is_authenticated():
        personal = MenuItem(title="Личная информация", href=reverse("discount:user-detail"))
        login = MenuItem(title="Выйти", href=reverse("account_logout"))
    else:
        login = MenuItem(title="Войти", href=reverse("discount:full-login"))
        personal = MenuItem(title="Личная информация", href=reverse("discount:full-login"))

    if user.is_shop_manager:
        shop_create = MenuItem(title="Зарегистрировать магазин", href=reverse("discount:shop-create"))
        menu_items["shop_create"] = shop_create

    instructions_item = MenuItem(title="Инструкции по работе с сайтом", href=reverse("discount:shop-instructions"))
    if active_menu_item == "shop-instructions":
        instructions_item.cls = "active"
    else:
        instructions_item.cls = "inactive"

    if active_menu_item == "contacts-page":
        contacts_item.cls = " active"
    # if active_menu_item == 'conditions-page':
    #    conditions_item.cls = ' active'
    if active_menu_item == "help-page":
        help_item.cls = " active"

    menu_items["contacts"] = contacts_item

    menu_items["help"] = help_item
    menu_items["instructions"] = instructions_item

    # menu_items['women'] = women_item
    # menu_items['men'] = men_item
    # menu_items['child'] = child_item

    menu_items["login"] = login
    menu_items["personal"] = personal

    user_menu_items = get_user_top_menu_list(context)

    return {"menu_items": menu_items, "user_menu_items": user_menu_items, "product_types": product_types}
Esempio n. 9
0
def get_main_top_menu(context):
    # user = context['request'].user
    full_menu = MenuItem.get_full_menu()
    # active_menu_item = context.get('active_menu_item', None)

    return {"full_menu": full_menu}
Esempio n. 10
0
def get_bottom_menu(context):
    user = context['request'].user
    active_menu_item = context.get('active_menu_item', None)
    menu_items = {}
    contacts_item = MenuItem(title='Контакты', href=reverse('discount:contacts-page'))
    #conditions_item = MenuItem(title='Условия сотрудничества', href=reverse('discount:conditions-page'))
    help_item = MenuItem(title='Как мы работаем', href=reverse('discount:help-page'))
    if context['request'].session.get('shop_offer', None):
        shop_offer_item = MenuItem(title='Предложение для магазинов', href=reverse('discount:shop-offer'))
        menu_items['shop_offer'] = shop_offer_item

    product_types = []
    product_types.append(MenuItem(title='Женщинам', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_WOMEN})))
    product_types.append(MenuItem(title='Мужчинам', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_MEN})))
    product_types.append(MenuItem(title='Детям', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_CHILDREN})))
    product_types.append(MenuItem(title='Обувь', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_SHOES})))
    product_types.append(MenuItem(title='Аксессуары', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_ACCESSORIES})))
    product_types.append(MenuItem(title='Игрушки', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_TOYS})))
    product_types.append(MenuItem(title='Красота', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_BEAUTY})))
    product_types.append(MenuItem(title='Спорт', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_SPORT})))
    product_types.append(MenuItem(title='Товары для дома', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_HOME})))
    product_types.append(MenuItem(title='Ювелирные изделия', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_JEWELRY})))
    product_types.append(MenuItem(title='Family Look', href=reverse('discount:product-list', kwargs={'alias':  settings.ALIAS_FAMILY_LOOK})))

    if not user.is_shop_manager:
        favourite = MenuItem(title='Корзина', href=reverse('discount:cart-view'))
        menu_items['favourite'] = favourite
    if user.is_authenticated():
        personal = MenuItem(title='Личная информация', href=reverse('discount:user-detail'))
        login = MenuItem(title='Выйти', href=reverse('account_logout'))
    else:
        login = MenuItem(title='Войти', href=reverse('discount:full-login'))
        personal = MenuItem(title='Личная информация', href=reverse('discount:full-login'))

    if user.is_shop_manager:
        shop_create = MenuItem(title='Зарегистрировать магазин', href=reverse('discount:shop-create'))
        menu_items['shop_create'] = shop_create


    instructions_item = MenuItem(title='Инструкции по работе с сайтом', href=reverse('discount:shop-instructions'))
    if active_menu_item == 'shop-instructions':
        instructions_item.cls = 'active'
    else:
        instructions_item.cls = 'inactive'

    if active_menu_item == 'contacts-page':
        contacts_item.cls = ' active'
    #if active_menu_item == 'conditions-page':
    #    conditions_item.cls = ' active'
    if active_menu_item == 'help-page':
        help_item.cls = ' active'

    menu_items['contacts'] = contacts_item

    menu_items['help'] = help_item
    menu_items['instructions'] = instructions_item

    #menu_items['women'] = women_item
    #menu_items['men'] = men_item
    #menu_items['child'] = child_item


    menu_items['login'] = login
    menu_items['personal'] = personal


    user_menu_items = get_user_top_menu_list(context)

    return {'menu_items': menu_items, 'user_menu_items': user_menu_items, 'product_types': product_types}
Esempio n. 11
0
def get_user_top_menu_list(context):
    request = context['request']
    user = request.user
    full_menu_list = []

    url_name = request.resolver_match.url_name

    if user.is_authenticated() and not user.is_shop_manager:

        item = MenuItem(title=models.ProductToCart.get_subscribed_count_text(user), href=reverse('discount:product-list-code'))
        if url_name == 'product-list-code':
            item.cls = 'active'
        item.link_class = 'code-list-menu'
        full_menu_list.append(item)

        item = MenuItem(title=models.ProductToCart.get_finished_count_text(user), href=reverse('discount:product-list-finished-code'))
        if url_name == 'product-list-finished-code':
            item.cls = 'active'
        item.link_class = 'finished-list-menu'
        full_menu_list.append(item)

    if user.is_shop_manager:

        shop = user.get_shop
        item = MenuItem(title='Страница магазина: {0}'.format(shop.title), href=reverse('discount:shop-detail', kwargs={'pk': shop.pk }))
        full_menu_list.append(item)

        item = MenuItem(title='Акции магазина', href=reverse('discount:product-list-shop'))
        full_menu_list.append(item)

        item = MenuItem(title='Добавить акцию', href=reverse('discount:product-create'))
        full_menu_list.append(item)

        item = MenuItem(title='Инструкции по работе с сайтом', href=reverse('discount:shop-instructions'))
        full_menu_list.append(item)
    return full_menu_list
Esempio n. 12
0
def get_main_top_menu(context):
    #user = context['request'].user
    full_menu = MenuItem.get_full_menu()
    #active_menu_item = context.get('active_menu_item', None)

    return {'full_menu': full_menu}