django-oscar / django-oscar-api

RESTful JSON API for django-oscar
Other
363 stars 160 forks source link

Feature Request - Partner Dashboard API #268

Open theArsalanM opened 3 years ago

theArsalanM commented 3 years ago

Django Oscar allow partners to login to dashboard, and perform operations specific to their store i.e view your orders, add/update your products etc.

Django Oscar API provides admin api, but seems like this API can be used by "staff users" or "superusers" only. This admin API cannot be used for standalone app for partners.

Is this the design principle of Oscar-API that doesn't allow partner APIs, or is this something we can work on as a new feature?

ibr9him commented 3 years ago

This would be nice.... Currently I am working on something similar. I want to query products by partner and expose that functionality through rest api.

what I am trying to achieve is GET /api/products/?partner=2

My work so far, I am trying to extend ProductList view and add my logic there. However I getting this error

File "/usr/local/lib/python3.7/site-packages/oscar/core/loading.py", line 176, in _pluck_classes
classname, ", ".join(packages)))
oscar.core.exceptions.ClassNotFoundError: No class 'ProducList' found in 

my work lives in APPNAME/forked_apps/api_customization

My code:

from oscarapi.utils.loading import get_api_class

ProducList = get_api_class("oscarapi.views.produst", "ProducList")

class ProductList(ProducList):

    def get_queryset(self):
        """
        Allow filtering on structure so standalone and parent products can
        be selected separately, eg::
            http://127.0.0.1:8000/api/products/?structure=standalone
        or::
            http://127.0.0.1:8000/api/products/?structure=parent
        """
        qs = super(ProductList, self).get_queryset()
        structure = self.request.query_params.get("structure")
        if structure is not None:
            return qs.filter(structure=structure)
        """
        Allow filtering on partner products, eg::
            http://127.0.0.1:8000/api/products/?partner=2
        """
        partner = self.request.query_params.get("partner")
        if partner is not None:
            return qs.filter(partner=partner)

        return qs

I could use some hints.

maerteijn commented 3 years ago

@ibr9him Hint: ProducList

Next to that, I think we need to solve this in a different way, see below.

maerteijn commented 3 years ago

Ok, I gave it some thought as I was actually not aware of the fact that you could link users to a Partner and that they can login into the oscar dashboard to view their products and orders.

I think that we can handle this by exposing the admin api for users attached to a specific partner. I will think about this and discuss this idea the following weeks.

ibr9him commented 3 years ago

@maerteijn gotcha.

Will now you mentioned it 'I think that we can handle this by exposing the admin api for users attached to a specific partner.' that was my next step.

Waiting to hear your thought on it and help if I could