Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Cursus
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
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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-App-Cursus
Merge requests
!42
Factor out some field types from CSV import app
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Factor out some field types from CSV import app
csv-import
into
master
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
Jonathan Weth
requested to merge
csv-import
into
master
10 months ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
2c45ba3b
1 commit,
10 months ago
1 file
+
35
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
aleksis/apps/cursus/model_extensions.py
0 → 100644
+
35
−
0
Options
from
django.apps
import
apps
from
django.db.models
import
Model
from
django.utils.translation
import
gettext
as
_
from
.models
import
Course
,
Subject
if
apps
.
is_installed
(
"
aleksis.apps.csv_import
"
):
from
aleksis.apps.csv_import.field_types
import
ProcessFieldType
class
GroupSubjectByShortNameFieldType
(
ProcessFieldType
):
name
=
"
group_subject_short_name
"
verbose_name
=
_
(
"
Short name of the subject
"
)
def
process
(
self
,
instance
:
Model
,
value
):
subject
,
__
=
Subject
.
objects
.
get_or_create
(
short_name
=
value
,
defaults
=
{
"
name
"
:
value
})
instance
.
subject
=
subject
instance
.
save
()
class
SubjectByShortNameFieldType
(
ProcessFieldType
):
name
=
"
subject_by_short_name
"
verbose_name
=
_
(
"
Short name of the subject
"
)
run_before_save
=
True
def
process
(
self
,
instance
:
Model
,
value
):
subject
,
__
=
Subject
.
objects
.
get_or_create
(
short_name
=
value
,
defaults
=
{
"
name
"
:
value
})
instance
.
subject
=
subject
class
CourseByUniqueReferenceFieldType
(
ProcessFieldType
):
name
=
"
course_by_unique_reference
"
verbose_name
=
_
(
"
Short name of the subject
"
)
run_before_save
=
True
def
process
(
self
,
instance
:
Model
,
value
):
course
=
Course
.
objects
.
get
(
extended_data__import_ref_csv
=
value
)
instance
.
course
=
course
Loading