Skip to content
Snippets Groups Projects
Commit 26c23983 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

run hooks

parent 30500282
Branches
No related tags found
No related merge requests found
Pipeline #12141 passed
Showing
with 133 additions and 102 deletions
......@@ -304,14 +304,12 @@ class ContractAdmin(
if not request.user.has_perm("contracts.view_confidential"):
# Allow user to view their own objects, even if not public
queryset = queryset.filter(
models.Q(is_public=True)
| models.Q(created_by=request.user)
models.Q(is_public=True) | models.Q(created_by=request.user)
)
if not request.user.has_perm("contracts.approve"):
queryset = queryset.filter(
models.Q(is_approved=True)
| models.Q(created_by=request.user)
models.Q(is_approved=True) | models.Q(created_by=request.user)
)
return queryset
......
......@@ -4,25 +4,51 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0021_contract_updated_on_alter_contractee_address_country_and_more'),
(
"contracts",
"0021_contract_updated_on_alter_contractee_address_country_and_more",
),
]
operations = [
migrations.AddField(
model_name='contract',
name='cost_amount_other',
field=models.CharField(blank=True, help_text="Je nutno vyplnit v případě, že máš vybranou možnost 'jiné' v jednotce nákladů.", max_length=128, null=True, verbose_name='Jednotka nákladů (jiné)'),
model_name="contract",
name="cost_amount_other",
field=models.CharField(
blank=True,
help_text="Je nutno vyplnit v případě, že máš vybranou možnost 'jiné' v jednotce nákladů.",
max_length=128,
null=True,
verbose_name="Jednotka nákladů (jiné)",
),
),
migrations.AlterField(
model_name='contract',
name='cost_unit',
field=models.CharField(blank=True, choices=[('hour', 'Hodina'), ('month', 'Měsíc'), ('year', 'Rok'), ('total', 'Celkem'), ('other', 'Jiné')], max_length=5, null=True, verbose_name='Jednotka nákladů'),
model_name="contract",
name="cost_unit",
field=models.CharField(
blank=True,
choices=[
("hour", "Hodina"),
("month", "Měsíc"),
("year", "Rok"),
("total", "Celkem"),
("other", "Jiné"),
],
max_length=5,
null=True,
verbose_name="Jednotka nákladů",
),
),
migrations.AlterField(
model_name='contract',
name='publishing_rejection_comment',
field=models.TextField(blank=True, help_text='Obsah není veřejně přístupný.', max_length=65536, null=True, verbose_name='Důvod nezveřejnění'),
model_name="contract",
name="publishing_rejection_comment",
field=models.TextField(
blank=True,
help_text="Obsah není veřejně přístupný.",
max_length=65536,
null=True,
verbose_name="Důvod nezveřejnění",
),
),
]
......@@ -4,15 +4,17 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0022_contract_cost_amount_other_alter_contract_cost_unit_and_more'),
(
"contracts",
"0022_contract_cost_amount_other_alter_contract_cost_unit_and_more",
),
]
operations = [
migrations.AlterField(
model_name='contractfile',
name='is_public',
field=models.BooleanField(default=True, verbose_name='Veřejně dostupný'),
model_name="contractfile",
name="is_public",
field=models.BooleanField(default=True, verbose_name="Veřejně dostupný"),
),
]
......@@ -4,15 +4,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0023_alter_contractfile_is_public'),
("contracts", "0023_alter_contractfile_is_public"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='is_approved',
field=models.BooleanField(default=False, help_text='Mohou měnit jen schvalovatelé. Pokud je smlouva veřejná, schválením se vypustí ven.', verbose_name='Je schválená'),
model_name="contract",
name="is_approved",
field=models.BooleanField(
default=False,
help_text="Mohou měnit jen schvalovatelé. Pokud je smlouva veřejná, schválením se vypustí ven.",
verbose_name="Je schválená",
),
),
]
......@@ -4,15 +4,14 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('contracts', '0024_alter_contract_is_approved'),
("contracts", "0024_alter_contract_is_approved"),
]
operations = [
migrations.RenameField(
model_name='contract',
old_name='cost_amount_other',
new_name='cost_unit_other',
model_name="contract",
old_name="cost_amount_other",
new_name="cost_unit_other",
),
]
......@@ -4,20 +4,23 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0025_rename_cost_amount_other_contract_cost_unit_other'),
("contracts", "0025_rename_cost_amount_other_contract_cost_unit_other"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='is_public',
field=models.BooleanField(default=True, help_text='Neveřejné smlouvy nejsou vidět bez přihlášení jako min. tajný čtenář.', verbose_name='Je veřejná'),
model_name="contract",
name="is_public",
field=models.BooleanField(
default=True,
help_text="Neveřejné smlouvy nejsou vidět bez přihlášení jako min. tajný čtenář.",
verbose_name="Je veřejná",
),
),
migrations.AlterField(
model_name='contractfile',
name='is_public',
field=models.BooleanField(verbose_name='Veřejně dostupný'),
model_name="contractfile",
name="is_public",
field=models.BooleanField(verbose_name="Veřejně dostupný"),
),
]
......@@ -4,14 +4,16 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('contracts', '0026_alter_contract_is_public_and_more'),
("contracts", "0026_alter_contract_is_public_and_more"),
]
operations = [
migrations.AlterModelOptions(
name='contractintent',
options={'verbose_name': 'Záměr v Piroplácení', 'verbose_name_plural': 'Záměry v Piroplácení'},
name="contractintent",
options={
"verbose_name": "Záměr v Piroplácení",
"verbose_name_plural": "Záměry v Piroplácení",
},
),
]
......@@ -4,28 +4,39 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0027_alter_contractintent_options'),
("contracts", "0027_alter_contractintent_options"),
]
operations = [
migrations.RemoveField(
model_name='contractee',
name='role',
model_name="contractee",
name="role",
),
migrations.RemoveField(
model_name='signee',
name='role',
model_name="signee",
name="role",
),
migrations.AddField(
model_name='contracteesignature',
name='role',
field=models.CharField(blank=True, help_text='Např. nájemce', max_length=256, null=True, verbose_name='Role'),
model_name="contracteesignature",
name="role",
field=models.CharField(
blank=True,
help_text="Např. nájemce",
max_length=256,
null=True,
verbose_name="Role",
),
),
migrations.AddField(
model_name='signeesignature',
name='role',
field=models.CharField(blank=True, help_text='Např. nájemce', max_length=256, null=True, verbose_name='Role'),
model_name="signeesignature",
name="role",
field=models.CharField(
blank=True,
help_text="Např. nájemce",
max_length=256,
null=True,
verbose_name="Role",
),
),
]
......@@ -4,20 +4,31 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0028_remove_contractee_role_remove_signee_role_and_more'),
("contracts", "0028_remove_contractee_role_remove_signee_role_and_more"),
]
operations = [
migrations.AlterField(
model_name='contracteesignature',
name='role',
field=models.CharField(blank=True, help_text="Např. 'nájemník'", max_length=256, null=True, verbose_name='Role'),
model_name="contracteesignature",
name="role",
field=models.CharField(
blank=True,
help_text="Např. 'nájemník'",
max_length=256,
null=True,
verbose_name="Role",
),
),
migrations.AlterField(
model_name='signeesignature',
name='role',
field=models.CharField(blank=True, help_text="Např. 'pronajímatel'", max_length=256, null=True, verbose_name='Role'),
model_name="signeesignature",
name="role",
field=models.CharField(
blank=True,
help_text="Např. 'pronajímatel'",
max_length=256,
null=True,
verbose_name="Role",
),
),
]
......@@ -581,33 +581,22 @@ class Contract(NameStrMixin, models.Model):
self.save()
def clean(self):
if (
not self.is_public
and not self.publishing_rejection_comment
):
if not self.is_public and not self.publishing_rejection_comment:
raise ValidationError(
{
"publishing_rejection_comment": "Pokud smlouva není veřejná, toto pole musí být vyplněné."
}
)
elif (
self.is_public
and self.publishing_rejection_comment
):
elif self.is_public and self.publishing_rejection_comment:
raise ValidationError(
{
"publishing_rejection_comment": "Nemůže být definováno, pokud je smlouva veřejná."
}
)
if (
self.cost_amount is None # 0 is falsy, but a value
and self.cost_unit
):
if self.cost_amount is None and self.cost_unit: # 0 is falsy, but a value
raise ValidationError(
{
"cost_unit": "Nemůže být definováno, pokud nejsou zadány náklady."
}
{"cost_unit": "Nemůže být definováno, pokud nejsou zadány náklady."}
)
if (
......@@ -615,15 +604,10 @@ class Contract(NameStrMixin, models.Model):
and not self.cost_unit
):
raise ValidationError(
{
"cost_amount": "Nemůže být definováno bez jednoty nákladů."
}
{"cost_amount": "Nemůže být definováno bez jednoty nákladů."}
)
if (
self.cost_unit == self.CostUnits.OTHER[1]
and self.cost_unit_other is None
):
if self.cost_unit == self.CostUnits.OTHER[1] and self.cost_unit_other is None:
raise ValidationError(
{
"cost_unit_other": "Musí být definováno, pokud je vybrána jednotka nákladů 'jiné'."
......
......@@ -92,8 +92,8 @@ def view_contract(request, id: int):
if not request.user.has_perm("contracts.view_confidential"):
filter = filter & (
models.Q(is_public=True) |
(
models.Q(is_public=True)
| (
models.Q(created_by=request.user)
if not request.user.is_anonymous
else True
......@@ -101,11 +101,8 @@ def view_contract(request, id: int):
)
contract = get_object_or_404(
(
get_objects_for_user(request.user, "contracts.view_contract")
.filter(filter)
),
id=id
(get_objects_for_user(request.user, "contracts.view_contract").filter(filter)),
id=id,
)
return render(
......@@ -125,8 +122,7 @@ def view_contract(request, id: int):
def view_contract_filing_area(request, id: int):
filing_area = get_object_or_404(
get_objects_for_user(request.user, "contracts.view_contractfilingarea"),
id=id
get_objects_for_user(request.user, "contracts.view_contractfilingarea"), id=id
)
contracts_page, contracts_paginator = get_paginated_contracts(
......@@ -152,8 +148,7 @@ def view_contract_filing_area(request, id: int):
def view_contract_issue(request, id: int):
issue = get_object_or_404(
get_objects_for_user(request.user, "contracts.view_contractissue"),
id=id
get_objects_for_user(request.user, "contracts.view_contractissue"), id=id
)
contracts_page, contracts_paginator = get_paginated_contracts(
......@@ -176,8 +171,7 @@ def view_contract_issue(request, id: int):
def view_contract_type(request, id: int):
type_ = get_object_or_404(
get_objects_for_user(request.user, "contracts.view_contracttype"),
id=id
get_objects_for_user(request.user, "contracts.view_contracttype"), id=id
)
contracts_page, contracts_paginator = get_paginated_contracts(
......@@ -200,8 +194,7 @@ def view_contract_type(request, id: int):
def view_contractee(request, id: int):
contractee = get_object_or_404(
get_objects_for_user(request.user, "contracts.view_contractee"),
id=id
get_objects_for_user(request.user, "contracts.view_contractee"), id=id
)
contracts_page, contracts_paginator = get_paginated_contracts(
......@@ -224,8 +217,7 @@ def view_contractee(request, id: int):
def view_signee(request, id: int):
signee = get_object_or_404(
get_objects_for_user(request.user, "contracts.view_signee"),
id=id
get_objects_for_user(request.user, "contracts.view_signee"), id=id
)
contracts_page, contracts_paginator = get_paginated_contracts(
......
......@@ -57,7 +57,7 @@ $(window).ready(
"block" : "none"
)
);
if (!otherIsSelected) $(".field-cost_unit_other").val("");
}
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment