Skip to content

Commit

Permalink
Merge pull request #524 from DevCom-IITB/placement_blog_access
Browse files Browse the repository at this point in the history
remove alumni access to placement blog
  • Loading branch information
HariRags authored Nov 19, 2024
2 parents ebf357c + 3503003 commit bfdb31e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions placements/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
from roles.helpers import login_required_ajax
from helpers.misc import query_from_num
from helpers.misc import query_search
from alumni.models import AlumniUser
from users.models import UserProfile


class PlacementBlogViewset(viewsets.ViewSet):
@classmethod
@login_required_ajax
def placement_blog(cls, request):
"""Get Placement Blog."""
# Retrieve the UserProfile of the logged-in user
user_profile = UserProfile.objects.get(user=request.user)

# Check if the ldap of the UserProfile exists in the AlumniUser model
if AlumniUser.objects.filter(ldap=user_profile.ldap_id).exists():
return Response({"error": "Alumni cannot access this page."}, status=403)
queryset = BlogEntry.objects.filter(blog_url=settings.PLACEMENTS_URL_VAL)
queryset = query_search(request, 3, queryset, ["title", "content"], "placement")
# queryset = queryset.order_by('-pinned', "-published")
Expand Down

0 comments on commit bfdb31e

Please sign in to comment.