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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Public contract registry
Commits
10a855b8
Commit
10a855b8
authored
Feb 17, 2023
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
improve __str__ methods, terminology, remove expected costs
parent
85e4e59b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
contracts/admin.py
+0
-4
0 additions, 4 deletions
contracts/admin.py
contracts/migrations/0002_remove_contract_expected_cost_hour_and_more.py
+28
-0
28 additions, 0 deletions
...tions/0002_remove_contract_expected_cost_hour_and_more.py
contracts/models.py
+45
-51
45 additions, 51 deletions
contracts/models.py
with
73 additions
and
55 deletions
contracts/admin.py
+
0
−
4
View file @
10a855b8
...
...
@@ -66,10 +66,6 @@ class ContractAdmin(MarkdownxGuardedModelAdmin):
"
notes
"
,
"
summary
"
,
"
primary_contract
"
,
"
expected_cost_total
"
,
"
expected_cost_year
"
,
"
expected_cost_month
"
,
"
expected_cost_hour
"
,
"
agreement_url
"
,
"
filing_area
"
,
)
...
...
This diff is collapsed.
Click to expand it.
contracts/migrations/0002_remove_contract_expected_cost_hour_and_more.py
0 → 100644
+
28
−
0
View file @
10a855b8
# Generated by Django 4.1.4 on 2023-02-17 03:00
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"
contracts
"
,
"
0001_initial
"
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
"
contract
"
,
name
=
"
expected_cost_hour
"
,
),
migrations
.
RemoveField
(
model_name
=
"
contract
"
,
name
=
"
expected_cost_month
"
,
),
migrations
.
RemoveField
(
model_name
=
"
contract
"
,
name
=
"
expected_cost_total
"
,
),
migrations
.
RemoveField
(
model_name
=
"
contract
"
,
name
=
"
expected_cost_year
"
,
),
]
This diff is collapsed.
Click to expand it.
contracts/models.py
+
45
−
51
View file @
10a855b8
...
...
@@ -7,6 +7,31 @@ from shared.models import NameStrMixin
from
users.models
import
User
class
RepresentativeMixin
:
@property
def
name
(
self
):
raise
NotImplementedError
@property
def
function
(
self
):
raise
NotImplementedError
@property
def
role
(
self
):
raise
NotImplementedError
def
__str__
(
self
)
->
str
:
result
=
self
.
name
if
self
.
function
is
not
None
:
result
+=
f
"
,
{
self
.
function
}
"
if
self
.
role
is
not
None
:
result
+=
f
"
(
{
self
.
role
}
)
"
return
result
class
Signee
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
256
,
...
...
@@ -85,7 +110,7 @@ class Signee(models.Model):
return
result
class
SigneeRepresentative
(
models
.
Model
):
class
SigneeRepresentative
(
RepresentativeMixin
,
models
.
Model
):
signee
=
models
.
ForeignKey
(
Signee
,
on_delete
=
models
.
CASCADE
,
...
...
@@ -116,17 +141,6 @@ class SigneeRepresentative(models.Model):
verbose_name
=
"
Zástupce
"
verbose_name_plural
=
"
Zástupci
"
def
__str__
(
self
)
->
str
:
result
=
self
.
name
if
self
.
function
is
not
None
:
result
+=
f
"
,
{
self
.
function
}
"
if
self
.
role
is
not
None
:
result
+=
f
"
(
{
self
.
role
}
)
"
return
result
class
Contractee
(
models
.
Model
):
name
=
models
.
CharField
(
...
...
@@ -194,7 +208,7 @@ class Contractee(models.Model):
return
result
class
ContracteeRepresentative
(
models
.
Model
):
class
ContracteeRepresentative
(
RepresentativeMixin
,
models
.
Model
):
contractee
=
models
.
ForeignKey
(
Contractee
,
on_delete
=
models
.
CASCADE
,
...
...
@@ -225,18 +239,6 @@ class ContracteeRepresentative(models.Model):
verbose_name
=
"
Zástupce
"
verbose_name_plural
=
"
Zástupci
"
# FIXME: Violates DRY, make a mixin
def
__str__
(
self
)
->
str
:
result
=
self
.
name
if
self
.
function
is
not
None
:
result
+=
f
"
,
{
self
.
function
}
"
if
self
.
role
is
not
None
:
result
+=
f
"
(
{
self
.
role
}
)
"
return
result
class
ContractSubtype
(
NameStrMixin
,
models
.
Model
):
name
=
models
.
CharField
(
...
...
@@ -416,30 +418,6 @@ class Contract(models.Model):
verbose_name
=
"
Hlavní smlouva
"
,
)
# WARNING: Dependent on the type!
expected_cost_total
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Očekáváná celková cena
"
,
)
expected_cost_year
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Očekáváná cena za rok
"
,
)
expected_cost_month
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Očekáváná cena za měsíc
"
,
)
expected_cost_hour
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"
Očekáváná cena za hodinu
"
,
)
agreement_url
=
models
.
URLField
(
max_length
=
256
,
blank
=
True
,
...
...
@@ -518,7 +496,15 @@ class ContracteeSignature(models.Model):
verbose_name_plural
=
"
Podpisy našich smluvních stran
"
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
contractee
.
name
}
,
{
self
.
date
}
"
representatives
=
"
,
"
.
join
(
self
.
contractee
.
representatives
)
result
=
self
.
contractee
.
name
if
len
(
representatives
)
!=
0
:
result
+=
f
"
zastoupena
{
representatives
}
"
result
+=
f
"
,
{
self
.
date
}
"
return
result
class
SigneeSignature
(
models
.
Model
):
...
...
@@ -545,7 +531,15 @@ class SigneeSignature(models.Model):
verbose_name_plural
=
"
Podpisy ostatních smluvních stran
"
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
signee
.
name
}
,
{
self
.
date
}
"
representatives
=
"
,
"
.
join
(
self
.
signee
.
representatives
)
result
=
self
.
signee
.
name
if
len
(
representatives
)
!=
0
:
result
+=
f
"
zastoupena
{
representatives
}
"
result
+=
f
"
,
{
self
.
date
}
"
return
result
class
ContractIntent
(
models
.
Model
):
...
...
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