Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LinkAhead Loan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
LinkAhead Loan
Commits
7deec282
Commit
7deec282
authored
1 month ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: added a check that a loan does not reference the same box twice
parent
ba490b98
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
ENH: allow multiple items to be borrowed
Pipeline
#60396
passed with warnings
1 month ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loanpy/src/loan/request_loan.py
+9
-4
9 additions, 4 deletions
loanpy/src/loan/request_loan.py
with
9 additions
and
4 deletions
loanpy/src/loan/request_loan.py
+
9
−
4
View file @
7deec282
...
...
@@ -24,6 +24,7 @@ from __future__ import absolute_import
import
linkahead
as
db
from
caosadvancedtools.serverside.helper
import
get_timestamp
,
print_success
from
linkahead.common.models
import
get_id_from_versionid
,
value_matches_versionid
from
.box_loan
import
(
BORROWER
,
BOX
,
COMMENT
,
DESTINATION
,
EXHAUST_CONTENTS
,
EXPECTED_RETURN
,
F_BOX
,
F_COMMENT
,
F_DESTINATION
,
F_EMAIL
,
F_EXHAUST_CONTENTS
,
...
...
@@ -32,13 +33,17 @@ from .box_loan import (BORROWER, BOX, COMMENT, DESTINATION, EXHAUST_CONTENTS, EX
insert_or_update_person
,
main
,
send_loan_request_mail
)
def
create_loan
(
box
,
borrower
,
expected_return
,
exhaust_contents
,
comment
,
destination
):
def
create_loan
(
box
,
borrower
,
expected_return
,
exhaust_contents
,
comment
,
destination
):
"""
Create a new loan record.
"""
if
isinstance
(
box
,
list
):
ids
=
[
get_id_from_versionid
(
val
)
if
value_matches_versionid
(
val
)
else
val
for
val
in
box
]
ids
=
[
str
(
val
)
for
val
in
ids
]
if
len
(
ids
)
!=
len
(
set
(
ids
)):
raise
ValueError
(
"
The loan must not reference the same item twice
"
)
loan
=
db
.
Record
().
add_parent
(
LOAN
)
loan
.
add_property
(
BOX
,
box
,
datatype
=
(
db
.
LIST
(
BOX
.
name
)
if
isinstance
(
box
,
list
)
else
BOX
.
name
))
loan
.
add_property
(
BOX
,
box
,
datatype
=
(
db
.
LIST
(
BOX
.
name
)
if
isinstance
(
box
,
list
)
else
BOX
.
name
))
loan
.
add_property
(
BORROWER
,
borrower
)
loan
.
add_property
(
EXPECTED_RETURN
,
expected_return
)
loan
.
add_property
(
EXHAUST_CONTENTS
,
exhaust_contents
)
...
...
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