Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove alumni access to placement blog #524

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading