feat(organization): add tool search, filter and access organization w…#449
Open
ZephyrNova47 wants to merge 1 commit intoVNOI-Admin:masterfrom
Open
feat(organization): add tool search, filter and access organization w…#449ZephyrNova47 wants to merge 1 commit intoVNOI-Admin:masterfrom
ZephyrNova47 wants to merge 1 commit intoVNOI-Admin:masterfrom
Conversation
leduythuccs
requested changes
Oct 17, 2025
Comment on lines
+22
to
+30
| {% block body %} | ||
| <div class="search-container"> | ||
| <form method="get" class="search-form"> | ||
| <input type="text" name="search" class="search-input" placeholder="{{ _('Search organizations...') }}" | ||
| value="{{ request.GET.search }}"> | ||
| <button type="submit" class="search-submit"><i class="fa fa-search"></i></button> | ||
| </form> | ||
| </div> | ||
|
|
Contributor
Contributor
Author
There was a problem hiding this comment.
omg =))) let me check
Comment on lines
+147
to
+149
| # Allow superusers and staff to access any organization | ||
| if self.request.user.is_superuser or self.request.user.is_staff: | ||
| return True |
Contributor
There was a problem hiding this comment.
this check is redundant, if user is superuser, they already have the judge.edit_organization, also i think better to leave the PrivateOrganizationMixin alone, don't change it
Contributor
Author
There was a problem hiding this comment.
ok, i understand
Comment on lines
+529
to
+558
| class OrganizationHomeById(TitleMixin, OrganizationByIdMixin, PostListBase): | ||
| template_name = 'organization/home.html' | ||
|
|
||
| def get_title(self): | ||
| return self.organization.name | ||
|
|
||
| def get_queryset(self): | ||
| queryset = BlogPost.objects.filter(organization=self.organization) | ||
|
|
||
| if not self.request.user.has_perm('judge.edit_all_post'): | ||
| if not self.can_edit_organization(): | ||
| if self.request.profile in self.organization: | ||
| # Normal user can only view public posts | ||
| queryset = queryset.filter(publish_on__lte=timezone.now(), visible=True) | ||
| else: | ||
| # User cannot view organization blog | ||
| # if they are not in the org | ||
| # even if the org is public | ||
| queryset = BlogPost.objects.none() | ||
| else: | ||
| # Org admin can view public posts & their own posts | ||
| queryset = queryset.filter(Q(visible=True) | Q(authors=self.request.profile)) | ||
|
|
||
| if self.request.user.is_authenticated: | ||
| profile = self.request.profile | ||
| queryset = queryset.annotate( | ||
| my_vote=FilteredRelation('votes', condition=Q(votes__voter_id=profile.id)), | ||
| ).annotate(vote_score=Coalesce(F('my_vote__score'), Value(0))) | ||
|
|
||
| return queryset.order_by('-sticky', '-publish_on').prefetch_related('authors__user') |
Contributor
There was a problem hiding this comment.
this is ok but it's make the code duplicated, is there a better way? Perhaps we could inherit the OrganizationHome, and override the get_object/get_query_set?
Contributor
Author
There was a problem hiding this comment.
Yes, I’ll switch to overriding get_object() or get_queryset() instead that way I can reuse the logic from OrganizationHome and avoid code duplication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Access Organization by ID
Description
This change adds the ability to access organizations directly by their ID number in addition to the existing slug-based access and search and filtering capabilities. This makes it easier for admins to navigate to organizations directly from the admin interface and provides a more reliable way to access organizations programmatically.
Type of change: New feature
What
ID-based Access
/organization/id/<number>OrganizationByIdMixinfor handling ID-based organization accessAdmin Interface Enhancements
is_open)is_unlisted)Why
Fixes: Add organization ID access #[issue_number]
How Has This Been Tested?
Test Configuration:
Checklist
Screenshots:
By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.