[IMP] Remove inter module dependency (#274)
This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
This commit is contained in:
@@ -18,3 +18,13 @@ class AssetConfig(AppConfig):
|
||||
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "asset"
|
||||
|
||||
def ready(self):
|
||||
from django.urls import include, path
|
||||
|
||||
from horilla.urls import urlpatterns
|
||||
|
||||
urlpatterns.append(
|
||||
path("asset/", include("asset.urls")),
|
||||
)
|
||||
super().ready()
|
||||
|
||||
@@ -411,6 +411,9 @@ class AssetReturnForm(ModelForm):
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initializes the AssetReturnForm with initial values and custom field settings.
|
||||
"""
|
||||
super(AssetReturnForm, self).__init__(*args, **kwargs)
|
||||
self.fields["return_date"].initial = date.today()
|
||||
|
||||
|
||||
@@ -210,7 +210,9 @@ class AssetRequest(HorillaModel):
|
||||
null=False,
|
||||
blank=False,
|
||||
)
|
||||
asset_category_id = models.ForeignKey(AssetCategory, on_delete=models.PROTECT)
|
||||
asset_category_id = models.ForeignKey(
|
||||
AssetCategory, on_delete=models.PROTECT, verbose_name=_("Asset Category")
|
||||
)
|
||||
asset_request_date = models.DateField(auto_now_add=True)
|
||||
description = models.TextField(null=True, blank=True, max_length=255)
|
||||
asset_request_status = models.CharField(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
staticUrl = $("#statiUrl").attr("data-url");
|
||||
$(document).ready(function() {
|
||||
function available_asset_chart(dataSet) {
|
||||
var Asset_available_chart = document.getElementById("assetAvailableChart");
|
||||
@@ -83,7 +84,7 @@ function emptyAssetAvialabeChart(assetAvailableChartChart,args,options){
|
||||
var noDataImage = new Image();
|
||||
noDataImage.src = assetAvailableChartChart.data.emptyImageSrc
|
||||
? assetAvailableChartChart.data.emptyImageSrc
|
||||
: "/static/images/ui/joiningchart.png";
|
||||
: staticUrl +"images/ui/joiningchart.png";
|
||||
|
||||
message = assetAvailableChartChart.data.message
|
||||
? assetAvailableChartChart.data.message
|
||||
|
||||
@@ -117,4 +117,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,60 +1,89 @@
|
||||
{% load i18n %}
|
||||
{% load i18n %} {% load horillafilters %}
|
||||
<div class="oh-modal__dialog-header">
|
||||
<button type="button" class="oh-modal_close--custom" onclick="$('#objectCreateModal').removeClass('oh-modal--show');">
|
||||
<ion-icon name="close-outline" role="img" aria-label="close outline" class="md hydrated"></ion-icon>
|
||||
</button>
|
||||
<span class="oh-modal__dialog-title ml-5" id="addEmployeeObjectiveModalLabel">
|
||||
<h5>{% trans "Asset Return Form" %}</h5>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="oh-modal_close--custom"
|
||||
onclick="$('#objectCreateModal').removeClass('oh-modal--show');"
|
||||
>
|
||||
<ion-icon
|
||||
name="close-outline"
|
||||
role="img"
|
||||
aria-label="close outline"
|
||||
class="md hydrated"
|
||||
></ion-icon>
|
||||
</button>
|
||||
<span
|
||||
class="oh-modal__dialog-title ml-5"
|
||||
id="addEmployeeObjectiveModalLabel"
|
||||
>
|
||||
<h5>{% trans "Asset Return Form" %}</h5>
|
||||
</span>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form hx-post="{%url 'asset-allocate-return' asset_id=asset_id %}" hx-target="#objectCreateModalTarget" hx-encoding="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<div class="oh-profile-section pt-0">
|
||||
<div class="oh-input__group">
|
||||
<label class="oh-input__label" for="objective">{% trans "Return Status" %}</label>
|
||||
{{asset_return_form.return_status}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="objective">{% trans "Return Date" %}</label>
|
||||
{{asset_return_form.return_date}}
|
||||
{{asset_return_form.return_date.errors}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="objective">{% trans "Return Condition" %}</label>
|
||||
{{asset_return_form.return_condition}}
|
||||
</div>
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="objective">{% trans "Return Condition Images" %}</label>
|
||||
{{asset_return_form.return_images}}
|
||||
</div>
|
||||
<div class="oh-btn-group mt-4">
|
||||
<button
|
||||
class=" oh-btn oh-btn--info oh-btn--shadow w-100"
|
||||
type="button"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#dynamicCreateModal"
|
||||
hx-get="{% url "add-asset-report" asset_id %}"
|
||||
hx-target="#dynamicCreateModalTarget"
|
||||
>
|
||||
{% trans "Add Report" %}
|
||||
</button>
|
||||
{% if perms.payroll.add_loanaccount %}
|
||||
<button
|
||||
class="oh-btn oh-btn--primary oh-btn--shadow w-100 ml-2"
|
||||
type="button"
|
||||
hx-get="{% url "asset-fine" %}?employee_id={{asset_alocation.assigned_to_employee_id.id}}&asset_id={{asset_id}}"
|
||||
hx-target="#assetFineModalBody"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#assetFineModal"
|
||||
>
|
||||
{% trans "Add Fine" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow w-100 ml-2">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form
|
||||
hx-post="{%url 'asset-allocate-return' asset_id=asset_id %}"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
hx-encoding="multipart/form-data"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<div class="oh-profile-section pt-0">
|
||||
<div class="oh-input__group">
|
||||
<label class="oh-input__label" for="objective"
|
||||
>{% trans "Return Status" %}</label
|
||||
>
|
||||
{{asset_return_form.return_status}}
|
||||
</div>
|
||||
<div class="oh-input__group">
|
||||
<label class="oh-input__label" for="objective"
|
||||
>{% trans "Return Date" %}</label
|
||||
>
|
||||
{{asset_return_form.return_date}}
|
||||
{{asset_return_form.return_date.errors}}
|
||||
</div>
|
||||
<div class="oh-input__group">
|
||||
<label class="oh-input__label" for="objective"
|
||||
>{% trans "Return Condition" %}</label
|
||||
>
|
||||
{{asset_return_form.return_condition}}
|
||||
</div>
|
||||
<div class="oh-input__group">
|
||||
<label class="oh-input__label" for="objective"
|
||||
>{% trans "Return Condition Images" %}</label
|
||||
>
|
||||
{{asset_return_form.return_images}}
|
||||
</div>
|
||||
<div class="oh-btn-group mt-4">
|
||||
<button
|
||||
class="oh-btn oh-btn--info oh-btn--shadow w-100"
|
||||
type="button"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#dynamicCreateModal"
|
||||
hx-get="{% url "add-asset-report" asset_id %}"
|
||||
hx-target="#dynamicCreateModalTarget"
|
||||
>
|
||||
{% trans "Add Report" %}
|
||||
</button>
|
||||
{% if "payroll"|app_installed %}
|
||||
{% if perms.payroll.add_loanaccount %}
|
||||
<button
|
||||
class="oh-btn oh-btn--primary oh-btn--shadow w-100 ml-2"
|
||||
type="button"
|
||||
hx-get="{% url "asset-fine" %}?employee_id={{asset_alocation.assigned_to_employee_id.id}}&asset_id={{asset_id}}"
|
||||
hx-target="#assetFineModalBody"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#assetFineModal"
|
||||
>
|
||||
{% trans "Add Fine" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<button
|
||||
type="submit"
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow w-100 ml-2"
|
||||
>
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% load attendancefilters %} {% load basefilters %} {% load static %}
|
||||
{% load horillafilters %} {% load basefilters %} {% load static %}
|
||||
{% load i18n %} {% include 'filter_tags.html' %}
|
||||
<div class="oh-card">
|
||||
{% for asset_history_list in asset_assignments %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% load i18n %}
|
||||
{% include 'filter_tags.html' %}{% load attendancefilters %}
|
||||
{% include 'filter_tags.html' %}{% load horillafilters %}
|
||||
<div class="oh-tabs__contents">
|
||||
<div class="oh-tabs__content " id="tab_3">
|
||||
<!-- Sticky Table for own objective-->
|
||||
|
||||
@@ -178,4 +178,20 @@ urlpatterns = [
|
||||
views.asset_history_search,
|
||||
name="asset-history-search",
|
||||
),
|
||||
path("asset-tab/<int:emp_id>", views.asset_tab, name="asset-tab"),
|
||||
path(
|
||||
"profile-asset-tab/<int:emp_id>",
|
||||
views.profile_asset_tab,
|
||||
name="profile-asset-tab",
|
||||
),
|
||||
path(
|
||||
"asset-request-tab/<int:emp_id>",
|
||||
views.asset_request_tab,
|
||||
name="asset-request-tab",
|
||||
),
|
||||
path(
|
||||
"dashboard-asset-request-approve",
|
||||
views.dashboard_asset_request_approve,
|
||||
name="dashboard-asset-request-approve",
|
||||
),
|
||||
]
|
||||
|
||||
102
asset/views.py
102
asset/views.py
@@ -55,11 +55,13 @@ from base.methods import (
|
||||
)
|
||||
from base.models import Company
|
||||
from base.views import paginator_qry
|
||||
from employee.models import EmployeeWorkInformation
|
||||
from employee.models import Employee, EmployeeWorkInformation
|
||||
from horilla import settings
|
||||
from horilla.decorators import (
|
||||
hx_request_required,
|
||||
login_required,
|
||||
manager_can_enter,
|
||||
owner_can_enter,
|
||||
permission_required,
|
||||
)
|
||||
from horilla.group_by import group_by_queryset
|
||||
@@ -1422,7 +1424,7 @@ def asset_available_chart(request):
|
||||
"labels": labels,
|
||||
"dataset": dataset,
|
||||
"message": _("Oops!! No Asset found..."),
|
||||
"emptyImageSrc": "/static/images/ui/asset.png",
|
||||
"emptyImageSrc": f"/{settings.STATIC_URL}images/ui/asset.png",
|
||||
}
|
||||
return JsonResponse(response)
|
||||
|
||||
@@ -1452,7 +1454,7 @@ def asset_category_chart(request):
|
||||
"labels": labels,
|
||||
"dataset": dataset,
|
||||
"message": _("Oops!! No Asset found..."),
|
||||
"emptyImageSrc": "/static/images/ui/asset.png",
|
||||
"emptyImageSrc": f"/{settings.STATIC_URL}images/ui/asset.png",
|
||||
}
|
||||
return JsonResponse(response)
|
||||
|
||||
@@ -1568,3 +1570,97 @@ def asset_history_search(request):
|
||||
"requests_ids": requests_ids,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@owner_can_enter("asset.view_asset", Employee)
|
||||
def asset_tab(request, emp_id):
|
||||
"""
|
||||
This function is used to view asset tab of an employee in employee individual view.
|
||||
|
||||
Parameters:
|
||||
request (HttpRequest): The HTTP request object.
|
||||
emp_id (int): The id of the employee.
|
||||
|
||||
Returns: return asset-tab template
|
||||
|
||||
"""
|
||||
employee = Employee.objects.get(id=emp_id)
|
||||
assets_requests = employee.requested_employee.all()
|
||||
assets = employee.allocated_employee.all()
|
||||
assets_ids = (
|
||||
json.dumps([instance.id for instance in assets]) if assets else json.dumps([])
|
||||
)
|
||||
context = {
|
||||
"assets": assets,
|
||||
"requests": assets_requests,
|
||||
"assets_ids": assets_ids,
|
||||
"employee": emp_id,
|
||||
}
|
||||
return render(request, "tabs/asset-tab.html", context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@hx_request_required
|
||||
def profile_asset_tab(request, emp_id):
|
||||
"""
|
||||
This function is used to view asset tab of an employee in employee profile view.
|
||||
|
||||
Parameters:
|
||||
request (HttpRequest): The HTTP request object.
|
||||
emp_id (int): The id of the employee.
|
||||
|
||||
Returns: return profile-asset-tab template
|
||||
|
||||
"""
|
||||
employee = Employee.objects.get(id=emp_id)
|
||||
assets = employee.allocated_employee.all()
|
||||
assets_ids = json.dumps([instance.id for instance in assets])
|
||||
context = {
|
||||
"assets": assets,
|
||||
"assets_ids": assets_ids,
|
||||
}
|
||||
return render(request, "tabs/profile-asset-tab.html", context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
@hx_request_required
|
||||
def asset_request_tab(request, emp_id):
|
||||
"""
|
||||
This function is used to view asset request tab of an employee in employee individual view.
|
||||
|
||||
Parameters:
|
||||
request (HttpRequest): The HTTP request object.
|
||||
emp_id (int): The id of the employee.
|
||||
|
||||
Returns: return asset-request-tab template
|
||||
|
||||
"""
|
||||
employee = Employee.objects.get(id=emp_id)
|
||||
assets_requests = employee.requested_employee.all()
|
||||
context = {"asset_requests": assets_requests, "emp_id": emp_id}
|
||||
return render(request, "tabs/asset-request-tab.html", context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
def dashboard_asset_request_approve(request):
|
||||
|
||||
asset_requests = AssetRequest.objects.filter(
|
||||
asset_request_status="Requested", requested_employee_id__is_active=True
|
||||
)
|
||||
asset_requests = filtersubordinates(
|
||||
request,
|
||||
asset_requests,
|
||||
"asset.change_assetrequest",
|
||||
field="requested_employee_id",
|
||||
)
|
||||
requests_ids = json.dumps([instance.id for instance in asset_requests])
|
||||
|
||||
return render(
|
||||
request,
|
||||
"request_and_approve/asset_requests_approve.html",
|
||||
{
|
||||
"asset_requests": asset_requests,
|
||||
"requests_ids": requests_ids,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user