-
Notifications
You must be signed in to change notification settings - Fork 27
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
Queues - show competitions using the queue #1317
Conversation
Perfect. |
@ihsaan-ullah There is a problem with this change: In def get_competitions(self, obj):
# get user from the context request
user = self.context['request'].user
# for super user return all competiitons using this queue
# for admin return competitions where this user is organizer using this queue
# for non-admin return public competitions using this queue
if user.is_superuser:
# Fetch all competitions
competitions = obj.competitions.all().values('id', 'title')
else:
# Fetch all competitions where user is organizer or competition is published
competitions = obj.competitions.filter(
Q(published=True) |
Q(created_by=user) |
Q(collaborators=user)
).values('id', 'title')
return competitions
When a user is not logged in and try to access the competition list, it raises the following error: TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User? |
Not sure if it's incidental (same naming for two different functions) or if the function should be edited. |
Solved in #1320 |
Actually the problem is something else and not the function name. The backend code really need rewriting but I am delaying it till we separate the frontend and backend, that could be a good opportunity to rewrite most of the code and simplify things. |
@ mention of reviewers
@Didayolo
A brief description of the purpose of the changes contained in this PR.
When viewing queue details, now you can see which competitions are using this queue with the following conditions:
Screenshot:
Issues this PR resolves
Checklist