Skip to content

Commit

Permalink
add changes to the views
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Nov 1, 2023
1 parent 3053c11 commit e3d2ab0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 31 deletions.
18 changes: 9 additions & 9 deletions breathecode/admissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class AcademyTeacherView(APIView, GenerateLookupsMixin):

@capable_of('read_member')
def get(self, request, academy_id):

handler = self.extensions(request)

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = ProfileAcademy.objects.filter(academy__id=academy_id,
role__slug__in=['teacher', 'assistant'
Expand Down Expand Up @@ -296,7 +296,7 @@ def get(self, request, format=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

try:
if isinstance(request.user, AnonymousUser):
Expand Down Expand Up @@ -363,7 +363,7 @@ def get(self, request):

# cache = handler.cache.get()
# if cache is not None:
# return Response(cache, status=status.HTTP_200_OK)
# return cache

items = CohortUser.objects.all()

Expand Down Expand Up @@ -567,7 +567,7 @@ def get(self, request, format=None, cohort_id=None, user_id=None, academy_id=Non

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

if user_id is not None:
item = CohortUser.objects.filter(cohort__academy__id=academy_id,
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def get(self, request, cohort_id=None, academy_id=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

if cohort_id is not None:
if cohort_id.isnumeric():
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def get(self, request, cohort_id=None, academy_id=None):

# cache = handler.cache.get()
# if cache is not None:
# return Response(cache, status=status.HTTP_200_OK)
# return cache

if cohort_id is not None:
item = None
Expand Down Expand Up @@ -1589,7 +1589,7 @@ def get(self, request, syllabus_id=None, syllabus_slug=None, version=None, acade

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

if academy_id is None:
raise ValidationException('Missing academy id', slug='missing-academy-id')
Expand Down Expand Up @@ -1752,7 +1752,7 @@ def get(self, request):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = CohortUser.objects.all()

Expand Down
6 changes: 4 additions & 2 deletions breathecode/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,10 @@ class CohortTaskView(APIView, GenerateLookupsMixin):
@capable_of('read_assignment')
def get(self, request, cohort_id, academy_id):
handler = self.extensions(request)

# cache = handler.cache.get()
# if cache is not None:
# return Response(cache, status=status.HTTP_200_OK)
# return cache

items = Task.objects.all()
lookup = {}
Expand Down Expand Up @@ -523,9 +524,10 @@ class TaskMeView(APIView):

def get(self, request, task_id=None, user_id=None):
handler = self.extensions(request)

# cache = handler.cache.get()
# if cache is not None:
# return Response(cache, status=status.HTTP_200_OK)
# return cache

if not user_id:
user_id = request.user.id
Expand Down
6 changes: 3 additions & 3 deletions breathecode/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get(self, request, event_id=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = get_my_event_types(request.user)
lang = get_user_language(request)
Expand Down Expand Up @@ -232,7 +232,7 @@ def get(self, request):

cache = handler.cache.get()
if cache is not None:
return HttpResponse('{}', content_type='application/json', status=status.HTTP_200_OK)
return cache

lang = get_user_language(request)

Expand Down Expand Up @@ -416,7 +416,7 @@ def get(self, request, academy_id=None, event_id=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

if event_id is not None:
single_event = Event.objects.filter(id=event_id, academy__id=academy_id).first()
Expand Down
2 changes: 1 addition & 1 deletion breathecode/feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get(self, request, format=None, academy_id=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = Answer.objects.filter(academy__id=academy_id)
lookup = {}
Expand Down
2 changes: 1 addition & 1 deletion breathecode/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ def get(self, request, course_slug=None):

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

lang = get_user_language(request)

Expand Down
4 changes: 2 additions & 2 deletions breathecode/mentorship/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,10 @@ class MentorView(APIView, HeaderLimitOffsetPagination):
@capable_of('read_mentorship_mentor')
def get(self, request, mentor_id=None, academy_id=None):
handler = self.extensions(request)
cache = handler.cache.get()

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

if mentor_id is not None:
mentor = MentorProfile.objects.filter(id=mentor_id, services__academy__id=academy_id).first()
Expand Down
2 changes: 1 addition & 1 deletion breathecode/payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def get(self, request):

# cache = handler.cache.get()
# if cache is not None:
# return Response(cache, status=status.HTTP_200_OK)
# return cache

lang = get_user_language(request)
utc_now = timezone.now()
Expand Down
24 changes: 12 additions & 12 deletions breathecode/registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get(self, request, academy_id=None):
handler = self.extensions(request)
cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = AssetTechnology.objects.all()
lookup = {}
Expand Down Expand Up @@ -483,10 +483,10 @@ class AssetView(APIView, GenerateLookupsMixin):

def get(self, request, asset_slug=None):
handler = self.extensions(request)
cache = handler.cache.get()

cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

lang = get_user_language(request)

Expand Down Expand Up @@ -760,16 +760,16 @@ class AcademyAssetView(APIView, GenerateLookupsMixin):

@capable_of('read_asset')
def get(self, request, asset_slug=None, academy_id=None):
handler = self.extensions(request)

cache = handler.cache.get()
if cache is not None:
return cache

member = ProfileAcademy.objects.filter(user=request.user, academy__id=academy_id).first()
if member is None:
raise ValidationException("You don't belong to this academy", status.HTTP_400_BAD_REQUEST)

handler = self.extensions(request)
cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)

if asset_slug is not None:
asset = Asset.get_by_slug(asset_slug, request)
if asset is None or (asset.academy is not None and asset.academy.id != int(academy_id)):
Expand Down Expand Up @@ -1022,7 +1022,7 @@ def get(self, request, academy_id=None):
handler = self.extensions(request)
cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = AssetComment.objects.filter(asset__academy__id=academy_id)
lookup = {}
Expand Down Expand Up @@ -1127,7 +1127,7 @@ def get(self, request, category_slug=None, academy_id=None):
handler = self.extensions(request)
cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = AssetCategory.objects.filter(academy__id=academy_id)
lookup = {}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ def get(self, request, keyword_slug=None, academy_id=None):
handler = self.extensions(request)
cache = handler.cache.get()
if cache is not None:
return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
return cache

items = AssetKeyword.objects.filter(academy__id=academy_id)
lookup = {}
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def get(self, request, cluster_slug=None, academy_id=None):
# cache has been disabled because I cant get it to refresh then keywords are resigned to assets
# cache = handler.cache.get()
# if cache is not None:
# return HttpResponse(cache, content_type='application/json', status=status.HTTP_200_OK)
# return cache

items = KeywordCluster.objects.filter(academy__id=academy_id)
lookup = {}
Expand Down

0 comments on commit e3d2ab0

Please sign in to comment.