API terminée
This commit is contained in:
parent
66cc4cd008
commit
1039d1e6d6
@ -1,3 +1,4 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Django settings for Lengow project.
|
||||
|
||||
@ -36,6 +37,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = [
|
||||
@ -115,3 +117,14 @@ USE_TZ = True
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = ['static']
|
||||
|
||||
# Rest Framework
|
||||
# TODO: Gérer l'authentification pour la modification / suppression via l'API
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
# Use Django's standard `django.contrib.auth` permissions,
|
||||
# or allow read-only access for unauthenticated users.
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||
]
|
||||
}
|
||||
|
@ -13,13 +13,21 @@ Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
from rest_framework import routers
|
||||
|
||||
from orders import views
|
||||
from orders.views import OrderViewSet
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'orders', OrderViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^$', views.OrderIndexView.as_view(), name='index'),
|
||||
url(r'^(?P<pk>[-\w]+)/$', views.OrderDetailView.as_view(), name='detail'),
|
||||
url(r'^api/', include(router.urls)),
|
||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
|
@ -1,5 +1,7 @@
|
||||
from django.views.generic import ListView, DetailView
|
||||
|
||||
from rest_framework import serializers, viewsets
|
||||
|
||||
from orders.models import Order
|
||||
|
||||
|
||||
@ -11,3 +13,16 @@ class OrderIndexView(ListView):
|
||||
class OrderDetailView(DetailView):
|
||||
template_name = 'orders/order/detail.html'
|
||||
model = Order
|
||||
|
||||
|
||||
class OrderSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = ('marketplace', 'idFlux', 'order_id', 'order_mrid', 'order_refid', 'order_external_id',
|
||||
'order_purchase', 'order_amount', 'order_tax', 'order_shipping', 'order_commission',
|
||||
'order_processing_fee', 'order_comments', 'customer_id', 'order_ip', 'order_items')
|
||||
|
||||
|
||||
class OrderViewSet(viewsets.ModelViewSet):
|
||||
queryset = Order.objects.all()
|
||||
serializer_class = OrderSerializer
|
||||
|
@ -1,2 +1,3 @@
|
||||
django
|
||||
pytz
|
||||
djangorestframework
|
||||
|
Loading…
Reference in New Issue
Block a user