Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin for payments #418

Open
paulocoutinhox opened this issue Aug 28, 2024 · 5 comments
Open

Admin for payments #418

paulocoutinhox opened this issue Aug 28, 2024 · 5 comments

Comments

@paulocoutinhox
Copy link
Contributor

Hi,

There is any admin for this payments?

Thanks.

@mariofix
Copy link
Member

Hi! I'm curious because most of the work is done automatically, what would you like to see in an admin?

I personally use django-baton and I can manage most payment cases editing the payment object.

@paulocoutinhox
Copy link
Contributor Author

No, i don't see admin things for the models/payments.

@WhyNotHugo
Copy link
Member

We don't currently ship an admin. I can't really imagine an implementation that would make sense; each project will have needs that are too specific in this sense.

FWIW, creating an admin is pretty simple. I use the following in one of my applications:

@admin.register(models.Payment, site=backoffice)
class PaymentAdmin(PaymentMixin, admin.ModelAdmin):
    view_on_site = False
    list_display = (
        "_display",
        "status",
        "variant",
        "order",
    )
    readonly_fields = (
        "invoice_type",
        "_display",
    )
    search_fields = ("order__pk",)
    raw_id_fields = (
        "order",
        "author",
        "receipt",
    )

    def get_queryset(self, request: HttpRequest) -> QuerySet[models.Payment]:
        return super().get_queryset(request).select_related("order")

    def has_add_permission(
        self,
        request: HttpRequest,
        obj: models.Payment | None = None,
    ) -> bool:
        return False

    def has_delete_permission(
        self,
        request: HttpRequest,
        obj: models.Payment | None = None,
    ) -> bool:
        return False

    def has_change_permission(
        self,
        request: HttpRequest,
        obj: models.Payment | None = None,
    ) -> bool:
        return False

@paulocoutinhox
Copy link
Contributor Author

paulocoutinhox commented Aug 29, 2024

Im not mean external admin, but im searching for the admin classes that make it appear on django admin.

The PaymentAdmin class that you sad above is the answer.

@WhyNotHugo
Copy link
Member

We can probably include it as an example in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants