def test_category_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/categories/new") wait_until_condition(browser, lambda x: x.is_text_present("Add a new product category")) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "category", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/categories/new") wait_until_condition(browser, lambda x: not x.is_text_present("Add a new product category")) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") assert is_tour_complete(shop2, "category", user) is False
def test_tour_view(rf, admin_user): shop = get_default_shop() assert is_tour_complete(shop, "home", admin_user) is False view = load("shuup.admin.views.tour:TourView").as_view() request = apply_request_middleware(rf.post("/", data={"tourKey": "home"}), user=admin_user) view(request) assert is_tour_complete(shop, "home", admin_user)
def test_category_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/categories/new") wait_until_condition(browser, lambda x: x.is_text_present("Add a new product category"), timeout=30) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "category", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/categories/new") wait_until_condition(browser, lambda x: not x.is_text_present("Add a new product category")) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") assert is_tour_complete(shop2, "category", user) is False
def test_product_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() product = factories.get_default_product() shop_product = product.get_shop_instance(shop) shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/products/%d/" % shop_product.pk) wait_until_condition(browser, lambda x: x.is_text_present(shop_product.product.name)) # as this is added through javascript, add an extra timeout wait_until_condition(browser, lambda x: x.is_text_present("You are adding a product."), timeout=30) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") category_targets = [ "a.shepherd-enabled[href='#basic-information-section']", "a.shepherd-enabled[href='#additional-details-section']", "a.shepherd-enabled[href='#manufacturer-section']", "a.shepherd-enabled[href*='-additional-section']", "a.shepherd-enabled[href='#product-media-section']", "a.shepherd-enabled[href='#product-images-section']", "a.shepherd-enabled[href='#contact-group-pricing-section']", "a.shepherd-enabled[href='#contact-group-discount-section']" ] # Scroll top before starting to click. For some reason the first # item is not found without this. For Firefox or Chrome the browser # does not do any extra scroll which could hide the first item. # Steps are scrollTo false on purpose since the scrollTo true is the # config which does not work in real world. browser.execute_script("window.scrollTo(0,0)") for target in category_targets: try: wait_until_condition(browser, lambda x: x.is_element_present_by_css(target)) browser.find_by_css(".shepherd-button.btn-primary").last.click() except ElementNotInteractableException: move_to_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: x.is_element_present_by_css(target)) browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: is_tour_complete(shop, "product", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/products/%d/" % shop_product.pk) wait_until_condition(browser, lambda x: not x.is_text_present("You are adding a product."), timeout=20) assert is_tour_complete(shop2, "product", user) is False browser.visit(live_server + "/logout") browser.visit(live_server + "/sa")
def test_product_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() product = factories.get_default_product() shop_product = product.get_shop_instance(shop) shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/products/%d/" % shop_product.pk) wait_until_condition( browser, lambda x: x.is_text_present("You are adding a product.")) wait_until_condition( browser, lambda x: x.is_element_present_by_css( ".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") category_targets = [ "a.shepherd-enabled[href='#basic-information-section']", "a.shepherd-enabled[href='#additional-details-section']", "a.shepherd-enabled[href='#manufacturer-section']", "a.shepherd-enabled[href*='-additional-section']", "a.shepherd-enabled[href='#product-media-section']", "a.shepherd-enabled[href='#product-images-section']", "a.shepherd-enabled[href='#contact-group-pricing-section']", "a.shepherd-enabled[href='#contact-group-discount-section']" ] for target in category_targets: wait_until_condition(browser, lambda x: x.is_element_present_by_css(target)) move_to_element(browser, ".shepherd-button.btn-primary") browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: is_tour_complete(shop, "product", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/products/%d/" % shop_product.pk) wait_until_condition( browser, lambda x: not x.is_text_present("You are adding a product.")) assert is_tour_complete(shop2, "product", user) is False browser.visit(live_server + "/logout") browser.visit(live_server + "/sa")
def test_home_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/home") wait_until_condition(browser, lambda x: x.is_text_present("Hi, new shop owner!")) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") category_targets = [ ".shepherd-enabled[data-target-id='category-1'", ".shepherd-enabled[data-target-id='category-2'", ".shepherd-enabled[data-target-id='category-3'", ".shepherd-enabled[data-target-id='category-5'", ".shepherd-enabled[data-target-id='category-9'", ".shepherd-enabled[data-target-id='category-4'", ".shepherd-enabled[data-target-id='category-6'", ".shepherd-enabled[data-target-id='category-7'", ".shepherd-enabled[data-target-id='category-8'", ".shepherd-enabled#site-search", ".shepherd-enabled.shop-btn.visit-store", ] for target in category_targets: wait_until_condition(browser, lambda x: x.is_element_present_by_css(target)) move_to_element(browser, ".shepherd-button.btn-primary") browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: x.is_text_present("We're done!")) move_to_element(browser, ".shepherd-button.btn-primary") browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: is_tour_complete(shop, "home", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/home") wait_until_condition(browser, lambda x: not x.is_text_present("Hi, new shop owner!")) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") wait_until_condition(browser, lambda x: not x.is_text_present("Hi, new shop owner!")) assert is_tour_complete(shop2, "home", user) is False
def test_home_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) for user in [admin_user, admin_user_2]: initialize_admin_browser_test(browser, live_server, settings, username=user.username, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) browser.visit(live_server + "/sa/home") wait_until_condition(browser, lambda x: x.is_text_present("Hi, new shop owner!"), timeout=30) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") category_targets = [ ".shepherd-enabled[data-target-id='category-1'", ".shepherd-enabled[data-target-id='category-2'", ".shepherd-enabled[data-target-id='category-3'", ".shepherd-enabled[data-target-id='category-5'", ".shepherd-enabled[data-target-id='category-9'", ".shepherd-enabled[data-target-id='category-4'", ".shepherd-enabled[data-target-id='category-6'", ".shepherd-enabled[data-target-id='category-7'", ".shepherd-enabled[data-target-id='category-8'", ".shepherd-enabled#site-search", ".shepherd-enabled.shop-btn.visit-store", ] for target in category_targets: wait_until_condition(browser, lambda x: x.is_element_present_by_css(target)) move_to_element(browser, ".shepherd-button.btn-primary") browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: x.is_text_present("We're done!"), timeout=30) move_to_element(browser, ".shepherd-button.btn-primary") browser.find_by_css(".shepherd-button.btn-primary").last.click() wait_until_condition(browser, lambda x: is_tour_complete(shop, "home", user)) # check whether the tour is shown again browser.visit(live_server + "/sa/home") wait_until_condition(browser, lambda x: not x.is_text_present("Hi, new shop owner!")) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") wait_until_condition(browser, lambda x: not x.is_text_present("Hi, new shop owner!")) assert is_tour_complete(shop2, "home", user) is False
def get_context_data(self, **kwargs): context = super(ProductEditView, self).get_context_data(**kwargs) orderability_errors = [] if self.object.pk: for shop in Shop.objects.all(): try: shop_product = self.object.get_shop_instance(shop) orderability_errors.extend([ "%s: %s" % (shop.name, msg.message) for msg in shop_product.get_orderability_errors( supplier=None, quantity=shop_product.minimum_purchase_quantity, customer=None) ]) except ObjectDoesNotExist: orderability_errors.extend([ "%s: %s" % (shop.name, _("Product is not available.")) ]) context["orderability_errors"] = orderability_errors context["product_sections"] = [] context["tour_key"] = "product" context["tour_complete"] = is_tour_complete("product") product_sections_provides = sorted( get_provide_objects("admin_product_section"), key=lambda x: x.order) for admin_product_section in product_sections_provides: if admin_product_section.visible_for_object(self.object): context["product_sections"].append(admin_product_section) context[admin_product_section. identifier] = admin_product_section.get_context_data( self.object) return context
def get_context_data(self, **kwargs): context = super(ProductEditView, self).get_context_data(**kwargs) orderability_errors = [] if self.object.pk: for shop in Shop.objects.all(): try: shop_product = self.object.get_shop_instance(shop) orderability_errors.extend( ["%s: %s" % (shop.name, msg.message) for msg in shop_product.get_orderability_errors( supplier=None, quantity=shop_product.minimum_purchase_quantity, customer=None)]) except ObjectDoesNotExist: orderability_errors.extend(["%s: %s" % (shop.name, _("Product is not available."))]) context["orderability_errors"] = orderability_errors context["product_sections"] = [] context["tour_key"] = "product" context["tour_complete"] = is_tour_complete("product") product_sections_provides = sorted(get_provide_objects("admin_product_section"), key=lambda x: x.order) for admin_product_section in product_sections_provides: if admin_product_section.visible_for_object(self.object): context["product_sections"].append(admin_product_section) context[admin_product_section.identifier] = admin_product_section.get_context_data(self.object) return context
def get_context_data(self, **kwargs): context = super(CategoryEditView, self).get_context_data(**kwargs) context["tour_key"] = "category" context["tour_complete"] = is_tour_complete(get_shop(self.request), "category", user=self.request.user) if self.object.pk: context["title"] = self.object.name return context
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) context["blocks"] = blocks = [] context["tour_key"] = "home" context["tour_complete"] = is_tour_complete(get_shop(self.request), "home") wizard_complete = setup_wizard_complete(self.request) wizard_url = reverse("shuup_admin:wizard") wizard_actions = [] if not wizard_complete: wizard_actions.append({ "text": _("Complete wizard"), "url": wizard_url }) else: wizard_steps = load_setup_wizard_panes( shop=self.request.shop, request=self.request, visible_only=False) for step in wizard_steps: wizard_actions.append({ "text": step.title, "url": "%s?pane_id=%s" % (wizard_url, step.identifier), "no_redirect": True }) blocks.append( SimpleHelpBlock( _("Complete the setup wizard"), actions=wizard_actions, icon_url="shuup_admin/img/configure.png", priority=-1, done=wizard_complete ) ) for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): blocks.extend(module.get_help_blocks(request=self.request, kind="setup")) blocks.sort(key=lambda b: b.priority) blocks.append( SimpleHelpBlock( priority=1000, text=_("Publish your store"), description=_("Let customers browse your store and make purchases"), css_class="green ", actions=[{ "method": "POST", "text": _("Publish shop"), "url": reverse("shuup_admin:shop.enable", kwargs={"pk": self.request.shop.pk}), "data": { "enable": True, "redirect": reverse("shuup_admin:dashboard") } }], icon_url="shuup_admin/img/publish.png", done=not self.request.shop.maintenance_mode ) ) return context
def get_context_data(self, **kwargs): context = super(ProductEditView, self).get_context_data(**kwargs) orderability_errors = [] shop = get_shop(self.request) if self.object.pk: context["title"] = self.object.product.name try: shop_product = self.object orderability_errors.extend([ "%s: %s" % (shop.name, msg.message) for msg in shop_product.get_orderability_errors( supplier=None, quantity=shop_product.minimum_purchase_quantity, customer=None) ]) except ObjectDoesNotExist: orderability_errors.extend([ "Error! %s: %s" % (shop.name, _("Product is not available.")) ]) product_validator_provides = sorted( get_provide_objects("admin_product_validator"), key=lambda provides: provides.ordering) context["bleach"] = bleach validation_issues = [] for admin_product_validator in product_validator_provides: for validation_issue in admin_product_validator.get_validation_issues( shop_product=self.object, shop=shop, user=self.request.user, supplier=get_supplier(self.request)): if validation_issue: validation_issues.append(validation_issue) context["validation_issues"] = sorted( validation_issues, key=lambda x: x.get_issue_type_priority()) context["orderability_errors"] = orderability_errors context["product_sections"] = [] context["tour_key"] = "product" context["tour_complete"] = is_tour_complete(get_shop(self.request), "product", user=self.request.user) product_sections_provides = sorted( get_provide_objects("admin_product_section"), key=lambda x: x.order) for admin_product_section in product_sections_provides: if admin_product_section.visible_for_object( self.object.product, self.request): context["product_sections"].append(admin_product_section) context[admin_product_section. identifier] = admin_product_section.get_context_data( self.object.product, self.request) return context
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) context["blocks"] = blocks = [] context["tour_key"] = "home" context["tour_complete"] = is_tour_complete("home") wizard_complete = setup_wizard_complete() wizard_url = reverse("shuup_admin:wizard") wizard_actions = [] if not wizard_complete: wizard_actions.append({ "text": _("Complete wizard"), "url": wizard_url }) else: wizard_steps = load_setup_wizard_panes( shop=Shop.objects.first(), request=self.request, visible_only=False) for step in wizard_steps: wizard_actions.append({ "text": step.title, "url": "%s?pane_id=%s" % (wizard_url, step.identifier), "no_redirect": True }) blocks.append( SimpleHelpBlock( _("Complete the setup wizard"), actions=wizard_actions, icon_url="shuup_admin/img/configure.png", priority=-1, done=wizard_complete ) ) for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): blocks.extend(module.get_help_blocks(request=self.request, kind="setup")) blocks.sort(key=lambda b: b.priority) blocks.append( SimpleHelpBlock( priority=1000, text=_("Publish your store"), description=_("Let customers browse your store and make purchases"), css_class="green", actions=[{ "method": "POST", "text": _("Publish shop"), "url": reverse("shuup_admin:shop.enable", kwargs={"pk": self.request.shop.pk}), "data": { "enable": True, "redirect": reverse("shuup_admin:dashboard") } }], icon_url="shuup_admin/img/publish.png" ) ) return context
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) shop = get_shop(self.request) context["blocks"] = blocks = [] context["tour_key"] = "home" context["tour_complete"] = is_tour_complete(shop, "home", user=self.request.user) wizard_complete = setup_wizard_complete(self.request) wizard_url = reverse("shuup_admin:wizard") wizard_actions = [] if not wizard_complete: wizard_actions.append({ "text": _("Complete wizard"), "url": wizard_url }) else: wizard_steps = load_setup_wizard_panes(shop=shop, request=self.request, visible_only=False) for step in wizard_steps: wizard_actions.append({ "text": step.title, "url": "%s?pane_id=%s" % (wizard_url, step.identifier), "no_redirect": True }) if wizard_actions: blocks.append( SimpleHelpBlock(_("Complete the setup wizard"), actions=wizard_actions, icon_url="shuup_admin/img/configure.png", priority=-1, done=wizard_complete)) for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): blocks.extend( module.get_help_blocks(request=self.request, kind="setup")) blocks.sort(key=lambda b: b.priority) if not blocks: blocks.append( SimpleHelpBlock(_("All set. Nothing to be configured"), actions=[], icon_url="shuup_admin/img/configure.png", priority=-1, done=True)) return context
def test_dashbord_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) # test with admin_user 1 initialize_admin_browser_test(browser, live_server, settings, shop=shop, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) wait_until_condition(browser, lambda x: x.is_text_present("Quicklinks")) wait_until_condition(browser, lambda x: x.is_element_present_by_css("#menu-button")) wait_until_condition(browser, lambda x: x.is_text_present("This is the dashboard for your store.")) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "dashboard", admin_user)) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") # test with admin_user 2 initialize_admin_browser_test(browser, live_server, settings, shop=shop, tour_complete=False, username=admin_user_2.username) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) wait_until_condition(browser, lambda x: x.is_element_present_by_css("#menu-button")) wait_until_condition(browser, lambda x: x.is_text_present("This is the dashboard for your store.")) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "dashboard", admin_user_2)) # check whether the tour is shown again browser.visit(live_server + "/sa") wait_until_condition(browser, lambda x: not x.is_text_present("This is the dashboard for your store.")) assert is_tour_complete(shop2, "dashboard", admin_user) is False assert is_tour_complete(shop2, "dashboard", admin_user_2) is False
def test_dashbord_tour(browser, admin_user, live_server, settings): shop = factories.get_default_shop() shop2 = factories.get_shop(identifier="shop2") admin_user_2 = factories.create_random_user(is_staff=True, is_superuser=True) admin_user_2.set_password("password") admin_user_2.save() shop.staff_members.add(admin_user) shop.staff_members.add(admin_user_2) # test with admin_user 1 initialize_admin_browser_test(browser, live_server, settings, shop=shop, tour_complete=False) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) wait_until_condition(browser, lambda x: x.is_text_present("Quicklinks")) wait_until_condition(browser, lambda x: x.is_element_present_by_css("#menu-button")) wait_until_condition(browser, lambda x: x.is_text_present("This is the dashboard for your store."), timeout=30) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "dashboard", admin_user)) browser.visit(live_server + "/logout") browser.visit(live_server + "/sa") # test with admin_user 2 initialize_admin_browser_test(browser, live_server, settings, shop=shop, tour_complete=False, username=admin_user_2.username) wait_until_condition(browser, lambda x: x.is_text_present("Welcome!")) wait_until_condition(browser, lambda x: x.is_element_present_by_css("#menu-button")) wait_until_condition(browser, lambda x: x.is_text_present("This is the dashboard for your store."), timeout=30) wait_until_condition(browser, lambda x: x.is_element_present_by_css(".shepherd-button.btn-primary")) click_element(browser, ".shepherd-button.btn-primary") wait_until_condition(browser, lambda x: not x.is_element_present_by_css(".shepherd-button")) wait_until_condition(browser, lambda x: is_tour_complete(shop, "dashboard", admin_user_2)) # check whether the tour is shown again browser.visit(live_server + "/sa") wait_until_condition(browser, lambda x: not x.is_text_present("This is the dashboard for your store.")) assert is_tour_complete(shop2, "dashboard", admin_user) is False assert is_tour_complete(shop2, "dashboard", admin_user_2) is False
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) shop = get_shop(self.request) context["blocks"] = blocks = [] context["tour_key"] = "home" context["tour_complete"] = is_tour_complete(shop, "home", user=self.request.user) wizard_complete = setup_wizard_complete(self.request) wizard_url = reverse("shuup_admin:wizard") wizard_actions = [] if not wizard_complete: wizard_actions.append({ "text": _("Complete wizard"), "url": wizard_url }) else: wizard_steps = load_setup_wizard_panes(shop=shop, request=self.request, visible_only=False) for step in wizard_steps: wizard_actions.append({ "text": step.title, "url": "%s?pane_id=%s" % (wizard_url, step.identifier), "no_redirect": True }) if wizard_actions: blocks.append( SimpleHelpBlock( _("Complete the setup wizard"), actions=wizard_actions, icon_url="shuup_admin/img/configure.png", priority=-1, done=wizard_complete ) ) for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): blocks.extend(module.get_help_blocks(request=self.request, kind="setup")) blocks.sort(key=lambda b: b.priority) if not blocks: blocks.append( SimpleHelpBlock( _("All set. Nothing to be configured"), actions=[], icon_url="shuup_admin/img/configure.png", priority=-1, done=True ) ) return context
def get_context_data(self, **kwargs): context = super(DashboardView, self).get_context_data(**kwargs) context["version"] = shuup.__version__ context["notifications"] = notifications = [] context["blocks"] = blocks = [] for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): notifications.extend(module.get_notifications(request=self.request)) blocks.extend(module.get_dashboard_blocks(request=self.request)) context["activity"] = get_activity(request=self.request) context["tour_key"] = "dashboard" context["tour_complete"] = is_tour_complete("dashboard") return context
def get_context_data(self, **kwargs): context = super(DashboardView, self).get_context_data(**kwargs) context["version"] = shuup.__version__ context["notifications"] = notifications = [] context["blocks"] = blocks = [] for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): notifications.extend(module.get_notifications(request=self.request)) blocks.extend(module.get_dashboard_blocks(request=self.request)) # sort blocks by sort order and size, trying to make them fit better blocks.sort(key=lambda block: (block.sort_order, DashboardBlock.SIZES.index(block.size))) context["activity"] = get_activity(request=self.request) context["tour_key"] = "dashboard" context["tour_complete"] = is_tour_complete(get_shop(self.request), "dashboard", user=self.request.user) return context
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) context["blocks"] = blocks = [] context["tour_key"] = "home" context["tour_complete"] = is_tour_complete("home") wizard_complete = setup_wizard_complete() blocks.append( SimpleHelpBlock(_("Complete the setup wizard"), actions=[{ "text": _("Complete wizard"), "url": reverse("shuup_admin:wizard") }] if not wizard_complete else [], icon_url="shuup_admin/img/configure.png", priority=-1, done=wizard_complete)) for module in get_modules(): if not get_missing_permissions(self.request.user, module.get_required_permissions()): blocks.extend( module.get_help_blocks(request=self.request, kind="setup")) blocks.sort(key=lambda b: b.priority) blocks.append( SimpleHelpBlock( priority=1000, text=_("Publish your store"), description=_( "Let customers browse your store and make purchases"), css_class="green", actions=[{ "method": "POST", "text": _("Publish shop"), "url": reverse("shuup_admin:shop.enable", kwargs={"pk": self.request.shop.pk}), "data": { "enable": True, "redirect": reverse("shuup_admin:dashboard") } }], icon_url="shuup_admin/img/publish.png")) return context
def get_context_data(self, **kwargs): context = super(CategoryEditView, self).get_context_data(**kwargs) context["tour_key"] = "category" context["tour_complete"] = is_tour_complete("category") return context