creating admin API
This commit is contained in:
parent
38f2b96ea1
commit
d98acb5963
0
admin_api/__init__.py
Normal file
0
admin_api/__init__.py
Normal file
BIN
admin_api/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
admin_api/__pycache__/admin.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
admin_api/__pycache__/apps.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
admin_api/__pycache__/models.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
admin_api/__pycache__/urls.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/urls.cpython-310.pyc
Normal file
Binary file not shown.
BIN
admin_api/__pycache__/views.cpython-310.pyc
Normal file
BIN
admin_api/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
3
admin_api/admin.py
Normal file
3
admin_api/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
6
admin_api/apps.py
Normal file
6
admin_api/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AdminApiConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'admin_api'
|
0
admin_api/migrations/__init__.py
Normal file
0
admin_api/migrations/__init__.py
Normal file
BIN
admin_api/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
admin_api/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
3
admin_api/models.py
Normal file
3
admin_api/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
12
admin_api/serializer.py
Normal file
12
admin_api/serializer.py
Normal file
@ -0,0 +1,12 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Level, Standards
|
||||
|
||||
class LevelSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Level
|
||||
fields = '__all__'
|
||||
|
||||
class StandardsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Standards
|
||||
fields = '__all__'
|
3
admin_api/tests.py
Normal file
3
admin_api/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
14
admin_api/urls.py
Normal file
14
admin_api/urls.py
Normal file
@ -0,0 +1,14 @@
|
||||
from django.urls import path, include
|
||||
from rest_framework import routers
|
||||
from .views import LevelViewSet, StandardsViewSet
|
||||
from . import views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'levels', LevelViewSet)
|
||||
router.register(r'standards', StandardsViewSet)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('content-list/', views.contentList, name='content-list'),
|
||||
]
|
50
admin_api/views.py
Normal file
50
admin_api/views.py
Normal file
@ -0,0 +1,50 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework import viewsets
|
||||
from search_tfidf.models import Level, Standards
|
||||
from search_tfidf.serializer import LevelSerializer, StandardsSerializer
|
||||
from django.http import JsonResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from rest_framework.decorators import api_view
|
||||
# Create your views here.
|
||||
|
||||
class LevelViewSet(viewsets.ModelViewSet):
|
||||
queryset = Level.objects.all()
|
||||
serializer_class = LevelSerializer
|
||||
|
||||
class StandardsViewSet(viewsets.ModelViewSet):
|
||||
queryset = Standards.objects.all()
|
||||
serializer_class = StandardsSerializer
|
||||
|
||||
@csrf_exempt
|
||||
@api_view(['GET'])
|
||||
def contentList(request):
|
||||
# Get the values from the request parameters
|
||||
level = request.GET.get('level')
|
||||
standard = request.GET.get('standard')
|
||||
data = ""
|
||||
|
||||
#module_path = filePath(level, standard)
|
||||
print(level, standard)
|
||||
# Read the JSON file
|
||||
#with open(module_path) as f:
|
||||
# data = json.load(f)
|
||||
|
||||
# Return the filtered data as a JSON response
|
||||
return JsonResponse({'contents': data})
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
def filePath(level_input, standard_input):
|
||||
standards_dir = os.path.join(BASE_DIR, 'static/data/')
|
||||
file_path = ''
|
||||
levels = next(os.walk(os.path.join(BASE_DIR, 'static/data')), (None, None, []))[1]
|
||||
if str(level_input) in levels:
|
||||
filenames = next(os.walk(standards_dir+level_input), (None, None, []))[2]
|
||||
for file in filenames:
|
||||
if str(standard_input) in file:
|
||||
file_path = standards_dir+str(level_input)+'/'+file
|
||||
|
||||
return file_path
|
Binary file not shown.
Binary file not shown.
@ -46,6 +46,7 @@ INSTALLED_APPS = [
|
||||
'rest_framework',
|
||||
'django_filters',
|
||||
'search_tfidf',
|
||||
'admin_api',
|
||||
'corsheaders',
|
||||
]
|
||||
|
||||
|
@ -18,5 +18,6 @@ from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('search_tfidf.urls')),
|
||||
path('client_api/', include('search_tfidf.urls')),
|
||||
path('admin_api/', include('admin_api.urls')),
|
||||
]
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[]
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[]
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[]
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[]
|
@ -1 +0,0 @@
|
||||
[]
|
File diff suppressed because one or more lines are too long
BIN
static/IDDRSStandards/1/IDDRS-1.10-Introduction-To-The-IDDRS.pdf
Normal file
BIN
static/IDDRSStandards/1/IDDRS-1.10-Introduction-To-The-IDDRS.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/1/IDDRS-1.20-Glossary.pdf
Normal file
BIN
static/IDDRSStandards/1/IDDRS-1.20-Glossary.pdf
Normal file
Binary file not shown.
17575
static/IDDRSStandards/2/IDDRS-2.10-The-UN-Approach-To-DDR.pdf
Normal file
17575
static/IDDRSStandards/2/IDDRS-2.10-The-UN-Approach-To-DDR.pdf
Normal file
File diff suppressed because it is too large
Load Diff
19032
static/IDDRSStandards/2/IDDRS-2.11-The-Legal-Framework-For-UNDDR.pdf
Normal file
19032
static/IDDRSStandards/2/IDDRS-2.11-The-Legal-Framework-For-UNDDR.pdf
Normal file
File diff suppressed because it is too large
Load Diff
15277
static/IDDRSStandards/2/IDDRS-2.20-The-Politics-of-DDR.pdf
Normal file
15277
static/IDDRSStandards/2/IDDRS-2.20-The-Politics-of-DDR.pdf
Normal file
File diff suppressed because it is too large
Load Diff
20697
static/IDDRSStandards/2/IDDRS-2.30-Community-Violence-Reduction.pdf
Normal file
20697
static/IDDRSStandards/2/IDDRS-2.30-Community-Violence-Reduction.pdf
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
BIN
static/IDDRSStandards/3/IDDRS-3.20-DDR-Programme-Design.pdf
Normal file
BIN
static/IDDRSStandards/3/IDDRS-3.20-DDR-Programme-Design.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
static/IDDRSStandards/3/IDDRS-3.41-Finance-and-Budgeting.pdf
Normal file
BIN
static/IDDRSStandards/3/IDDRS-3.41-Finance-and-Budgeting.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/3/IDDRS-3.42-Personnel-and-Staffing.pdf
Normal file
BIN
static/IDDRSStandards/3/IDDRS-3.42-Personnel-and-Staffing.pdf
Normal file
Binary file not shown.
Binary file not shown.
BIN
static/IDDRSStandards/4/IDDRS-4.10-Disarmament.pdf
Normal file
BIN
static/IDDRSStandards/4/IDDRS-4.10-Disarmament.pdf
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
static/IDDRSStandards/4/IDDRS-4.20-Demobilization.pdf
Normal file
BIN
static/IDDRSStandards/4/IDDRS-4.20-Demobilization.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/4/IDDRS-4.30-Reintegration.pdf
Normal file
BIN
static/IDDRSStandards/4/IDDRS-4.30-Reintegration.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.10-Women-Gender-and-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.10-Women-Gender-and-DDR.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.20-Children-and-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.20-Children-and-DDR.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.30-Youth-and-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.30-Youth-and-DDR.pdf
Normal file
Binary file not shown.
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.50-Food-Assistance-in-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.50-Food-Assistance-in-DDR.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.60-HIV-AIDS-and-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.60-HIV-AIDS-and-DDR.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.70-Health-and-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.70-Health-and-DDR.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/5/IDDRS-5.80-Disability-Inclusive-DDR.pdf
Normal file
BIN
static/IDDRSStandards/5/IDDRS-5.80-Disability-Inclusive-DDR.pdf
Normal file
Binary file not shown.
3076
static/IDDRSStandards/6/IDDRS-6.10-DDR-and-SSR.pdf
Normal file
3076
static/IDDRSStandards/6/IDDRS-6.10-DDR-and-SSR.pdf
Normal file
File diff suppressed because one or more lines are too long
1798
static/IDDRSStandards/6/IDDRS-6.20-DDR-and-Transitional-Justice.pdf
Normal file
1798
static/IDDRSStandards/6/IDDRS-6.20-DDR-and-Transitional-Justice.pdf
Normal file
File diff suppressed because one or more lines are too long
BIN
static/IDDRSStandards/6/IDDRS-6.30-DDR-and-Natural-Resources.pdf
Normal file
BIN
static/IDDRSStandards/6/IDDRS-6.30-DDR-and-Natural-Resources.pdf
Normal file
Binary file not shown.
BIN
static/IDDRSStandards/6/IDDRS-6.40-DDR-and-Organized-Crime.pdf
Normal file
BIN
static/IDDRSStandards/6/IDDRS-6.40-DDR-and-Organized-Crime.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user