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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
27d0b60e
Verified
Commit
27d0b60e
authored
Apr 30, 2020
by
Nik | Klampfradler
Committed by
Jonathan Weth
May 1, 2020
Browse files
Options
Downloads
Patches
Plain Diff
Move remaining parts to site preferences
parent
66a5c580
No related branches found
No related tags found
1 merge request
!217
Migrate from constance to dynamic-preferences
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/core/models.py
+4
-8
4 additions, 8 deletions
aleksis/core/models.py
aleksis/core/util/core_helpers.py
+7
-2
7 additions, 2 deletions
aleksis/core/util/core_helpers.py
aleksis/core/util/sass_helpers.py
+3
-3
3 additions, 3 deletions
aleksis/core/util/sass_helpers.py
with
14 additions
and
13 deletions
aleksis/core/models.py
+
4
−
8
View file @
27d0b60e
...
...
@@ -19,13 +19,9 @@ from polymorphic.models import PolymorphicModel
from
.mixins
import
ExtensibleModel
,
PureDjangoModel
from
.tasks
import
send_notification
from
.util.core_helpers
import
now_tomorrow
from
.util.core_helpers
import
get_site_preferences
,
now_tomorrow
from
.util.model_helpers
import
ICONS
from
dynamic_preferences.registries
import
global_preferences_registry
global_preferences
=
global_preferences_registry
.
manager
()
class
Person
(
ExtensibleModel
):
"""
A model describing any person related to a school, including, but not
...
...
@@ -117,9 +113,9 @@ class Person(ExtensibleModel):
@property
def
adressing_name
(
self
)
->
str
:
if
g
lobal
_preferences
[
"
notification__addressing_name_format
"
]
==
"
dutch
"
:
if
g
et_site
_preferences
()
[
"
notification__addressing_name_format
"
]
==
"
dutch
"
:
return
f
"
{
self
.
last_name
}
{
self
.
first_name
}
"
elif
g
lobal
_preferences
[
"
notification__addressing_name_format
"
]
==
"
english
"
:
elif
g
et_site
_preferences
()
[
"
notification__addressing_name_format
"
]
==
"
english
"
:
return
f
"
{
self
.
last_name
}
,
{
self
.
first_name
}
"
else
:
return
f
"
{
self
.
first_name
}
{
self
.
last_name
}
"
...
...
@@ -180,7 +176,7 @@ class Person(ExtensibleModel):
a primary group, unless force is True.
"""
pattern
=
pattern
or
g
lobal
_preferences
[
"
account__primary_group_pattern
"
]
pattern
=
pattern
or
g
et_site
_preferences
()
[
"
account__primary_group_pattern
"
]
if
pattern
:
if
force
or
not
self
.
primary_group
:
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/core_helpers.py
+
7
−
2
View file @
27d0b60e
...
...
@@ -88,6 +88,12 @@ def merge_app_settings(setting: str, original: Union[dict, list], deduplicate: b
raise
TypeError
(
"
Only dict and list settings can be merged.
"
)
def
get_site_preferences
():
"""
Get the preferences manager of the current site
"""
return
get_current_site
(
get_request
()).
preferences
def
lazy_preference
(
section
:
str
,
name
:
str
)
->
Callable
[[
str
,
str
],
Any
]:
"""
Lazily get a config value from dynamic preferences. Useful to bind preferences
to other global settings to make them available to third-party apps that are not
...
...
@@ -95,8 +101,7 @@ def lazy_preference(section: str, name: str) -> Callable[[str, str], Any]:
"""
def
_get_preference
(
section
:
str
,
name
:
str
)
->
Any
:
site
=
get_current_site
(
get_request
())
return
site
.
preferences
[
"
%s__%s
"
%
(
section
,
name
)]
return
get_site_preferences
()[
"
%s__%s
"
%
(
section
,
name
)]
# The type is guessed from the default value to improve lazy()'s behaviour
# FIXME Reintroduce the behaviour described above
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/sass_helpers.py
+
3
−
3
View file @
27d0b60e
from
django.conf
import
settings
from
colour
import
web2hex
from
dynamic_preferences.registries
import
global_preferences_registry
from
sass
import
SassColor
from
.util.core_helpers
import
get_site_preferences
def
get_colour
(
html_colour
:
str
)
->
SassColor
:
rgb
=
web2hex
(
html_colour
,
force_long
=
True
)[
1
:]
...
...
@@ -13,5 +13,5 @@ def get_colour(html_colour: str) -> SassColor:
def
get_preference
(
section
:
str
,
name
:
str
)
->
str
:
global_preferences
=
global_preferences_registry
.
manager
()
return
g
lobal
_preferences
[
"
%s__%s
"
%
(
section
,
name
)]
site
=
get_current_site
(
get_request
()
)
return
g
et_site
_preferences
()
[
"
%s__%s
"
%
(
section
,
name
)]
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