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
7f874743
Verified
Commit
7f874743
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Disable multi-tenancy for now. Mitigates
#77
.
parent
1f897403
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/core/mixins.py
+1
-12
1 addition, 12 deletions
biscuit/core/mixins.py
biscuit/core/util/core_helpers.py
+2
-35
2 additions, 35 deletions
biscuit/core/util/core_helpers.py
with
3 additions
and
47 deletions
biscuit/core/mixins.py
+
1
−
12
View file @
7f874743
...
...
@@ -3,22 +3,11 @@ from django.db import models
from
.util.core_helpers
import
get_current_school
class
SchoolRelatedManager
(
models
.
Manager
):
def
get_queryset
(
self
)
->
models
.
query
.
QuerySet
:
qs
=
super
().
get_queryset
()
school
=
get_current_school
()
if
school
:
return
qs
.
filter
(
school
=
school
)
else
:
return
qs
.
none
()
class
SchoolRelated
(
models
.
Model
):
class
Meta
:
abstract
=
True
objects
=
SchoolRelatedManager
()
#
objects = SchoolRelatedManager()
school
=
models
.
ForeignKey
(
'
core.School
'
,
on_delete
=
models
.
CASCADE
,
default
=
get_current_school
)
This diff is collapsed.
Click to expand it.
biscuit/core/util/core_helpers.py
+
2
−
35
View file @
7f874743
from
importlib
import
import_module
import
pkgutil
from
typing
import
Optional
,
Sequence
from
warnings
import
warn
from
django.apps
import
apps
from
django.conf
import
settings
from
django.http
import
HttpRequest
from
django_global_request.middleware
import
get_request
def
get_app_packages
()
->
Sequence
[
str
]:
"""
Find all packages within the biscuit.apps namespace.
"""
...
...
@@ -34,36 +29,8 @@ def get_app_packages() -> Sequence[str]:
return
pkgs
# FIXME Use more specific result type
def
get_current_school
()
->
Optional
:
request
=
get_request
()
if
request
:
# We are inside a web request, thus called from a public interface
if
hasattr
(
request
,
'
user
'
)
and
hasattr
(
request
.
user
,
'
person
'
):
# Use the same school as that of the logged-in user
return
request
.
user
.
person
.
school
else
:
# Set no school so no data is ever returned
# during an unauthenticated request
return
None
else
:
# We are called from outside a request (probably shell),
# thus called from a private interface
School
=
apps
.
get_model
(
'
core.School
'
)
if
hasattr
(
settings
,
'
DEFAULT_SCHOOL
'
):
# Use school defined in settings
return
School
.
objects
.
get
(
pk
=
settings
.
DEFAULT_SCHOOL
)
else
:
# Use first school
warn
(
'
No school set, using first known school.
'
,
RuntimeWarning
)
return
School
.
objects
.
first
()
# Raise an exception because not finding a school wreaks havoc
raise
RuntimeError
(
'
No school set or found. Check your database.
'
)
def
get_current_school
()
->
int
:
return
1
def
is_impersonate
(
request
:
HttpRequest
)
->
bool
:
...
...
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