mirror of
https://github.com/lemeow125/Ivy-Backend.git
synced 2024-11-17 06:39:26 +08:00
Added user list url endpoints
This commit is contained in:
parent
3205880bde
commit
d2a869b685
4 changed files with 21 additions and 4 deletions
|
@ -143,6 +143,10 @@ DJOSER = {
|
|||
'SEND_ACTIVATION_EMAIL': True,
|
||||
'SEND_CONFIRMATION_EMAIL': True,
|
||||
'ACTIVATION_URL': 'activation/{uid}/{token}',
|
||||
'PERMISSIONS': {
|
||||
'user': ['rest_framework.permissions.AllowAny'],
|
||||
'user_list': ['rest_framework.permissions.AllowAny'],
|
||||
},
|
||||
}
|
||||
|
||||
EMAIL_HOST = 'sandbox.smtp.mailtrap.io'
|
||||
|
|
|
@ -29,7 +29,13 @@ class LogSerializer(serializers.HyperlinkedModelSerializer):
|
|||
|
||||
class Meta:
|
||||
model = Product.history.model
|
||||
fields = ('history_id', 'name', 'quantity',
|
||||
fields = ('history_id', 'id', 'name', 'quantity',
|
||||
'history_date', 'history_user_id')
|
||||
read_only_fields = ('history_id', 'name', 'quantity',
|
||||
read_only_fields = ('history_id', 'id', 'name', 'quantity',
|
||||
'history_date', 'history_user_id')
|
||||
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('id', 'username', 'email', 'date_joined')
|
||||
|
|
|
@ -6,6 +6,7 @@ router = routers.DefaultRouter()
|
|||
router.register(r'products', views.ProductViewSet)
|
||||
router.register(r'logs', views.LogViewSet)
|
||||
router.register(r'lowest_stock_product', views.LeastStockProductViewSet)
|
||||
router.register(r'user_list', views.UserListViewSet)
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework import viewsets
|
||||
from django.db.models import Min
|
||||
from .serializers import ProductSerializer, LogSerializer
|
||||
from django.contrib.auth.models import User
|
||||
from .serializers import ProductSerializer, LogSerializer, UserSerializer
|
||||
from .models import Product
|
||||
|
||||
|
||||
|
@ -11,6 +11,12 @@ class ProductViewSet(viewsets.ModelViewSet):
|
|||
queryset = Product.objects.all().order_by('-date_added')
|
||||
|
||||
|
||||
class UserListViewSet(viewsets.ModelViewSet):
|
||||
# permission_classes = [IsAuthenticated]
|
||||
serializer_class = UserSerializer
|
||||
queryset = User.objects.all()
|
||||
|
||||
|
||||
class LeastStockProductViewSet(viewsets.ModelViewSet):
|
||||
# permission_classes = [IsAuthenticated]
|
||||
http_method_names = ['get']
|
||||
|
|
Loading…
Reference in a new issue