Esempio n. 1
0
    def get_toolbar(self):
        order = self.object
        toolbar = Toolbar()
        toolbar.append(URLActionButton(
            text=_("Create Shipment..."),
            icon="fa fa-truck",
            disable_reason=_("There are no products to ship") if not order.get_unshipped_products() else None,
            url=reverse("shoop_admin:order.create-shipment", kwargs={"pk": order.pk}),
            extra_css_class="btn-info"
        ))

        toolbar.append(PostActionButton(
            post_url=reverse("shoop_admin:order.set-status", kwargs={"pk": order.pk}),
            name="status",
            value=OrderStatus.objects.get_default_complete().pk,
            text=_("Set Complete"),
            icon="fa fa-check-circle",
            disable_reason=(
                _("This order can not be set as complete at this point")
                if not order.can_set_complete()
                else None
            ),
            extra_css_class="btn-success"
        ))

        # TODO: Add extensibility to action_button_groups?
        return toolbar
Esempio n. 2
0
    def get_toolbar(self):
        order = self.object
        toolbar = Toolbar()
        toolbar.append(URLActionButton(
            text=_("Create Shipment"),
            icon="fa fa-truck",
            disable_reason=_("There are no products to ship") if not order.get_unshipped_products() else None,
            url=reverse("shoop_admin:order.create-shipment", kwargs={"pk": order.pk}),
            extra_css_class="btn-info"
        ))

        toolbar.append(PostActionButton(
            post_url=reverse("shoop_admin:order.set-status", kwargs={"pk": order.pk}),
            name="status",
            value=OrderStatus.objects.get_default_complete().pk,
            text=_("Set Complete"),
            icon="fa fa-check-circle",
            disable_reason=(
                _("This order can not be set as complete at this point")
                if not order.can_set_complete()
                else None
            ),
            extra_css_class="btn-success"
        ))

        for button in get_provide_objects("admin_order_toolbar_button"):
            toolbar.append(button(order))

        return toolbar
Esempio n. 3
0
 def get_context_data(self, **kwargs):
     context = super(CouponListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([
         NewActionButton("shoop_admin:coupons.new",
                         text=_("Create new Coupon")),
     ])
     return context
Esempio n. 4
0
 def get_context_data(self, **kwargs):
     context = super(CampaignListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([
         NewActionButton("shoop_admin:basket_campaigns.new",
                         text=_("Create new Basket Campaign")),
     ])
     return context
Esempio n. 5
0
    def get_context_data(self, **kwargs):
        context = super(AddonListView, self).get_context_data(**kwargs)
        context["toolbar"] = Toolbar([
            PostActionButton(
                icon="fa fa-save",
                form_id="addon_list",
                text=_("Save addon changes"),
                extra_css_class="btn-success",
            ),
            NewActionButton(
                reverse("shoop_admin:addon.upload"),
                text=_("Upload new addon"),
                extra_css_class="btn-info",
                icon="fa fa-upload",
            )
        ])
        if self.request.GET.get("reload"):
            context["toolbar"].append(
                URLActionButton(
                    reverse("shoop_admin:addon.reload"),
                    text=_("Reload application"),
                    extra_css_class="btn-warning",
                    icon="fa fa-refresh",
                ))

        return context
Esempio n. 6
0
 def get_toolbar(self):
     return Toolbar([
         URLActionButton(
             text="New Script", icon="fa fa-plus", extra_css_class="btn-success",
             url=reverse("shoop_admin:notify.script.new")
         )
     ])
Esempio n. 7
0
 def get_toolbar(self):
     buttons = []
     model = self.model
     if hasattr(self, "get_model"):
         model = self.get_model()
     new_button = NewActionButton.for_model(model)
     if new_button:
         buttons.append(new_button)
     return Toolbar(buttons)
Esempio n. 8
0
 def get_context_data(self, **kwargs):
     context = super(AddonUploadView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([
         PostActionButton(
             icon="fa fa-upload",
             form_id="upload_form",
             text=_("Upload"),
             extra_css_class="btn-success",
         )
     ])
     return context
Esempio n. 9
0
 def get_context_data(self, **kwargs):
     context = super(ProductMediaEditView, self).get_context_data(**kwargs)
     context["title"] = _("Edit Media: %s") % self.object
     context["toolbar"] = Toolbar([
         PostActionButton(
             icon="fa fa-save",
             form_id="media_form",
             text=_("Save"),
             extra_css_class="btn-success",
         ),
     ])
     return context
Esempio n. 10
0
 def get_context_data(self, **kwargs):
     context = super(ScriptEditView, self).get_context_data(**kwargs)
     if self.object.pk:
         context["toolbar"] = Toolbar([
             URLActionButton(text=_(u"Edit Script Contents..."),
                             icon="fa fa-pencil",
                             extra_css_class="btn-info",
                             url=reverse(
                                 "shoop_admin:notify.script.edit-content",
                                 kwargs={"pk": self.object.pk}))
         ])
     return context
Esempio n. 11
0
 def get_context_data(self, **kwargs):
     context = super(OrderCreatePaymentView, self).get_context_data(**kwargs)
     context["title"] = _("Create Payment -- %s") % context["order"]
     context["toolbar"] = Toolbar([
         PostActionButton(
             icon="fa fa-check-circle",
             form_id="create_payment",
             text=_("Create Payment"),
             extra_css_class="btn-success",
         ),
     ])
     return context
Esempio n. 12
0
    def get_toolbar(self):
        order = self.object
        if order.is_canceled():
            return
        toolbar = Toolbar()
        toolbar.append(URLActionButton(
            text=_("Create Shipment"),
            icon="fa fa-truck",
            disable_reason=_("There are no products to ship") if not order.get_unshipped_products() else None,
            url=reverse("shoop_admin:order.create-shipment", kwargs={"pk": order.pk}),
            extra_css_class="btn-info"
        ))

        toolbar.append(PostActionButton(
            post_url=reverse("shoop_admin:order.set-status", kwargs={"pk": order.pk}),
            name="status",
            value=OrderStatus.objects.get_default_complete().pk,
            text=_("Set Complete"),
            icon="fa fa-check-circle",
            disable_reason=(
                _("This order can not be set as complete at this point")
                if not order.can_set_complete()
                else None
            ),
            extra_css_class="btn-success"
        ))

        toolbar.append(PostActionButton(
            post_url=reverse("shoop_admin:order.set-status", kwargs={"pk": order.pk}),
            name="status",
            value=OrderStatus.objects.get_default_canceled().pk,
            text=_("Cancel Order"),
            icon="fa fa-trash",
            disable_reason=(
                _("Paid, shipped, or canceled orders cannot be canceled")
                if not order.can_set_canceled()
                else None
            ),
            extra_css_class="btn-danger btn-inverse"
        ))

        for button in get_provide_objects("admin_order_toolbar_button"):
            toolbar.append(button(order))

        return toolbar
Esempio n. 13
0
 def get_context_data(self, **kwargs):
     context = super(EditScriptContentView, self).get_context_data(**kwargs)
     context["title"] = get_create_or_change_title(self.request,
                                                   self.object)
     context["action_infos"] = Action.get_ui_info_map()
     context["condition_infos"] = Condition.get_ui_info_map()
     context["cond_op_names"] = get_enum_choices_dict(StepConditionOperator)
     context["step_next_names"] = get_enum_choices_dict(StepNext)
     context["toolbar"] = Toolbar([
         JavaScriptActionButton(text="Save",
                                icon="fa fa-save",
                                extra_css_class="btn-success",
                                onclick="ScriptEditor.save();return false"),
         get_discard_button(get_model_url(self.object, "edit"))
     ])
     return context
Esempio n. 14
0
    def get_context_data(self, **kwargs):
        context = super(AddonUploadConfirmView,
                        self).get_context_data(**kwargs)

        with zipfile.ZipFile(self.get_addon_path()) as zf:
            context["filenames"] = sorted(zf.namelist())
            pkg_info_path = first(filename for filename in context["filenames"]
                                  if filename.endswith("PKG-INFO"))
            if pkg_info_path:
                context["pkg_info"] = zf.read(pkg_info_path).decode(
                    "UTF-8", "replace")

        context["toolbar"] = Toolbar([
            PostActionButton(
                icon="fa fa-download",
                form_id="install_form",
                text=_("Install Addon"),
                extra_css_class="btn-success",
            )
        ])
        return context
Esempio n. 15
0
 def get_context_data(self, **kwargs):
     context = super(ContactGroupListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar(
         [NewActionButton("shoop_admin:contact-group.new")])
     return context
Esempio n. 16
0
 def get_toolbar(self):
     if settings.SHOOP_ENABLE_MULTIPLE_SHOPS:
         return super(ShopListView, self).get_toolbar()
     else:
         return Toolbar([])
Esempio n. 17
0
 def get_toolbar(self):
     if settings.SHOOP_ENABLE_MULTIPLE_SUPPLIERS:
         return super(SupplierListView, self).get_toolbar()
     else:
         return Toolbar([])
Esempio n. 18
0
 def get_toolbar(self):
     return Toolbar([])