Example #1
0
 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")
Example #2
0
    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)
Example #3
0
 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 Shoop.io after 24 hours. Click here for more information."
         ),
                            title=_("Telemetry"),
                            kind="info",
                            url="shoop_admin:telemetry")
Example #4
0
    def get_notifications(self, request):
        old_open_orders = Order.objects.filter(
            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")
Example #5
0
    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):  # ... but there's no theme active?!
                    # Panic!
                    yield Notification(text=_(
                        "No theme is active. Click here to activate one."),
                                       title=_("Theming"),
                                       url="shoop_admin:xtheme.config")
Example #6
0
    def get_notifications(self, request):
        notif_qs = NotificationModel.objects.unread_for_user(
            request.user).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(
                                   "shoop_admin:notify.mark-read",
                                   kwargs={"pk": notif.pk}),
                               datetime=notif.created_on)
Example #7
0
 def get_notifications(self, request):
     return [Notification(text="OK")]