def get_notifications(self, request): if not self.check_demo_optin(request): return yield Notification(text="Your IP is %s" % request.META.get("REMOTE_ADDR")) yield Notification(title="Dice", text="Your lucky number is %d" % random.randint(1, 43), kind="success") yield Notification(title="Stock Alert", text="Items X, Y, Z are running low", kind="warning") yield Notification(title="Outstanding Orders", text="10 orders have not been touched in 7 days", kind="danger")
def get_notifications(self, request): try: engines["jinja2"] except InvalidTemplateEngineError: text = """Simple Order Notifications can't send order notifications because it can't find a Jinja2 template engine. Name your Jinja2 template engine "jinja2" to resolve this.""" yield Notification(text=text)
def get_notifications(self, request): if is_telemetry_enabled() and is_in_grace_period( ) and not is_opt_out(): yield Notification(_( "Statistics will be periodically sent to Wshop.com after 24 hours. Click here for more information." ), title=_("Telemetry"), kind="info", url="wshop_admin:telemetry")
def get_notifications(self, request): shop = request.shop old_open_orders = Order.objects.filter( shop=shop, status__role=OrderStatusRole.INITIAL, order_date__lt=now() - timedelta(days=4)).count() if old_open_orders: yield Notification(title=_("Outstanding Orders"), text=_("%d outstanding orders") % old_open_orders, kind="danger")
def get_notifications(self, request): try: engine = engines["jinja2"] except KeyError: engine = None if engine and isinstance(engine, Jinja2): # The engine is what we expect... if isinstance(engine.env, XthemeEnvironment ): # ... and it's capable of loading themes... if not get_current_theme( request.shop): # ... but there's no theme active?! # Panic! yield Notification(text=_( "No theme is active. Click here to activate one."), title=_("Theming"), url="wshop_admin:xtheme.config")
def get_notifications(self, request): """ Injects a message to the user and also a notification """ # multi-shop not supported if not WshopSettings.get_setting("WSHOP_ENABLE_MULTIPLE_SHOPS"): # there would be only sample data for single-shops envs shop = Shop.objects.first() if sample_manager.has_installed_samples(shop): messages.warning( request, _('There is sample data installed. ' 'Access "Settings > Sample Data" for more information.')) yield Notification(_( "There is sample data installed. Click here to consolidate or delete them." ), title=_("Sample Data"), kind="warning", url="wshop_admin:sample_data")
def get_notifications(self, request): shop = get_shop(request) notif_qs = NotificationModel.objects.unread_for_user( request.user).filter(shop=shop).order_by("-id")[:15] for notif in notif_qs: if notif.priority == Priority.HIGH: kind = "warning" elif notif.priority == Priority.CRITICAL: kind = "danger" else: kind = "info" yield Notification(text=notif.message, url=notif.url, kind=kind, dismissal_url=reverse( "wshop_admin:notify.mark-read", kwargs={"pk": notif.pk}), datetime=notif.created_on)
def get_notifications(self, request): return [Notification(text="OK")]