Moved django over to rest_framework
This commit is contained in:
parent
d956f1aa52
commit
c49b5c169f
20
migratorapi/api/serializers.py
Normal file
20
migratorapi/api/serializers.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from .models import Migration
|
||||||
|
|
||||||
|
|
||||||
|
class MigrationSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Migration
|
||||||
|
fields = ['submit_time',
|
||||||
|
'domain',
|
||||||
|
'booked_time',
|
||||||
|
'original_server',
|
||||||
|
'new_server',
|
||||||
|
'username',
|
||||||
|
'notes',
|
||||||
|
'brand',
|
||||||
|
'ticket_id',
|
||||||
|
'migration_status',
|
||||||
|
'agent_booked',
|
||||||
|
'additional_domains',
|
||||||
|
'migration_type']
|
||||||
@ -1,7 +1,10 @@
|
|||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
from . import views
|
from . import views
|
||||||
|
from rest_framework import routers
|
||||||
|
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
router.register('migrations', views.MigrationViewSet)
|
||||||
|
|
||||||
app_name = 'api'
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.IndexView.as_view(), name='index')
|
path('', include(router.urls))
|
||||||
]
|
]
|
||||||
|
|||||||
@ -3,10 +3,18 @@ from django.http import HttpResponseRedirect
|
|||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from rest_framework import status, viewsets
|
||||||
|
from .serializers import MigrationSerializer
|
||||||
|
|
||||||
from .models import Migration
|
from .models import Migration
|
||||||
|
|
||||||
|
|
||||||
|
class MigrationViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Migration.objects.all()
|
||||||
|
serializer_class = MigrationSerializer
|
||||||
|
# permission_classes = (AllowAny,)
|
||||||
|
|
||||||
|
|
||||||
class IndexView(generic.ListView):
|
class IndexView(generic.ListView):
|
||||||
template_name = 'api/index.html'
|
template_name = 'api/index.html'
|
||||||
context_object_name = 'latest_migrations'
|
context_object_name = 'latest_migrations'
|
||||||
|
|||||||
@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'rest_framework',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
Reference in New Issue
Block a user