Example #1
0
    def get_context_data(self, **kwargs):
        context = super(OrderCreateRefundView, self).get_context_data(**kwargs)
        context["title"] = _("Create Refund -- %s") % context["order"]
        context["toolbar"] = Toolbar([
            PostActionButton(
                icon="fa fa-check-circle",
                form_id="create_refund",
                text=_("Create Refund"),
                extra_css_class="btn-success",
            )
        ],
                                     view=self)

        # Allowing full refunds for suppliers would block the refunds for
        # rest of the suppliers since full refund can only be created once
        supplier = context["supplier"] = get_supplier(self.request)
        if not supplier:
            context["toolbar"].append(
                URLActionButton(
                    url=reverse("shuup_admin:order.create-full-refund",
                                kwargs={"pk": self.object.pk}),
                    icon="fa fa-dollar",
                    text=_("Refund Entire Order"),
                    extra_css_class="btn-info",
                    disable_reason=_("This order already has existing refunds")
                    if self.object.has_refunds() else None))

        # Setting the line_numbers choices dynamically creates issues with the blank formset,
        # So adding that to the context to be rendered manually
        context["line_number_choices"] = self._get_line_number_choices(
            supplier)

        lines = lines = self.object.lines.all()
        if supplier:
            lines = lines.filter(supplier=supplier)
        context["json_line_data"] = [
            self._get_line_data(self.object, line) for line in lines
        ]
        return context
Example #2
0
    def get_context_data(self, **kwargs):
        context = super(ScriptEditView, self).get_context_data(**kwargs)
        if self.object.pk:
            buttons = []

            edit_button_title = _("Edit Script Contents...")

            # this script was created through a template
            # so show an option to easily edit the template
            if self.object.template:
                template_cls = get_identifier_to_object_map(
                    SCRIPT_TEMPLATES_PROVIDE_CATEGORY).get(
                        self.object.template)

                # check whether is possible to edit the script through the template editor
                if template_cls and template_cls(
                        self.object).can_edit_script():
                    # change the editor button title to advanced mode
                    edit_button_title = _("Edit Script (advanced)")

                    buttons.append(
                        URLActionButton(
                            text=_("Edit Template"),
                            icon="fa fa-pencil-square-o",
                            extra_css_class="btn-info",
                            url=reverse(
                                "shuup_admin:notify.script-template-edit",
                                kwargs={"pk": self.object.pk})))

            buttons.insert(
                0,
                URLActionButton(text=edit_button_title,
                                icon="fa fa-pencil",
                                extra_css_class="btn-info",
                                url=reverse(
                                    "shuup_admin:notify.script.edit-content",
                                    kwargs={"pk": self.object.pk})))
            context["toolbar"] = Toolbar(buttons)
        return context
Example #3
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",
            )
        ],
                                     view=self)
        return context
Example #4
0
 def get_context_data(self, **kwargs):
     context = super(ListSettingsView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar(
         [
             PostActionButton(
                 icon="fa fa-save",
                 form_id="settings_form",
                 text=_("Save"),
                 extra_css_class="btn-success",
             ),
             JavaScriptActionButton(
                 icon="fa fa-cog",
                 text=_("Reset Defaults"),
                 onclick="resetDefaultValues()",
             ),
         ],
         view=self,
     )
     context["defaults"] = "|".join([
         self.settings.get_settings_key(c.id)
         for c in self.settings.default_columns
     ])
     return context
Example #5
0
    def get_context_data(self, **kwargs):
        context = super(OrderCreateRefundView, self).get_context_data(**kwargs)
        context["title"] = _("Create Refund -- %s") % context["order"]
        context["toolbar"] = Toolbar([
            PostActionButton(
                icon="fa fa-check-circle",
                form_id="create_refund",
                text=_("Create Refund"),
                extra_css_class="btn-success",
            ),
            URLActionButton(
                url=reverse("shuup_admin:order.create-full-refund", kwargs={"pk": self.object.pk}),
                icon="fa fa-dollar",
                text=_("Refund Entire Order"),
                extra_css_class="btn-info",
                disable_reason=_("This order already has existing refunds") if self.object.has_refunds() else None
            ),
        ])

        # Setting the line_numbers choices dynamically creates issues with the blank formset,
        # So adding that to the context to be rendered manually
        context["line_number_choices"] = self._get_line_number_choices()
        context["json_line_data"] = [self._get_line_data(self.object, line) for line in self.object.lines.all()]
        return context
Example #6
0
 def get_toolbar(self):
     return Toolbar([])
Example #7
0
 def get_toolbar(self):
     if ShuupSettings.get_setting("SHUUP_ENABLE_MULTIPLE_SHOPS"):
         return super(ShopListView, self).get_toolbar()
     else:
         return Toolbar([])
Example #8
0
 def get_toolbar(self):
     return Toolbar([
         NewActionButton.for_model(Order,
                                   url=reverse("shuup_admin:order.new")),
         SettingsActionButton.for_model(Order, return_url="order")
     ])
Example #9
0
 def get_toolbar(self):
     if settings.SHUUP_ENABLE_MULTIPLE_SUPPLIERS:
         return super(SupplierListView, self).get_toolbar()
     else:
         return Toolbar([])
Example #10
0
 def get_toolbar(self):
     if settings.SHUUP_ENABLE_MULTIPLE_SHOPS:
         return super(ShopListView, self).get_toolbar()
     else:
         return Toolbar([])
Example #11
0
    def get_toolbar(self):
        order = self.object
        toolbar = Toolbar()
        toolbar.append(
            URLActionButton(text=_("Create Refund"),
                            icon="fa fa-dollar",
                            disable_reason=_("This order cannot be refunded")
                            if not order.can_create_refund() else None,
                            url=reverse("shuup_admin:order.create-refund",
                                        kwargs={"pk": order.pk}),
                            extra_css_class="btn-info"))

        toolbar.append(
            URLActionButton(
                text=_("Create Payment"),
                icon="fa fa-money",
                disable_reason=_("This order cannot be paid at this point")
                if order.is_paid() else None,
                url=reverse("shuup_admin:order.create-payment",
                            kwargs={"pk": order.pk}),
                extra_css_class="btn-info"))

        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("shuup_admin:order.create-shipment",
                                        kwargs={"pk": order.pk}),
                            extra_css_class="btn-info"))

        toolbar.append(
            PostActionButton(
                post_url=reverse("shuup_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("shuup_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"))
        toolbar.append(
            URLActionButton(
                text=_("Edit order"),
                icon="fa fa-money",
                disable_reason=_("This order cannot modified at this point")
                if not order.can_edit() else None,
                url=reverse("shuup_admin:order.edit", kwargs={"pk": order.pk}),
                extra_css_class="btn-info"))

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

        return toolbar
Example #12
0
 def get_context_data(self, **kwargs):
     context = super(ContactGroupListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([NewActionButton("shuup_admin:contact-group.new")])
     return context
Example #13
0
 def get_context_data(self, **kwargs):
     context = super(CampaignListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([
         NewActionButton("shuup_admin:basket_campaigns.new", text=_("Create new Basket Campaign")),
     ])
     return context
Example #14
0
 def get_context_data(self, **kwargs):
     context = super(CouponListView, self).get_context_data(**kwargs)
     context["toolbar"] = Toolbar([
         NewActionButton("shuup_admin:coupons.new", text=_("Create new Coupon")),
     ])
     return context