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

add icons to tags, conditional signee admin field display

parent 7b5f0ffe
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ from django.contrib import admin ...@@ -2,7 +2,7 @@ from django.contrib import admin
from shared.admin import MarkdownxGuardedModelAdmin from shared.admin import MarkdownxGuardedModelAdmin
from .forms import ContractAdminForm, SigneeAdminForm from .forms import ContractAdminForm, ContractFileAdminForm, SigneeAdminForm
from .models import ( from .models import (
Contract, Contract,
Contractee, Contractee,
...@@ -27,6 +27,10 @@ class IndexHiddenModelAdmin(MarkdownxGuardedModelAdmin): ...@@ -27,6 +27,10 @@ class IndexHiddenModelAdmin(MarkdownxGuardedModelAdmin):
# BEGIN Contracts # BEGIN Contracts
class ContractFileAdmin(IndexHiddenModelAdmin):
form = ContractFileAdminForm
class ContracteeSignatureInline(admin.TabularInline): class ContracteeSignatureInline(admin.TabularInline):
model = ContracteeSignature model = ContracteeSignature
extra = 0 extra = 0
...@@ -39,6 +43,7 @@ class SigneeSignatureInline(admin.TabularInline): ...@@ -39,6 +43,7 @@ class SigneeSignatureInline(admin.TabularInline):
class ContractFileInline(admin.TabularInline): class ContractFileInline(admin.TabularInline):
model = ContractFile model = ContractFile
form = ContractFileAdminForm
extra = 0 extra = 0
...@@ -155,6 +160,7 @@ class SigneeAdmin(MarkdownxGuardedModelAdmin): ...@@ -155,6 +160,7 @@ class SigneeAdmin(MarkdownxGuardedModelAdmin):
class ContracteeRepresentativeInline(admin.TabularInline): class ContracteeRepresentativeInline(admin.TabularInline):
form = ContractFileAdminForm
model = ContracteeRepresentative model = ContracteeRepresentative
extra = 0 extra = 0
...@@ -176,6 +182,8 @@ for model in ( ...@@ -176,6 +182,8 @@ for model in (
): ):
admin.site.register(model, IndexHiddenModelAdmin) admin.site.register(model, IndexHiddenModelAdmin)
admin.site.register(ContractFile, ContractFileAdmin)
for model in ( for model in (
ContractIssue, ContractIssue,
ContractFilingArea, ContractFilingArea,
......
...@@ -23,6 +23,20 @@ class ContractAdminForm(forms.ModelForm): ...@@ -23,6 +23,20 @@ class ContractAdminForm(forms.ModelForm):
} }
class ContractFileAdminForm(forms.ModelForm):
class Media:
js = (
"shared/admin_contract_file_form.js",
);
class Meta:
widgets = {
"name": forms.TextInput(attrs={
"list": "file-types"
}),
}
class SigneeAdminForm(forms.ModelForm): class SigneeAdminForm(forms.ModelForm):
class Media: class Media:
js = ( js = (
......
...@@ -33,9 +33,10 @@ class Signee(models.Model): ...@@ -33,9 +33,10 @@ class Signee(models.Model):
) )
class EntityTypes(models.TextChoices): class EntityTypes(models.TextChoices):
NATURAL_PERSON = "physical_person", "Fyzická osoba" NATURAL_PERSON = "natural_person", "Fyzická osoba"
LEGAL_ENTITY = "legal_entity", "Právnická osoba" LEGAL_ENTITY = "legal_entity", "Právnická osoba"
BUSINESS_NATURAL_PERSON = "business_natural_person", "Podnikající fyzická osoba" BUSINESS_NATURAL_PERSON = "business_natural_person", "Podnikající fyzická osoba"
OTHER = "other", "Jiné"
entity_type = models.CharField( entity_type = models.CharField(
max_length=23, max_length=23,
...@@ -484,6 +485,12 @@ class Contract(models.Model): ...@@ -484,6 +485,12 @@ class Contract(models.Model):
permissions = (("approve", "Schválit / zrušit schválení"),) permissions = (("approve", "Schválit / zrušit schválení"),)
def get_public_files(self):
return ContractFile.objects.filter(
contract=self,
is_public=True,
).all()
def __str__(self) -> str: def __str__(self) -> str:
return self.name return self.name
......
<a <a
class="p-1.5 rounded-sm text-ellipsis bg-gray-200 duration-100 hover:bg-gray-300 hover:no-underline" class="p-1.5 rounded-sm text-ellipsis whitespace-nowrap bg-gray-200 duration-100 hover:bg-gray-300 hover:no-underline"
href="{{ url }}" href="{{ url }}"
>{% if icon %}<i class="{{ icon }} mr-2"></i>{% endif %}{{ content }}</a> >{% if icon %}<i class="{{ icon }} mr-2"></i>{% endif %}{{ content }}</a>
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<td class="font-bold">Název</td> <td class="font-bold">Název</td>
<td>Typy</td> <td>Typy</td>
<td>Platná</td> <td>Platná</td>
<td>Účinná od</td> <td class="whitespace-nowrap">Účinná od</td>
<td>Účinná do</td> <td class="whitespace-nowrap">Účinná do</td>
<td>Podepsána s</td> <td class="whitespace-nowrap">Podepsána s</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
<td> <td>
<ul class="flex flex-wrap gap-1.5"> <ul class="flex flex-wrap gap-1.5">
{% for type in contract.types.all %} {% for type in contract.types.all %}
<li class="p-1.5 rounded-sm whitespace-nowrap bg-gray-200">{{ type.name }}</li> <li class="flex">
{% include "contracts/includes/tag.html" with url="#TODO" icon="ico--folder" content=type.name %}
</li>
{% endfor %} {% endfor %}
</ul> </ul>
</td> </td>
...@@ -39,12 +41,22 @@ ...@@ -39,12 +41,22 @@
<i class="{% if contract.legal_state == contract.LegalStates.VALID %}ico--checkmark{% else %}ico--cross{% endif %}"></i> <i class="{% if contract.legal_state == contract.LegalStates.VALID %}ico--checkmark{% else %}ico--cross{% endif %}"></i>
</td> </td>
<td class="whitespace-nowrap">{{ contract.valid_start_date }}</td> <td class="whitespace-nowrap">{{ contract.valid_start_date }}</td>
<td class="whitespace-nowrap">{{ contract.valid_end_date }}</td> <td class="whitespace-nowrap">
{% if contract.valid_end_date %}
{{ contract.valid_end_date }}
{% else %}
<span class="text-grey-200">Neurčité</span>
{% endif %}
</td>
<td> <td>
<ul class="flex flex-wrap gap-1.5"> <ul class="flex flex-wrap gap-1.5">
{% for signature in contract.signee_signatures.all %} {% for signature in contract.signee_signatures.all %}
<li class="flex"> <li class="flex">
{% include "contracts/includes/tag.html" with url="#TODO" content=signature.signee.name %} {% if signature.signee.entity_type == signature.signee.EntityTypes.LEGAL_ENTITY or signature.signee.entity_type == signature.signee.EntityTypes.OTHER %}
{% include "contracts/includes/tag.html" with url="#TODO" icon="ico--office" content=signature.signee.name %}
{% else %}
{% include "contracts/includes/tag.html" with url="#TODO" icon="ico--user" content=signature.signee.name %}
{% endif %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% load subtract %} {% load subtract %}
{% block content %} {% block content %}
<h1 class="head-alt-lg mb-10">{{ contract.name }}</h1> <h1 class="head-alt-lg mb-10"><i class="ico--file-blank mr-4"></i>{{ contract.name }}</h1>
<table class="table table-auto w-full table--striped table--bordered mb-7"> <table class="table table-auto w-full table--striped table--bordered mb-7">
<tbody> <tbody>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<ul class="flex flex-wrap gap-1.5"> <ul class="flex flex-wrap gap-1.5">
{% for type in contract.types.all %} {% for type in contract.types.all %}
<li class="flex"> <li class="flex">
{% include "contracts/includes/tag.html" with url="#TODO" content=type.name %} {% include "contracts/includes/tag.html" with url="#TODO" icon="ico--folder" content=type.name %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<tr> <tr>
<td class="w-1/5 !p-2.5">Soubory</td> <td class="w-1/5 !p-2.5">Soubory</td>
<td class="w-4/5 !p-2.5"> <td class="w-4/5 !p-2.5">
{% with contract.files.all as files %} {% with contract.get_public_files as files %}
{% if files|length != 0 %} {% if files|length != 0 %}
<ul class="flex gap-2"> <ul class="flex gap-2">
{% for file in files %} {% for file in files %}
...@@ -83,7 +83,13 @@ ...@@ -83,7 +83,13 @@
</tr> </tr>
<tr> <tr>
<td class="w-1/5 !p-2.5">Konec účinnosti</td> <td class="w-1/5 !p-2.5">Konec účinnosti</td>
<td class="w-4/5 !p-2.5">{{ contract.valid_end_date }}</td> <td class="w-4/5 !p-2.5">
{% if contract.valid_end_date %}
{{ contract.valid_end_date }}
{% else %}
<span class="text-grey-200">Neurčitý</span>
{% endif %}
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
...@@ -100,6 +106,21 @@ ...@@ -100,6 +106,21 @@
<td class="w-1/5 !p-2.5">Stav</td> <td class="w-1/5 !p-2.5">Stav</td>
<td class="w-4/5 !p-2.5">{{ contract.get_paper_form_state_display }}</td> <td class="w-4/5 !p-2.5">{{ contract.get_paper_form_state_display }}</td>
</tr> </tr>
<tr>
<td class="w-1/5 !p-2.5">Spisovna</td>
<td class="w-4/5 !p-2.5">
<div class="flex gap-3 items-center">
<div class="flex">
{% include "contracts/includes/tag.html" with url="#TODO" icon="ico--drawer" content=contract.filing_area.name %}
</div>
<span>|</span>
<span>
zodpovědná osoba
{{ contract.filing_area.person_responsible }}
</span>
</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -214,14 +235,15 @@ ...@@ -214,14 +235,15 @@
{% with contract.contractee_signatures.all as signatures %} {% with contract.contractee_signatures.all as signatures %}
{% if signatures|length != 0 %} {% if signatures|length != 0 %}
<ul class="mb-5 grid grid-cols-3 gap-2"> <ul class="mb-5 grid grid-cols-2 gap-2">
{% for signature in signatures %} {% for signature in signatures %}
<li class="p-3 border border-gray-300 rounded-md"> <li class="p-3 border border-gray-300 rounded-md">
<address class="mb-3"> <address class="mb-3">
<div class="mb-1"> <div class="mb-1">
<a <a
class="inline-block p-1.5 mb-1 rounded-sm whitespace-nowrap cursor-pointer not-italic hover:no-underline bg-gray-200 duration-100 hover:bg-gray-300" class="inline-block p-1.5 mb-1 rounded-sm cursor-pointer not-italic hover:no-underline bg-gray-200 duration-100 hover:bg-gray-300"
> >
<i class="ico--office mr-2"></i>
<strong>{{ signature.contractee.name }}</strong> <strong>{{ signature.contractee.name }}</strong>
{% if signature.contractee.department %} {% if signature.contractee.department %}
- {{ signature.contractee.department }} - {{ signature.contractee.department }}
...@@ -266,14 +288,15 @@ ...@@ -266,14 +288,15 @@
{% with contract.signee_signatures.all as signatures %} {% with contract.signee_signatures.all as signatures %}
{% if signatures|length != 0 %} {% if signatures|length != 0 %}
<ul class="mb-5 grid grid-cols-3 gap-2"> <ul class="mb-5 grid grid-cols-2 gap-2">
{% for signature in signatures %} {% for signature in signatures %}
<li class="p-3 border border-gray-300 rounded-md"> <li class="p-3 border border-gray-300 rounded-md">
<address class="mb-3"> <address class="mb-3">
<div class="mb-1"> <div class="mb-1">
<a <a
class="inline-block p-1.5 mb-1 rounded-sm whitespace-nowrap cursor-pointer not-italic hover:no-underline bg-gray-200 duration-100 hover:bg-gray-300" class="inline-block p-1.5 mb-1 rounded-sm cursor-pointer not-italic hover:no-underline bg-gray-200 duration-100 hover:bg-gray-300"
> >
<i class="{% if signature.signee.entity_type == signature.signee.EntityTypes.LEGAL_ENTITY or signature.signee.entity_type == signature.signee.EntityTypes.OTHER %}ico--office{% else %}ico--user{% endif %} mr-2"></i>
<strong>{{ signature.signee.name }}</strong> <strong>{{ signature.signee.name }}</strong>
{% if signature.signee.department %} {% if signature.signee.department %}
- {{ signature.signee.department }} - {{ signature.signee.department }}
......
import $ from "jquery";
$(window).ready(
() => {
$("body").append(
`<datalist id="file-types">
<option value="Původní verze">
<option value="Anonymizovaná verze">
</datalist>`
);
}
);
import $ from "jquery"; import $ from "jquery";
const fieldDepartmentValues = new Set([
"legal_entity",
"other",
]);
$(window).ready( $(window).ready(
() => { () => {
let isPhysicalPerson = ($("#id_entity_type").find(":selected").val() === "natural_person");
let isEmpty = ($("#id_entity_type").find(":selected").val() === "");
$(".field-date_of_birth"). $(".field-date_of_birth").
css( css(
"display", "display",
( (
($("#id_is_legal_entity").is(":checked")) ? (!isEmpty && isPhysicalPerson) ?
"none": "block" "block" : "none"
)
);
$(".field-ico_number").
css(
"display",
(
(!isEmpty && !isPhysicalPerson) ?
"block" : "none"
)
);
$(".field-department").
css(
"display",
(
(!isEmpty && fieldDepartmentValues.has($("#id_entity_type").find(":selected").val())) ?
"block" : "none"
) )
); );
$("#id_is_legal_entity").on( $("#id_entity_type").on(
"change", "change",
event => { event => {
isEmpty = ($(event.target).val() === "");
isPhysicalPerson = ($(event.target).val() === "natural_person");
$(".field-date_of_birth"). $(".field-date_of_birth").
css( css(
"display", "display",
( (
(event.target.checked) ? (!isEmpty && isPhysicalPerson) ?
"none" : "block" "block" : "none"
)
);
$(".field-ico_number").
css(
"display",
(
(!isEmpty && !isPhysicalPerson) ?
"block" : "none"
)
);
$(".field-department").
css(
"display",
(
(!isEmpty && fieldDepartmentValues.has($(event.target).val())) ?
"block" : "none"
) )
); );
} }
......
...@@ -13,6 +13,10 @@ module.exports = { ...@@ -13,6 +13,10 @@ module.exports = {
import: path.resolve("static_src", "admin", "contract_form.js"), import: path.resolve("static_src", "admin", "contract_form.js"),
dependOn: "shared", dependOn: "shared",
}, },
admin_contract_file_form: {
import: path.resolve("static_src", "admin", "contract_file_form.js"),
dependOn: "shared",
},
admin_signee_form: { admin_signee_form: {
import: path.resolve("static_src", "admin", "signee_form.js"), import: path.resolve("static_src", "admin", "signee_form.js"),
dependOn: "shared", dependOn: "shared",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment