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
Merge requests
!422
Resolve "Add option to define rows for preferences forms"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add option to define rows for preferences forms"
337-add-option-to-define-rows-for-preferences-forms
into
master
Overview
3
Commits
3
Pipelines
4
Changes
2
All threads resolved!
Hide all comments
Merged
Jonathan Weth
requested to merge
337-add-option-to-define-rows-for-preferences-forms
into
master
4 years ago
Overview
3
Commits
3
Pipelines
4
Changes
2
All threads resolved!
Hide all comments
Expand
Closes
#337 (closed)
Edited
4 years ago
by
Jonathan Weth
0
0
Merge request reports
Compare
master
version 2
58d7de49
4 years ago
version 1
df1dc6cc
4 years ago
master (base)
and
latest version
latest version
8b8b6ec2
3 commits,
4 years ago
version 2
58d7de49
2 commits,
4 years ago
version 1
df1dc6cc
1 commit,
4 years ago
2 files
+
38
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
aleksis/core/util/forms.py
0 → 100644
+
34
−
0
Options
from
collections
import
OrderedDict
from
material
import
Layout
,
Row
class
PreferenceLayout
(
Layout
):
"""
django-material Layout object for managing preferences.
"""
def
__init__
(
self
,
form_base_class
,
section
=
None
):
"""
Create Layout object for the given form_base_class.
:param form_base_class: A Form class used as the base. Must have a ``registry` attribute
:param section: A section where the layout builder will load preferences
"""
registry
=
form_base_class
.
registry
if
section
:
# Try to use section param
preferences_obj
=
registry
.
preferences
(
section
=
section
)
else
:
# display all preferences in the form
preferences_obj
=
registry
.
preferences
()
rows
=
OrderedDict
()
for
preference
in
preferences_obj
:
row_name
=
preference
.
get
(
"
row
"
,
preference
.
identifier
())
rows
.
setdefault
(
row_name
,
[])
rows
[
row_name
].
append
(
preference
.
identifier
())
rows_material
=
[]
for
fields
in
rows
.
values
():
rows_material
.
append
(
Row
(
*
fields
))
super
().
__init__
(
*
rows_material
)
Loading