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

run hooks

parent 77a9189a
Branches
No related tags found
No related merge requests found
Showing
with 228 additions and 112 deletions
......@@ -4,40 +4,70 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0029_alter_contracteesignature_role_and_more'),
("contracts", "0029_alter_contracteesignature_role_and_more"),
]
operations = [
migrations.AlterField(
model_name='signee',
name='address_country',
field=models.CharField(blank=True, default='Česká Republika', max_length=256, null=True, verbose_name='Země'),
model_name="signee",
name="address_country",
field=models.CharField(
blank=True,
default="Česká Republika",
max_length=256,
null=True,
verbose_name="Země",
),
),
migrations.AlterField(
model_name='signee',
name='address_district',
field=models.CharField(blank=True, max_length=256, null=True, verbose_name='Obec'),
model_name="signee",
name="address_district",
field=models.CharField(
blank=True, max_length=256, null=True, verbose_name="Obec"
),
),
migrations.AlterField(
model_name='signee',
name='address_street_with_number',
field=models.CharField(blank=True, help_text='Veřejné pouze, když typ není nastaven na fyzickou osobu.', max_length=256, null=True, verbose_name='Ulice, č.p.'),
model_name="signee",
name="address_street_with_number",
field=models.CharField(
blank=True,
help_text="Veřejné pouze, když typ není nastaven na fyzickou osobu.",
max_length=256,
null=True,
verbose_name="Ulice, č.p.",
),
),
migrations.AlterField(
model_name='signee',
name='address_zip',
field=models.CharField(blank=True, help_text='Veřejné pouze, když typ není nastaven na fyzickou osobu.', max_length=16, null=True, verbose_name='PSČ'),
model_name="signee",
name="address_zip",
field=models.CharField(
blank=True,
help_text="Veřejné pouze, když typ není nastaven na fyzickou osobu.",
max_length=16,
null=True,
verbose_name="PSČ",
),
),
migrations.AlterField(
model_name='signee',
name='date_of_birth',
field=models.DateField(blank=True, help_text='U fyzických osob musí být vyplněno.', null=True, verbose_name='Datum narození'),
model_name="signee",
name="date_of_birth",
field=models.DateField(
blank=True,
help_text="U fyzických osob musí být vyplněno.",
null=True,
verbose_name="Datum narození",
),
),
migrations.AlterField(
model_name='signee',
name='ico_number',
field=models.CharField(blank=True, help_text='U právnických a podnikajících fyzických osob musí být vyplněno. Vyplněním můžeš automaticky načíst data z ARES.', max_length=16, null=True, verbose_name='IČO'),
model_name="signee",
name="ico_number",
field=models.CharField(
blank=True,
help_text="U právnických a podnikajících fyzických osob musí být vyplněno. Vyplněním můžeš automaticky načíst data z ARES.",
max_length=16,
null=True,
verbose_name="IČO",
),
),
]
......@@ -4,25 +4,42 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0030_alter_signee_address_country_and_more'),
("contracts", "0030_alter_signee_address_country_and_more"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='cost_unit_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_unit_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='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",
),
),
]
# Generated by Django 4.1.4 on 2023-04-03 21:35
import contracts.models
from django.db import migrations, models
import contracts.models
class Migration(migrations.Migration):
class Migration(migrations.Migration):
dependencies = [
('contracts', '0031_alter_contract_cost_unit_other_and_more'),
("contracts", "0031_alter_contract_cost_unit_other_and_more"),
]
operations = [
migrations.AlterField(
model_name='signee',
name='address_country',
field=models.CharField(blank=True, default=contracts.models.get_default_country, max_length=256, null=True, verbose_name='Země'),
model_name="signee",
name="address_country",
field=models.CharField(
blank=True,
default=contracts.models.get_default_country,
max_length=256,
null=True,
verbose_name="Země",
),
),
]
# Generated by Django 4.1.4 on 2023-04-10 21:45
import contracts.models
from django.db import migrations, models
import contracts.models
class Migration(migrations.Migration):
class Migration(migrations.Migration):
dependencies = [
('contracts', '0032_alter_signee_address_country'),
("contracts", "0032_alter_signee_address_country"),
]
operations = [
migrations.AlterField(
model_name='contractfile',
name='file',
field=models.FileField(upload_to=contracts.models.get_contract_file_loaction, verbose_name='Soubor'),
model_name="contractfile",
name="file",
field=models.FileField(
upload_to=contracts.models.get_contract_file_loaction,
verbose_name="Soubor",
),
),
]
# Generated by Django 4.1.4 on 2023-04-10 22:26
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contracts', '0033_alter_contractfile_file'),
("contracts", "0033_alter_contractfile_file"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='agreement_url',
field=models.URLField(blank=True, help_text='Běžně odkaz na fórum. Využívá se např. u koaličních smluv.', max_length=256, null=True, verbose_name='Odkaz na schválení'),
model_name="contract",
name="agreement_url",
field=models.URLField(
blank=True,
help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv.",
max_length=256,
null=True,
verbose_name="Odkaz na schválení",
),
),
migrations.AlterField(
model_name='contract',
name='cost_amount',
field=models.PositiveIntegerField(blank=True, help_text='Pokud se smlouvu nejsou spojené náklady, nevyplňuj vůbec.', null=True, verbose_name='Náklady (Kč)'),
model_name="contract",
name="cost_amount",
field=models.PositiveIntegerField(
blank=True,
help_text="Pokud se smlouvu nejsou spojené náklady, nevyplňuj vůbec.",
null=True,
verbose_name="Náklady (Kč)",
),
),
migrations.AlterField(
model_name='contract',
name='created_by',
field=models.ForeignKey(blank=True, help_text='Pokud vytváříš novou smlouvu, autorem budeš ty.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='uploaded_contracts', to=settings.AUTH_USER_MODEL, verbose_name='Vytvořena uživatelem'),
model_name="contract",
name="created_by",
field=models.ForeignKey(
blank=True,
help_text="Pokud vytváříš novou smlouvu, autorem budeš ty.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="uploaded_contracts",
to=settings.AUTH_USER_MODEL,
verbose_name="Vytvořena uživatelem",
),
),
migrations.AlterField(
model_name='contract',
name='tender_url',
field=models.URLField(blank=True, help_text='Běžně odkaz na fórum.', max_length=256, null=True, verbose_name='Odkaz na výběrové řízení'),
model_name="contract",
name="tender_url",
field=models.URLField(
blank=True,
help_text="Běžně odkaz na fórum.",
max_length=256,
null=True,
verbose_name="Odkaz na výběrové řízení",
),
),
]
......@@ -4,20 +4,29 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0034_alter_contract_agreement_url_and_more'),
("contracts", "0034_alter_contract_agreement_url_and_more"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='valid_end_date',
field=models.DateField(blank=True, help_text='<strong>Pokud není konec účinnosti zadán, smlouva je evidována jako na dobu neurčitou.</strong>', null=True, verbose_name='Konec účinnosti'),
model_name="contract",
name="valid_end_date",
field=models.DateField(
blank=True,
help_text="<strong>Pokud není konec účinnosti zadán, smlouva je evidována jako na dobu neurčitou.</strong>",
null=True,
verbose_name="Konec účinnosti",
),
),
migrations.AlterField(
model_name='contract',
name='valid_start_date',
field=models.DateField(blank=True, help_text='<strong>Pokud není začátek účinnosti zadán, vypočítá se automaticky podle posledního data podpisu.</strong>', null=True, verbose_name='Začátek účinnosti'),
model_name="contract",
name="valid_start_date",
field=models.DateField(
blank=True,
help_text="<strong>Pokud není začátek účinnosti zadán, vypočítá se automaticky podle posledního data podpisu.</strong>",
null=True,
verbose_name="Začátek účinnosti",
),
),
]
......@@ -4,15 +4,20 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contracts', '0035_alter_contract_valid_end_date_and_more'),
("contracts", "0035_alter_contract_valid_end_date_and_more"),
]
operations = [
migrations.AlterField(
model_name='contract',
name='tender_url',
field=models.URLField(blank=True, help_text='Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>.', max_length=256, null=True, verbose_name='Odkaz na výběrové řízení'),
model_name="contract",
name="tender_url",
field=models.URLField(
blank=True,
help_text='Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>.',
max_length=256,
null=True,
verbose_name="Odkaz na výběrové řízení",
),
),
]
import datetime
import os
import mimetypes
import os
import typing
from django.conf import settings
......@@ -102,7 +102,13 @@ def get_default_country():
return settings.DEFAULT_COUNTRY
class Signee(CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNameMixin, models.Model):
class Signee(
CreatedByMixin,
OwnPermissionsMixin,
SignatureCountMixin,
InlineNameMixin,
models.Model,
):
name = models.CharField(
max_length=256,
verbose_name="Jméno",
......@@ -168,7 +174,7 @@ class Signee(CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNam
blank=True,
null=True,
verbose_name="Datum narození",
help_text="U fyzických osob musí být vyplněno."
help_text="U fyzických osob musí být vyplněno.",
) # WARNING: Legal entity status dependent!
department = models.CharField(
......@@ -207,22 +213,22 @@ class Signee(CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNam
self.entity_type == self.EntityTypes.NATURAL_PERSON
and not self.date_of_birth
):
raise ValidationError({
"date_of_birth": "U fyzických osob musí být definováno."
})
raise ValidationError(
{"date_of_birth": "U fyzických osob musí být definováno."}
)
if (
self.entity_type in (
self.EntityTypes.LEGAL_ENTITY,
self.EntityTypes.BUSINESS_NATURAL_PERSON
)
self.entity_type
in (self.EntityTypes.LEGAL_ENTITY, self.EntityTypes.BUSINESS_NATURAL_PERSON)
and not self.ico_number
):
raise ValidationError({
raise ValidationError(
{
"ico_number": "U právnických a podnikajících fyzických osob musí být definováno."
})
}
)
if (self.entity_type != self.EntityTypes.OTHER):
if self.entity_type != self.EntityTypes.OTHER:
for field in (
"address_street_with_number",
"address_district",
......@@ -230,9 +236,9 @@ class Signee(CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNam
"address_country",
):
if not getattr(self, field):
raise ValidationError({
field: "Pokud není vybrán typ \"Jiné\", musí být definováno."
})
raise ValidationError(
{field: 'Pokud není vybrán typ "Jiné", musí být definováno.'}
)
return super().clean()
......@@ -260,7 +266,11 @@ class Signee(CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNam
class Contractee(
CreatedByMixin, OwnPermissionsMixin, SignatureCountMixin, InlineNameMixin, models.Model
CreatedByMixin,
OwnPermissionsMixin,
SignatureCountMixin,
InlineNameMixin,
models.Model,
):
name = models.CharField(
max_length=256,
......@@ -481,7 +491,7 @@ class Contract(NameStrMixin, models.Model):
help_text=mark_safe(
"<strong>Pokud není začátek účinnosti zadán, vypočítá se automaticky "
"podle posledního data podpisu.</strong>"
)
),
)
valid_end_date = models.DateField(
blank=True,
......@@ -490,7 +500,7 @@ class Contract(NameStrMixin, models.Model):
help_text=mark_safe(
"<strong>Pokud není konec účinnosti zadán, smlouva je evidována jako "
"na dobu neurčitou.</strong>"
)
),
)
class LegalStates(models.TextChoices):
......@@ -541,8 +551,8 @@ class Contract(NameStrMixin, models.Model):
null=True,
verbose_name="Odkaz na výběrové řízení",
help_text=mark_safe(
"Běžně odkaz na <a href=\"https://forum.pirati.cz/viewforum.php?f=572\">fórum</a>."
)
'Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>.'
),
)
agreement_url = models.URLField(
......@@ -550,7 +560,7 @@ class Contract(NameStrMixin, models.Model):
blank=True,
null=True,
verbose_name="Odkaz na schválení",
help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv."
help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv.",
) # WARNING: Dependent on the type!
issues = models.ManyToManyField(
......@@ -572,7 +582,7 @@ class Contract(NameStrMixin, models.Model):
blank=True,
null=True,
verbose_name="Náklady (Kč)",
help_text="Pokud se smlouvu nejsou spojené náklady, nevyplňuj vůbec."
help_text="Pokud se smlouvu nejsou spojené náklady, nevyplňuj vůbec.",
)
cost_unit = models.CharField(
......@@ -586,7 +596,7 @@ class Contract(NameStrMixin, models.Model):
cost_unit_other = models.CharField(
max_length=128,
verbose_name="Jednotka nákladů (jiné)",
help_text="Je nutno vyplnit v případě, že máš vybranou možnost \"jiné\" v jednotce nákladů.",
help_text='Je nutno vyplnit v případě, že máš vybranou možnost "jiné" v jednotce nákladů.',
blank=True,
null=True,
)
......@@ -716,13 +726,13 @@ class Contract(NameStrMixin, models.Model):
if self.cost_unit == self.CostUnits.OTHER and not self.cost_unit_other:
raise ValidationError(
{
"cost_unit_other": "Musí být definováno, pokud je vybrána jednotka nákladů \"jiné\"."
"cost_unit_other": 'Musí být definováno, pokud je vybrána jednotka nákladů "jiné".'
}
)
elif self.cost_unit != self.CostUnits.OTHER and self.cost_unit_other:
raise ValidationError(
{
"cost_unit_other": "Nemůže být definováno, pokud není vybrána jednotka nákladů \"jiné\"."
"cost_unit_other": 'Nemůže být definováno, pokud není vybrána jednotka nákladů "jiné".'
}
)
......@@ -843,7 +853,7 @@ class ContracteeSignature(models.Model):
blank=True,
null=True,
verbose_name="Role",
help_text="Např. \"nájemník\"",
help_text='Např. "nájemník"',
)
def __str__(self) -> str:
......@@ -880,7 +890,7 @@ class SigneeSignature(models.Model):
blank=True,
null=True,
verbose_name="Role",
help_text="Např. \"pronajímatel\"",
help_text='Např. "pronajímatel"',
)
def __str__(self) -> str:
......
......@@ -155,6 +155,20 @@
{% endwith %}
</td>
</tr>
{% if not contract.is_public and contract.publishing_rejection_comment %}
<td class="w-1/5 !p-2.5 !bg-red-100">
<div class="flex items-center">
{% include "contracts/includes/private_info_icon.html" %}
<span class="text-red-600">Důvod nezveřejnění</span>
</div>
</td>
<td class="w-4/5 !p-1.5 !bg-red-100">
<div class="prose max-w-none text-red-600">
{{ contract.publishing_rejection_comment|markdownify|safe }}
</div>
</td>
</tr>
{% endif %}
{% endif %}
</tbody>
</table>
......
......@@ -376,7 +376,6 @@ def get_ares_info(request, ico: int):
if result_count.text == "0":
raise HTTPExceptions.NOT_FOUND
return HttpResponse(
content=ares_info.content,
status=ares_info.status_code,
......
......@@ -77,7 +77,7 @@ MIDDLEWARE = [
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_http_exceptions.middleware.ExceptionHandlerMiddleware",
"django_http_exceptions.middleware.ThreadLocalRequestMiddleware",
"shared.middlewares.ClamAVMiddleware"
"shared.middlewares.ClamAVMiddleware",
]
ROOT_URLCONF = "registry.urls"
......
import clamd
from io import BytesIO
from django.http import HttpResponseForbidden
import clamd
from django.conf import settings
from django.http import HttpResponseForbidden
class ClamAVMiddleware:
def __init__(self, get_response):
......@@ -14,9 +15,7 @@ class ClamAVMiddleware:
# the view (and later middleware) are called.
cd = clamd.ClamdNetworkSocket(
host=settings.CLAMD_TCP_ADDR,
port=settings.CLAMD_TCP_SOCKET,
timeout=120
host=settings.CLAMD_TCP_ADDR, port=settings.CLAMD_TCP_SOCKET, timeout=120
)
if request.method == "POST" and len(request.FILES) > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment