[UPDT] ASSET: Replace static paginator count to dynamic
This commit is contained in:
@@ -82,7 +82,7 @@ class AssetExportFilter(CustomFilterSet):
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetExportFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form.fields["asset_purchase_date"].widget.attrs.update({"type": "date"})
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class AssetFilter(CustomFilterSet):
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for visible in self.form.visible_fields():
|
||||
visible.field.widget.attrs["id"] = str(uuid.uuid4())
|
||||
|
||||
@@ -132,7 +132,7 @@ class CustomAssetFilter(CustomFilterSet):
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CustomAssetFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for visible in self.form.visible_fields():
|
||||
visible.field.widget.attrs["id"] = str(uuid.uuid4())
|
||||
|
||||
@@ -174,7 +174,7 @@ class AssetRequestFilter(CustomFilterSet):
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetRequestFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for visible in self.form.visible_fields():
|
||||
visible.field.widget.attrs["id"] = str(uuid.uuid4())
|
||||
|
||||
@@ -217,7 +217,7 @@ class AssetAllocationFilter(CustomFilterSet):
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetAllocationFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for visible in self.form.visible_fields():
|
||||
visible.field.widget.attrs["id"] = str(uuid.uuid4())
|
||||
|
||||
@@ -241,7 +241,7 @@ class AssetCategoryFilter(CustomFilterSet):
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetCategoryFilter, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for visible in self.form.visible_fields():
|
||||
visible.field.widget.attrs["id"] = str(uuid.uuid4())
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class AssetForm(ModelForm):
|
||||
instance = kwargs.get("instance")
|
||||
if instance:
|
||||
kwargs["initial"] = set_date_field_initial(instance)
|
||||
super(AssetForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
reload_queryset(self.fields)
|
||||
self.fields["asset_category_id"].widget.attrs.update({"id": str(uuid.uuid4())})
|
||||
self.fields["asset_lot_number_id"].widget.attrs.update(
|
||||
@@ -304,10 +304,7 @@ class AssetRequestForm(ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
user = kwargs.pop("user", None)
|
||||
super(AssetRequestForm, self).__init__(
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
reload_queryset(self.fields)
|
||||
if user is not None and user.has_perm("asset.add_assetrequest"):
|
||||
self.fields["requested_employee_id"].queryset = Employee.objects.all()
|
||||
@@ -329,7 +326,7 @@ class AssetAllocationForm(ModelForm):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AssetAllocationForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
reload_queryset(self.fields)
|
||||
self.fields["asset_id"].queryset = Asset.objects.filter(
|
||||
asset_status="Available"
|
||||
@@ -415,7 +412,7 @@ class AssetReturnForm(ModelForm):
|
||||
"""
|
||||
Initializes the AssetReturnForm with initial values and custom field settings.
|
||||
"""
|
||||
super(AssetReturnForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["return_date"].initial = date.today()
|
||||
|
||||
self.fields["return_images"] = MultipleFileField(label="Images")
|
||||
|
||||
@@ -1,146 +1,104 @@
|
||||
{% load i18n %} {% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
{% load i18n %}
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table oh-table--sortable">
|
||||
<div class="oh-sticky-table__thead">
|
||||
<div class="oh-sticky-table__tr">
|
||||
<div class="oh-sticky-table__th">{% trans "Batch Number" %}</div>
|
||||
<div class="oh-sticky-table__th">{% trans " Description" %}</div>
|
||||
{% if perms.asset.change_assetlot or perms.asset.delete_assetlot %}
|
||||
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for batch_number in batch_numbers %}
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-sticky-table__td">{{batch_number.lot_number}}</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{{batch_number.lot_description}}
|
||||
</div>
|
||||
{% if perms.asset.change_assetlot or perms.asset.delete_assetlot %}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-btn-group">
|
||||
{% if perms.asset.change_assetlot %}
|
||||
<a
|
||||
class="oh-btn oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Update' %}"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#objectUpdateModal"
|
||||
hx-put="{% url 'asset-batch-update' batch_id=batch_number.id %}"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
>
|
||||
<ion-icon
|
||||
name="create-outline"
|
||||
role="img"
|
||||
class="md hydrated"
|
||||
aria-label="create outline"
|
||||
></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.asset.delete_assetlot %}
|
||||
<form
|
||||
hx-confirm="{% trans 'Do you want to delete this batch number ?' %}"
|
||||
hx-post="{% url 'asset-batch-number-delete' batch_id=batch_number.id %}?{{pg}}"
|
||||
hx-target="#AssetBatchList"
|
||||
style="display: contents"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<button
|
||||
class="oh-btn oh-btn--danger-outline w-100"
|
||||
title="{% trans 'Delete' %}"
|
||||
>
|
||||
<ion-icon
|
||||
name="trash-outline"
|
||||
role="img"
|
||||
class="md hydrated"
|
||||
aria-label="trash outline"
|
||||
></ion-icon>
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table oh-table--sortable">
|
||||
<div class="oh-sticky-table__thead">
|
||||
<div class="oh-sticky-table__tr">
|
||||
<div class="oh-sticky-table__th">{% trans "Batch Number" %}</div>
|
||||
<div class="oh-sticky-table__th">{% trans " Description" %}</div>
|
||||
{% if perms.asset.change_assetlot or perms.asset.delete_assetlot %}
|
||||
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for batch_number in batch_numbers %}
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-sticky-table__td">{{batch_number.lot_number}}</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{{batch_number.lot_description}}
|
||||
</div>
|
||||
{% if perms.asset.change_assetlot or perms.asset.delete_assetlot %}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-btn-group">
|
||||
{% if perms.asset.change_assetlot %}
|
||||
<a class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Update' %}"
|
||||
data-toggle="oh-modal-toggle" data-target="#objectUpdateModal"
|
||||
hx-put="{% url 'asset-batch-update' batch_id=batch_number.id %}"
|
||||
hx-target="#objectUpdateModalTarget">
|
||||
<ion-icon name="create-outline" role="img" class="md hydrated"
|
||||
aria-label="create outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.asset.delete_assetlot %}
|
||||
<form hx-confirm="{% trans 'Do you want to delete this batch number ?' %}"
|
||||
hx-post="{% url 'asset-batch-number-delete' batch_id=batch_number.id %}?{{pg}}"
|
||||
hx-target="#AssetBatchList" style="display: contents">
|
||||
{% csrf_token %}
|
||||
<button class="oh-btn oh-btn--danger-outline w-100" title="{% trans 'Delete' %}">
|
||||
<ion-icon name="trash-outline" role="img" class="md hydrated"
|
||||
aria-label="trash outline"></ion-icon>
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- pagination start -->
|
||||
<div class="oh-pagination">
|
||||
<span
|
||||
class="oh-pagination__page"
|
||||
data-toggle="modal"
|
||||
data-target="#addEmployeeModal"
|
||||
></span>
|
||||
<nav class="oh-pagination__nav">
|
||||
<div class="oh-pagination__input-container me-3">
|
||||
<span class="oh-pagination__label me-1">{% trans "Page" %}</span>
|
||||
<input
|
||||
type="number"
|
||||
name="page"
|
||||
class="oh-pagination__input"
|
||||
value="{{batch_numbers.number }}"
|
||||
min="1"
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}"
|
||||
hx-target="#AssetBatchList"
|
||||
/>
|
||||
<span class="oh-pagination__label"
|
||||
>{% trans "of" %} {{ batch_numbers.paginator.num_pages }}</span
|
||||
>
|
||||
</div>
|
||||
<ul class="oh-pagination__items">
|
||||
{% if batch_numbers.has_previous %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page=1"
|
||||
class="oh-pagination__link"
|
||||
hx-target="#AssetBatchList"
|
||||
>{% trans "First" %}</a
|
||||
>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.previous_page_number }}"
|
||||
class="oh-pagination__link"
|
||||
hx-target="#AssetBatchList"
|
||||
>
|
||||
{% trans "Previous" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %} {% if batch_numbers.has_next %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.next_page_number }}"
|
||||
class="btn btn-outline-secondary"
|
||||
hx-target="#AssetBatchList"
|
||||
>
|
||||
{% trans "Next" %}
|
||||
</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.paginator.num_pages }}"
|
||||
hx-target="#AssetBatchList"
|
||||
class="oh-pagination__link"
|
||||
>
|
||||
{% trans "Last" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<!-- end of pagination -->
|
||||
<!-- pagination start -->
|
||||
<div class="oh-pagination">
|
||||
<span class="oh-pagination__page" data-toggle="modal" data-target="#addEmployeeModal"></span>
|
||||
<nav class="oh-pagination__nav">
|
||||
<div class="oh-pagination__input-container me-3">
|
||||
<span class="oh-pagination__label me-1">{% trans "Page" %}</span>
|
||||
<input type="number" name="page" class="oh-pagination__input" value="{{batch_numbers.number }}" min="1"
|
||||
hx-get="{% url 'asset-batch-number-search' %}?{{pg}}" hx-target="#AssetBatchList" />
|
||||
<span class="oh-pagination__label">{% trans "of" %} {{ batch_numbers.paginator.num_pages }}</span>
|
||||
</div>
|
||||
<ul class="oh-pagination__items">
|
||||
{% if batch_numbers.has_previous %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page=1" class="oh-pagination__link"
|
||||
hx-target="#AssetBatchList">{% trans "First" %}</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.previous_page_number }}"
|
||||
class="oh-pagination__link" hx-target="#AssetBatchList">
|
||||
{% trans "Previous" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if batch_numbers.has_next %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.next_page_number }}"
|
||||
class="btn btn-outline-secondary" hx-target="#AssetBatchList">
|
||||
{% trans "Next" %}
|
||||
</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-get="{% url 'asset-batch-number-search' %}?{{pg}}&page={{ batch_numbers.paginator.num_pages }}"
|
||||
hx-target="#AssetBatchList" class="oh-pagination__link">
|
||||
{% trans "Last" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<!-- end of pagination -->
|
||||
</div>
|
||||
|
||||
@@ -3,77 +3,54 @@
|
||||
|
||||
<!-- start of messages -->
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<!-- end of messages -->
|
||||
|
||||
<main :class="sidebarOpen ? 'oh-main__sidebar-visible' : ''">
|
||||
<section class="oh-wrapper oh-main__topbar" x-data="{searchShow: false}">
|
||||
<div class="oh-main__titlebar oh-main__titlebar--left">
|
||||
<h1 class="oh-main__titlebar-title fw-bold">
|
||||
{% trans "Asset Batch Number" %}
|
||||
</h1>
|
||||
<a
|
||||
class="oh-main__titlebar-search-toggle"
|
||||
role="button"
|
||||
aria-label="Toggle Search"
|
||||
@click="searchShow = !searchShow"
|
||||
>
|
||||
<ion-icon
|
||||
name="search-outline"
|
||||
class="oh-main__titlebar-serach-icon"
|
||||
></ion-icon>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oh-main__titlebar oh-main__titlebar--right">
|
||||
<div
|
||||
class="oh-input-group oh-input__search-group"
|
||||
:class="searchShow ? 'oh-input__search-group--show' : ''"
|
||||
>
|
||||
<ion-icon
|
||||
name="search-outline"
|
||||
class="oh-input-group__icon oh-input-group__icon--left"
|
||||
></ion-icon>
|
||||
<input
|
||||
name="search"
|
||||
hx-get="{% url 'asset-batch-number-search' %}"
|
||||
hx-target="#AssetBatchList"
|
||||
hx-trigger="keyup delay:500ms"
|
||||
type="text"
|
||||
class="oh-input oh-input__icon"
|
||||
aria-label="Search Input"
|
||||
placeholder="{% trans 'Search' %}"
|
||||
/>
|
||||
</div>
|
||||
<div class="oh-main__titlebar-button-container">
|
||||
{% if perms.asset.add_assetlot %}
|
||||
<div class="oh-btn-group ml-2">
|
||||
<div>
|
||||
<a
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get="{% url 'asset-batch-number-creation' %}"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
<ion-icon class="me-2" name="add-outline"></ion-icon>{% trans "Create" %}
|
||||
<section class="oh-wrapper oh-main__topbar" x-data="{searchShow: false}">
|
||||
<div class="oh-main__titlebar oh-main__titlebar--left">
|
||||
<h1 class="oh-main__titlebar-title fw-bold">
|
||||
{% trans "Asset Batch Number" %}
|
||||
</h1>
|
||||
<a class="oh-main__titlebar-search-toggle" role="button" aria-label="Toggle Search"
|
||||
@click="searchShow = !searchShow">
|
||||
<ion-icon name="search-outline" class="oh-main__titlebar-serach-icon"></ion-icon>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="oh-main__titlebar oh-main__titlebar--right">
|
||||
<div class="oh-input-group oh-input__search-group"
|
||||
:class="searchShow ? 'oh-input__search-group--show' : ''">
|
||||
<ion-icon name="search-outline" class="oh-input-group__icon oh-input-group__icon--left"></ion-icon>
|
||||
<input name="search" hx-get="{% url 'asset-batch-number-search' %}" hx-target="#AssetBatchList"
|
||||
hx-trigger="keyup delay:500ms" type="text" class="oh-input oh-input__icon" aria-label="Search Input"
|
||||
placeholder="{% trans 'Search' %}" />
|
||||
</div>
|
||||
<div class="oh-main__titlebar-button-container">
|
||||
{% if perms.asset.add_assetlot %}
|
||||
<div class="oh-btn-group ml-2">
|
||||
<div>
|
||||
<a class="oh-btn oh-btn--secondary oh-btn--shadow" data-toggle="oh-modal-toggle"
|
||||
data-target="#objectCreateModal" hx-get="{% url 'asset-batch-number-creation' %}"
|
||||
hx-target="#objectCreateModalTarget">
|
||||
<ion-icon class="me-2" name="add-outline"></ion-icon>{% trans "Create" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div id="AssetBatchList">
|
||||
{% include 'batch/asset_batch_number_list.html' %}
|
||||
</div>
|
||||
</section>
|
||||
<div id="AssetBatchList">
|
||||
{% include 'batch/asset_batch_number_list.html' %}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
class="oh-badge oh-badge--secondary oh-badge--small oh-badge--round ms-2 mr-2"
|
||||
id="asset-count{{asset_category.id}}"
|
||||
data-category-id="{{asset_category.id}}"
|
||||
title='{{asset_category.asset_set.count}} {% trans "Asset" %}'>
|
||||
title="{{asset_category.asset_set.count}} {% trans 'Assets' %}">
|
||||
{{asset_category.asset_set.count}}
|
||||
</span>
|
||||
<span class="oh-accordion-meta__title">{{asset_category}}</span>
|
||||
|
||||
@@ -3,60 +3,58 @@
|
||||
<!-- start of messages -->
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{message.tags}}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
$('.oh-modal__close').click()
|
||||
}, 1000);
|
||||
</script>
|
||||
{% endfor %}
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
$('.oh-modal__close').click()
|
||||
}, 1000);
|
||||
</script>
|
||||
</div>
|
||||
{% endif %}
|
||||
<!-- end of messages -->
|
||||
|
||||
<!-- asset cretion form -->
|
||||
<div class="oh-modal__dialog-header">
|
||||
<button type="button" class="oh-modal__close" data-dismiss="oh-modal" aria-label="Close"
|
||||
{% if messages %}
|
||||
hx-get="{%url 'asset-category-view-search-filter'%}?{{pg}}" hx-target="#assetCategoryList"
|
||||
{% endif %}
|
||||
>
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
<span class="oh-modal__dialog-title ml-5" id="addEmployeeObjectiveModalLabel">
|
||||
<h5>{% trans "Asset Category Update" %}</h5>
|
||||
</span>
|
||||
<button type="button" class="oh-modal__close" data-dismiss="oh-modal" aria-label="Close" {% if messages %}
|
||||
hx-get="{%url 'asset-category-view-search-filter'%}?{{pg}}" hx-target="#assetCategoryList" {% endif %}>
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
<span class="oh-modal__dialog-title ml-5" id="addEmployeeObjectiveModalLabel">
|
||||
<h5>{% trans "Asset Category Update" %}</h5>
|
||||
</span>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form hx-post="{%url 'asset-category-update' cat_id=asset_category_update_form.instance.id %}?{{pg}}"
|
||||
hx-target="#objectUpdateModalTarget">
|
||||
{% csrf_token %}
|
||||
<div class="oh-profile-section pt-0">
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.asset_category_name.id_for_label}}">{% trans "Name" %}</label>
|
||||
{{asset_category_update_form.asset_category_name.errors}}
|
||||
{{asset_category_update_form.asset_category_name}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.asset_category_description.id_for_label}}">{% trans "Description" %}</label>
|
||||
{{asset_category_update_form.asset_category_description.errors}}
|
||||
{{asset_category_update_form.asset_category_description}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.company_id.id_for_label}}">{% trans "Company" %}</label>
|
||||
{{asset_category_update_form.company_id.errors}}
|
||||
{{asset_category_update_form.company_id}}
|
||||
</div>
|
||||
<form hx-post="{%url 'asset-category-update' cat_id=asset_category_update_form.instance.id %}?{{pg}}"
|
||||
hx-target="#objectUpdateModalTarget">
|
||||
{% csrf_token %}
|
||||
<div class="oh-profile-section pt-0">
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.asset_category_name.id_for_label}}">{% trans "Name" %}</label>
|
||||
{{asset_category_update_form.asset_category_name.errors}}
|
||||
{{asset_category_update_form.asset_category_name}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.asset_category_description.id_for_label}}">{% trans "Description" %}</label>
|
||||
{{asset_category_update_form.asset_category_description.errors}}
|
||||
{{asset_category_update_form.asset_category_description}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="{{asset_category_update_form.company_id.id_for_label}}">{% trans "Company" %}</label>
|
||||
{{asset_category_update_form.company_id.errors}}
|
||||
{{asset_category_update_form.company_id}}
|
||||
</div>
|
||||
|
||||
<div class="oh-modal__dialog-footer p-0 mt-3">
|
||||
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow ">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="oh-modal__dialog-footer p-0 mt-3">
|
||||
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow ">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -270,7 +270,7 @@ def asset_delete(request, asset_id):
|
||||
previous_data = request.GET.urlencode()
|
||||
asset_filtered = AssetFilter(request.GET, queryset=assets)
|
||||
asset_list = asset_filtered.qs
|
||||
paginator = Paginator(asset_list, 20)
|
||||
paginator = Paginator(asset_list, get_pagination())
|
||||
page_number = request.GET.get("page")
|
||||
page_obj = paginator.get_page(page_number)
|
||||
context = {
|
||||
@@ -313,9 +313,11 @@ def asset_list(request, cat_id):
|
||||
Raises:
|
||||
None
|
||||
"""
|
||||
asset_list_filter = request.GET.get("asset_list")
|
||||
asset_info = request.GET.get("asset_info")
|
||||
context = {}
|
||||
asset_under = ""
|
||||
assets_in_category = Asset.objects.none()
|
||||
asset_info = request.GET.get("asset_info")
|
||||
asset_list_filter = request.GET.get("asset_list")
|
||||
if asset_list_filter:
|
||||
# if the data is present means that it is for asset filtered list
|
||||
query = request.GET.get("query")
|
||||
@@ -335,10 +337,11 @@ def asset_list(request, cat_id):
|
||||
previous_data = request.GET.urlencode()
|
||||
asset_filtered = AssetFilter(request.GET, queryset=assets_in_category)
|
||||
asset_list = asset_filtered.qs
|
||||
# Change 20 to the desired number of items per page
|
||||
paginator = Paginator(asset_list, 20)
|
||||
|
||||
paginator = Paginator(asset_list, get_pagination())
|
||||
page_number = request.GET.get("page")
|
||||
page_obj = paginator.get_page(page_number)
|
||||
|
||||
requests_ids = json.dumps([instance.id for instance in page_obj.object_list])
|
||||
data_dict = parse_qs(previous_data)
|
||||
get_key_instances(Asset, data_dict)
|
||||
@@ -1038,7 +1041,6 @@ def asset_import(request):
|
||||
Returns:
|
||||
HttpResponseRedirect: A redirect to the asset category view after processing the import.
|
||||
"""
|
||||
|
||||
try:
|
||||
if request.method == "POST":
|
||||
file = request.FILES.get("asset_import")
|
||||
@@ -1079,13 +1081,17 @@ def asset_import(request):
|
||||
)
|
||||
|
||||
messages.success(request, _("Successfully imported Assets"))
|
||||
return redirect(asset_category_view)
|
||||
messages.error(request, _("File Error"))
|
||||
else:
|
||||
messages.error(request, _("File Error"))
|
||||
|
||||
return redirect(asset_category_view)
|
||||
|
||||
except Exception as exception:
|
||||
messages.error(request, f"{exception}")
|
||||
return redirect(asset_category_view)
|
||||
|
||||
return redirect(asset_category_view)
|
||||
|
||||
|
||||
@login_required
|
||||
def asset_excel(_request):
|
||||
@@ -1260,7 +1266,7 @@ def asset_batch_view(request):
|
||||
|
||||
asset_batches = AssetLot.objects.all()
|
||||
previous_data = request.GET.urlencode()
|
||||
asset_batch_numbers_search_paginator = Paginator(asset_batches, 20)
|
||||
asset_batch_numbers_search_paginator = Paginator(asset_batches, get_pagination())
|
||||
page_number = request.GET.get("page")
|
||||
asset_batch_numbers = asset_batch_numbers_search_paginator.get_page(page_number)
|
||||
asset_batch_form = AssetBatchForm()
|
||||
@@ -1361,7 +1367,7 @@ def asset_batch_number_search(request):
|
||||
|
||||
asset_batches = AssetLot.objects.all().filter(lot_number__icontains=search_query)
|
||||
previous_data = request.GET.urlencode()
|
||||
asset_batch_numbers_search_paginator = Paginator(asset_batches, 20)
|
||||
asset_batch_numbers_search_paginator = Paginator(asset_batches, get_pagination())
|
||||
page_number = request.GET.get("page")
|
||||
asset_batch_numbers = asset_batch_numbers_search_paginator.get_page(page_number)
|
||||
|
||||
@@ -1418,7 +1424,7 @@ def asset_dashboard(request):
|
||||
|
||||
@login_required
|
||||
@permission_required(perm="asset.view_assetcategory")
|
||||
def asset_available_chart(request):
|
||||
def asset_available_chart(_request):
|
||||
"""
|
||||
This function returns the response for the available asset chart in the asset dashboard.
|
||||
"""
|
||||
@@ -1445,7 +1451,7 @@ def asset_available_chart(request):
|
||||
|
||||
@login_required
|
||||
@permission_required(perm="asset.view_assetcategory")
|
||||
def asset_category_chart(request):
|
||||
def asset_category_chart(_request):
|
||||
"""
|
||||
This function returns the response for the asset category chart in the asset dashboard.
|
||||
"""
|
||||
@@ -1658,6 +1664,17 @@ def asset_request_tab(request, emp_id):
|
||||
|
||||
@login_required
|
||||
def dashboard_asset_request_approve(request):
|
||||
"""
|
||||
Handles the asset request approval dashboard view.
|
||||
|
||||
This view fetches and filters asset requests that are currently in the
|
||||
"Requested" status and belong to employees who are active. It further filters
|
||||
the asset requests based on the subordinates of the logged-in user and the
|
||||
specific permission 'asset.change_assetrequest'.
|
||||
|
||||
The filtered asset requests are then passed to the template for rendering,
|
||||
along with a JSON-encoded list of the request IDs.
|
||||
"""
|
||||
|
||||
asset_requests = AssetRequest.objects.filter(
|
||||
asset_request_status="Requested", requested_employee_id__is_active=True
|
||||
|
||||
Reference in New Issue
Block a user