Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Public contract registry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
TO
Public contract registry
Commits
f56e643d
Commit
f56e643d
authored
2 years ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
signing party normalization
parent
fdbe7781
No related branches found
No related tags found
1 merge request
!3
Release
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
contracts/management/commands/import_old_contracts.py
+32
-3
32 additions, 3 deletions
contracts/management/commands/import_old_contracts.py
with
32 additions
and
3 deletions
contracts/management/commands/import_old_contracts.py
+
32
−
3
View file @
f56e643d
...
...
@@ -7,6 +7,7 @@ from datetime import date, datetime
import
yaml
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
django.db
import
models
from
postal.parser
import
parse_address
from
git
import
Repo
...
...
@@ -300,10 +301,12 @@ class Command(BaseCommand):
"
česká pirátkská strana
"
,
"
česká pirátská stran
"
,
):
instance
=
Contractee
()
model
=
Contractee
instance
=
model
()
is_contractee
=
True
else
:
instance
=
Signee
(
name
=
name
,
address_country
=
"
Česká republika
"
)
model
=
Signee
instance
=
model
(
name
=
name
,
address_country
=
"
Česká republika
"
)
for
signing_party_key
,
signing_party_value
in
signing_party
.
items
():
if
isinstance
(
signing_party_value
,
str
):
...
...
@@ -352,6 +355,32 @@ class Command(BaseCommand):
case
"
IČ
"
:
instance
.
ico_number
=
signing_party_value
# Do our best to merge signing parties together.
existing_instance
=
model
.
objects
.
filter
(
(
models
.
Q
(
name
=
instance
.
name
)
&
(
(
models
.
Q
(
address_street_with_number
=
instance
.
address_street_with_number
)
if
instance
.
address_street_with_number
is
not
None
else
models
.
Value
(
False
)
)
|
(
models
.
Q
(
date_of_birth
=
instance
.
date_of_birth
)
if
model
is
Signee
and
instance
.
date_of_birth
is
not
None
else
models
.
Value
(
False
)
)
)
)
|
(
models
.
Q
(
ico_number
=
instance
.
ico_number
)
if
instance
.
ico_number
is
not
None
else
models
.
Value
(
False
)
)
).
first
()
if
existing_instance
is
not
None
:
instance
=
existing_instance
else
:
instance
.
save
()
return
instance
,
is_contractee
,
issue_count
...
...
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