Skip to content

Commit

Permalink
Add Edly site config api - EDLY-6656
Browse files Browse the repository at this point in the history
  • Loading branch information
Taimoor Ahmed authored and Taimoor Ahmed committed May 14, 2024
1 parent b4d068e commit d77c807
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions course_discovery/apps/edly_discovery_app/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
app_name = 'v1'
urlpatterns = [
url(r'^edly_sites/', edly_sites.EdlySiteViewSet.as_view(), name='edly_sites'),
url(r'^edly_site_config/', edly_sites.EdlySiteConfigViewset.as_view(), name='edly_site_config'),
url(r'^dataloader/', dataloader_api.EdlyDataLoaderView.as_view(), name='edly_dataloader'),
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Views for Edly Sites API.
"""
from django.contrib.sites.models import Site
from rest_framework import status, viewsets, filters
from rest_framework.authentication import SessionAuthentication
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -96,3 +95,24 @@ def get_updated_site_partner(self, discovery_site):
partner.save()

return partner


class EdlySiteConfigViewset(APIView):
"""
Create Default Site and Partner Configuration.
"""
permission_classes = [IsAuthenticated, CanAccessSiteCreation]

def post(self, request):
"""
POST /edly_api/v1/edly_site_config/
"""
site = request.site
site_partner = Partner.objects.get(site=site)
request_data = request.data.get('discovery', {})
current_plan = request_data.get('DJANGO_SETTINGS_OVERRIDE', {}).get('CURRENT_PLAN')
if current_plan == 'deactivated':
site_partner.is_disabled = True
site_partner.save()

return Response('Discovery site updated successfully', status=status.HTTP_200_OK)

0 comments on commit d77c807

Please sign in to comment.