Skip to content

Commit

Permalink
Fix documentation typos and requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
maerteijn committed Nov 2, 2020
1 parent fc11c71 commit 9444fe1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Django==2.2.13
sphinx
sphinx_rtd_theme
sphinx_rtd_theme
django-oscar==2.1
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

# General information about the project.
project = u'Django Osar API'
copyright = u'2015, 2016 Django Oscar'
copyright = u'2015-2020 jango Oscar'
author = u'Lars van de Kerkhof, Martijn Jacobs'

# The version info for the project you're documenting, acts as replacement for
Expand Down
30 changes: 15 additions & 15 deletions docs/source/usage/the_admin_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ The endpoints which Oscar API exposes by default are mostly suitable for checkou
* Use Oscar with the *Admin API* as a SAAS solution: let other developers and companies integrate Oscar with their products
* *Push synchronization* of stockrecords / products / categories / partners instead of import scripts etc.

..note::
To enable the admin api, you must first set ``OSCARAPI_BLOCK_ADMIN_API_ACCESS`` to ``False`` in your settings file.
.. note::
To enable the Admin API, you must first set ``OSCARAPI_BLOCK_ADMIN_API_ACCESS`` to ``False`` in your settings file.

To gain access to the *Admin API* you will beed to be a staff user (``IsAdminUser`` in `DRF`_). The ``APIAdminPermission`` (see also :ref:`permissions-label`) is used to grant access to the different models in the *Admin API* and what you can do with them. So if you only have the *view* and *edit permissions* for the ``Product`` model you are only allowed to view and edit products. To delete products you need the *delete* permission as well.

Expand All @@ -22,15 +22,15 @@ The *Admin API* is also accessible in the browsable API when your logged in user
.. image:: ../images/admin-api.png
:alt: The Admin API

Example add an image
--------------------
Example: add an image
---------------------

To add an image to an exiting product and change nothing else, it is best to use
the ``PATCH`` http method. This will let you send incomplete information to
the api, and update only what is being sent.
To add an image to an existing product and change nothing else, it is best to use
the ``PATCH`` http method. This will let you send partial information to
the API, and update only what is being sent.

The are 2 methods to update and existing product, depending on whether you
know the current api url or you only know the product ``upc``.
There are two methods to update an existing product, depending on whether you
know the current API url or you only know the product ``upc``.

Suppose we know the full url then it can be done like this::

Expand All @@ -45,10 +45,10 @@ Suppose we know the full url then it can be done like this::
}
)

The api will download the image from that url and add it to the list.
The API will download the image from that url and add it to the list.

Suppose you don't know the url in the api, you'd have to know some unique attribute,
for example the upc. You can just use the product list api and if you send
Suppose you don't know the url in the API, you'd have to know some unique attribute,
for example, the UPC. You can just use the product list API and if you send
enough data to uniquely identify the product, it will succeed::

session.post(
Expand All @@ -64,16 +64,16 @@ enough data to uniquely identify the product, it will succeed::
)

That will also work, you can even try to paste the bodies into the browsable
html api and it will update your product and add the image. The second method
makes the api very suitable for integration with external parties, you can just
html API and it will update your product and add the image. The second method
makes the APO very suitable for integration with external parties, you can just
send updates and forget about it, no need to search for the product first or
whatever.

An optimization
---------------

Suppose you want to integrate with an external system and want to send you data
in a fire and forget way. If you have a lot of images, the api will need to
in a fire and forget way. If you have a lot of images, the API will need to
download the images every time, to check if they are know images or new images
to determine if there is anything to update. That is a lot of useless traffic.

Expand Down

0 comments on commit 9444fe1

Please sign in to comment.