Пример #1
0
 def __init__(self, view):
     super(ProductPackageViewToolbar, self).__init__(view)
     if self.parent_product.get_package_child_to_quantity_map():
         self.append(PostActionButton(
             post_url=self.request.path,
             name="command",
             value="clear_package",
             confirm=self.confirm_text,
             text=self.button_text,
             extra_css_class="btn-danger",
             icon="fa fa-times"
         ))
Пример #2
0
 def get_context_data(self, **kwargs):
     context = super(ProductCrossSellEditView, self).get_context_data(**kwargs)
     context["title"] = _("Edit Cross-Sell: %s") % self.object
     context["toolbar"] = Toolbar([
         PostActionButton(
             icon="fa fa-save",
             form_id="xsell_form",
             text=_("Save"),
             extra_css_class="btn-success",
         ),
     ], view=self)
     return context
Пример #3
0
 def get_context_data(self, **kwargs):
     context = super(OrderAddressEditView, self).get_context_data(**kwargs)
     context["title"] = _("Save -- %s") % context["order"]
     context["toolbar"] = Toolbar([
         PostActionButton(
             icon="fa fa-check-circle",
             form_id="edit-addresses",
             text=_("Save"),
             extra_css_class="btn-primary",
         ),
     ], view=self)
     return context
Пример #4
0
 def _build_cancel_button(self):
     self.append(PostActionButton(
         post_url=reverse("E-Commerce_admin:order.set-status", kwargs={"pk": self.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 self.order.can_set_canceled()
             else None
         ),
         extra_css_class="btn-danger btn-inverse"
     ))
Пример #5
0
 def _build_set_complete_button(self):
     self.append(PostActionButton(
         post_url=reverse("E-Commerce_admin:order.set-status", kwargs={"pk": self.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 self.order.can_set_complete()
             else None
         ),
         extra_css_class="btn-success"
     ))
Пример #6
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
Пример #7
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
Пример #8
0
 def get_toolbar(self):
     product_type = self.get_object()
     save_form_id = self.get_save_form_id()
     delete_url = reverse_lazy(
         "E-Commerce_admin:product_type.delete", kwargs={"pk": product_type.pk}
     ) if product_type.pk else None
     toolbar = get_default_edit_toolbar(self, save_form_id)
     if not delete_url:
         return toolbar
     toolbar.append(PostActionButton(
         post_url=delete_url,
         text=_(u"Delete"),
         icon="fa fa-trash",
         extra_css_class="btn-danger",
         confirm=_("Are you sure you wish to delete %s? Warrning: all related products will disappear from storefront until new value for product type is set!") % product_type,  # noqa
         required_permissions=()
     ))
     return toolbar
Пример #9
0
    def build_renew_password_button(self):
        disable_reason = None

        if "E-Commerce.front.apps.auth" not in settings.INSTALLED_APPS:
            disable_reason = _("The E-Commerce frontend is not enabled.")
        elif not self.user:
            disable_reason = _("Contact has no associated user.")
        elif not getattr(self.user, "email", None):
            disable_reason = _("User has no associated email.")

        return PostActionButton(
            post_url=reverse("E-Commerce_admin:contact.reset_password", kwargs={"pk": self.contact.pk}),
            name="pk",
            value=self.contact.pk,
            text=_(u"Reset password"),
            tooltip=_(u"Send a password renewal email."),
            confirm=_("Are you sure you wish to send a password recovery email to %s?") % self.contact.email,
            icon="fa fa-undo",
            disable_reason=disable_reason,
            extra_css_class="dropdown-item",
        )
Пример #10
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("E-Commerce_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"] = {
            line.ordering: self._get_line_data(self.object, line)
            for line in lines
        }
        return context
Пример #11
0
    def _build_existing_user(self):
        user = self.user
        change_password_button = DropdownItem(
            url=reverse("E-Commerce_admin:user.change-password", kwargs={"pk": user.pk}),
            text=_(u"Change Password"), icon="fa fa-exchange",
            required_permissions=["user.change-password"]
        )
        reset_password_button = DropdownItem(
            url=reverse("E-Commerce_admin:user.reset-password", kwargs={"pk": user.pk}),
            disable_reason=(_("User has no email address") if not getattr(user, 'email', '') else None),
            text=_(u"Send Password Reset Email"), icon="fa fa-envelope",
            required_permissions=["user.reset-password"]
        )
        permissions_button = DropdownItem(
            url=reverse("E-Commerce_admin:user.change-permissions", kwargs={"pk": user.pk}),
            text=_(u"Edit Permissions"), icon="fa fa-lock", required_permissions=["user.change-permissions"]
        )
        menu_items = [
            change_password_button,
            reset_password_button,
            permissions_button,
            DropdownDivider()
        ]

        person_contact = PersonContact.objects.filter(user=user).first()
        if person_contact:
            contact_url = reverse("E-Commerce_admin:contact.detail", kwargs={"pk": person_contact.pk})
            menu_items.append(DropdownItem(
                url=contact_url,
                icon="fa fa-search",
                text=_("Contact Details"),
                required_permissions=["contact.detail"]
            ))
        else:
            contact_url = reverse("E-Commerce_admin:contact.new") + "?type=person&user_id=%s" % user.pk
            menu_items.append(DropdownItem(
                url=contact_url,
                icon="fa fa-plus",
                text=_(u"New Contact"),
                tooltip=_("Create a new contact and associate it with this user"),
                required_permissions=["contact.new"]
            ))
        self.append(DropdownActionButton(
            menu_items,
            icon="fa fa-star",
            text=_(u"Actions"),
            extra_css_class="btn-info",
        ))
        if not user.is_active:
            self.append(PostActionButton(
                post_url=self.request.path,
                name="set_is_active",
                value="1",
                icon="fa fa-check-circle",
                text=_(u"Activate User"),
                extra_css_class="btn-gray",
            ))
        else:
            self.append(PostActionButton(
                post_url=self.request.path,
                name="set_is_active",
                value="0",
                icon="fa fa-times-circle",
                text=_(u"Deactivate User"),
                extra_css_class="btn-gray",
            ))

        if (self.request.user.is_superuser and get_front_url() and
                user.is_active and not user.is_superuser and not user.is_staff):
            self.append(PostActionButton(
                post_url=reverse("E-Commerce_admin:user.login-as", kwargs={"pk": user.pk}),
                text=_(u"Login as User"),
                extra_css_class="btn-gray"
            ))