Fakultas Ilmu Komputer UI

config.py 1.27 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from api import models
from api import permissions as api_permissions
from api import serializers as api_serializers
from django import shortcuts
from rest_framework import generics
from rest_framework import permissions as rest_framework_permissions


class AppConfigDetail(generics.RetrieveUpdateAPIView):
    permission_classes = [rest_framework_permissions.IsAdminUser]
    queryset = models.AppConfig.objects.all()
    serializer_class = api_serializers.AppConfigSerializer

    def get_object(self):
        obj = shortcuts.get_object_or_404(models.AppConfig)
        return obj


class HelpContactConfigDetail(generics.RetrieveUpdateAPIView):
    permission_classes = [api_permissions.IsAdminUserOrReadOnly]
    queryset = models.HelpContactConfig.objects.all()
    serializer_class = api_serializers.HelpContactConfigSerializer

    def get_object(self):
        obj = shortcuts.get_object_or_404(models.HelpContactConfig)
        return obj


class ShipmentConfigDetail(generics.RetrieveUpdateAPIView):
    permission_classes = [api_permissions.IsAdminUserOrReadOnly]
    queryset = models.ShipmentConfig.objects.all()
    serializer_class = api_serializers.ShipmentConfigSerializer

    def get_object(self):
        obj = shortcuts.get_object_or_404(models.ShipmentConfig)
        return obj