Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
73bbe508
Commit
73bbe508
authored
4 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Add permission check for search
parent
eefc706a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!207
Resolve "Roles and permissions"
Pipeline
#1632
failed
4 years ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/urls.py
+2
-1
2 additions, 1 deletion
aleksis/core/urls.py
aleksis/core/views.py
+12
-0
12 additions, 0 deletions
aleksis/core/views.py
with
14 additions
and
1 deletion
aleksis/core/urls.py
+
2
−
1
View file @
73bbe508
...
...
@@ -9,6 +9,7 @@ from django.views.i18n import JavaScriptCatalog
import
calendarweek.django
import
debug_toolbar
from
django_js_reverse.views
import
urls_js
from
rules.contrib.views
import
permission_required
from
two_factor.urls
import
urlpatterns
as
tf_urls
from
.
import
views
...
...
@@ -41,7 +42,7 @@ urlpatterns = [
path
(
"
announcement/edit/<int:pk>/
"
,
views
.
announcement_form
,
name
=
"
edit_announcement
"
),
path
(
"
announcement/delete/<int:pk>/
"
,
views
.
delete_announcement
,
name
=
"
delete_announcement
"
),
path
(
"
search/searchbar/
"
,
views
.
searchbar_snippets
,
name
=
"
searchbar_snippets
"
),
path
(
"
search/
"
,
include
(
"
haystack
.urls
"
)
),
path
(
"
search/
"
,
views
.
PermissionSearchView
(),
name
=
"
haystack
_search
"
),
path
(
"
maintenance-mode/
"
,
include
(
"
maintenance_mode.urls
"
)),
path
(
"
impersonate/
"
,
include
(
"
impersonate.urls
"
)),
path
(
"
__i18n__/
"
,
include
(
"
django.conf.urls.i18n
"
)),
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/views.py
+
12
−
0
View file @
73bbe508
...
...
@@ -2,6 +2,7 @@ from importlib import import_module
from
typing
import
Optional
from
django.apps
import
apps
from
django.contrib.auth.mixins
import
PermissionRequiredMixin
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
,
HttpRequest
,
HttpResponse
from
django.shortcuts
import
get_object_or_404
,
redirect
,
render
...
...
@@ -11,6 +12,7 @@ from django_tables2 import RequestConfig
from
guardian.shortcuts
import
get_objects_for_user
from
haystack.inputs
import
AutoQuery
from
haystack.query
import
SearchQuerySet
from
haystack.views
import
SearchView
from
rules.contrib.views
import
permission_required
from
.forms
import
(
...
...
@@ -364,3 +366,13 @@ def searchbar_snippets(request: HttpRequest) -> HttpResponse:
context
=
{
"
results
"
:
results
}
return
render
(
request
,
"
search/searchbar_snippets.html
"
,
context
)
class
PermissionSearchView
(
PermissionRequiredMixin
,
SearchView
):
permission_required
=
"
core.search
"
def
create_response
(
self
):
context
=
self
.
get_context
()
if
not
self
.
has_permission
():
return
self
.
handle_no_permission
()
return
render
(
self
.
request
,
self
.
template
,
context
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment