[UPDT] PMS: Key result status automatic updation

This commit is contained in:
Horilla
2023-10-07 16:09:52 +05:30
parent 3e59bf86b8
commit 861e33b2a5
3 changed files with 140 additions and 6 deletions

View File

@@ -213,6 +213,7 @@
{% if employee_key_result.status != value %}
<option value="{{value}}">{{label}}</option>
{% endif%}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{% endfor %}
</select>
</div>

View File

@@ -12,10 +12,112 @@
<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 "Objectives" %} </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-main__titlebar-button-container">
<div class="oh-dropdown" x-data="{open: false}">
<button class="oh-btn ml-2" @click="open = !open">
<ion-icon name="filter" class="mr-1"></ion-icon>{% trans "Filter" %}<div id="filterCount"></div>
</button>
<div class="oh-dropdown__menu oh-dropdown__menu--right oh-dropdown__filter p-4" x-show="open"
@click.outside="open = false" style="display: none;">
<form
hx-get="{% url 'objective-list-search' %}"
hx-target="#objective_list"
hx-swap="innerHTML"
method="get"
id="filterForm">
<div class="oh-dropdown__filter-body">
<div class="oh-accordion">
<div class="oh-accordion-header">{% trans "Objective" %}</div>
<div class="oh-accordion-body">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Objective" %}</label>
{{objective_filer_form.objective}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Status" %}</label>
{{objective_filer_form.status}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Employee" %}</label>
{{objective_filer_form.employee_id}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Created" %} </label>
{{objective_filer_form.created_at}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "Start Date" %}</label>
{{objective_filer_form.start_date}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Updated At" %}</label>
{{objective_filer_form.updated_at}}
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label">{% trans "End Date" %}</label>
{{objective_filer_form.end_date}}
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Archive" %}</label>
{{ objective_filer_form.archive }}
</div>
</div>
<div class="oh-input-group">
<label class="oh-label">{% trans "Key Result" %}</label>
{{ objective_filer_form.emp_obj_id }}
</div>
</div>
</div>
</div>
<div class="oh-accordion">
<div class="oh-accordion-header">{% trans "Advanced" %}</div>
<div class="oh-accordion-body">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group fil">
<a hx-get="{%url 'objective-list-search' %}?created_at_date_range=today" hx-target="#objective_list" class="oh-btn oh-btn--secondary oh-btn--small w-100">{% trans "Today" %}</a>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group fil">
<a hx-get="{%url 'objective-list-search' %}?created_at_date_range=yesterday" hx-target="#objective_list" class="oh-btn oh-btn--secondary oh-btn--small w-100">{% trans "Yesterday" %}</a>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group fil">
<a hx-get="{%url 'objective-list-search' %}?created_at_date_range=week" hx-target="#objective_list" class="oh-btn oh-btn--secondary oh-btn--small w-100">{% trans "This Week" %}</a>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group fil">
<a hx-get="{%url 'objective-list-search' %}?created_at_date_range=month" hx-target="#objective_list" class="oh-btn oh-btn--secondary oh-btn--small w-100">{% trans "This Month" %}</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="oh-dropdown__filter-footer">
<button class="oh-btn oh-btn--secondary oh-btn--small w-100 filterButton" id="objective-filter-form-submit">{% trans "Filter" %}</button>
</div>
</form>
</div>
</div>
<!-- checking user permission for objective creation -->
{% if perms.pms.view_questiontemplate or request.user|filtersubordinates %}
<div class="oh-btn-group ml-2">

View File

@@ -513,10 +513,23 @@ def objective_detailed_view_key_result_status(request, obj_id, kr_id):
status = request.POST.get("key_result_status")
employee_key_result = EmployeeKeyResult.objects.get(id=kr_id)
employee_key_result.status = status
current_value = employee_key_result.current_value
target_value = employee_key_result.target_value
if current_value >= target_value:
employee_key_result.status = 'Closed'
else:
employee_key_result.status = status
employee_key_result.save()
messages.info(request, _("Status has been updated"))
return redirect(objective_detailed_view_activity, id=obj_id)
# return redirect(objective_detailed_view_activity, id=obj_id)
response = (
redirect(objective_detailed_view_activity, id=obj_id)
)
return HttpResponse(
response.content.decode("utf-8") + "<script>location.reload();</script>"
)
@login_required
@@ -534,7 +547,7 @@ def objective_detailed_view_current_value(request, kr_id):
employee_key_result = EmployeeKeyResult.objects.get(id=kr_id)
target_value = employee_key_result.target_value
objective_id = employee_key_result.employee_objective_id.id
if int(current_value) <= target_value:
if int(current_value) < target_value:
employee_key_result.current_value = current_value
employee_key_result.save()
messages.info(
@@ -543,6 +556,24 @@ def objective_detailed_view_current_value(request, kr_id):
% {"employee_key_result": employee_key_result},
)
return redirect(objective_detailed_view_activity, objective_id)
elif int(current_value) == target_value:
employee_key_result.current_value = current_value
employee_key_result.status = 'Closed'
employee_key_result.save()
messages.info(
request,
_("Current value of %(employee_key_result)s updated")
% {"employee_key_result": employee_key_result},
)
# return redirect(objective_detailed_view_activity, objective_id)
response = (
redirect(objective_detailed_view_activity, objective_id)
)
return HttpResponse(
response.content.decode("utf-8") + "<script>location.reload();</script>"
)
elif int(current_value) > target_value:
messages.warning(request, _("Current value is greater than target value"))
return redirect(objective_detailed_view_activity, objective_id)
@@ -1006,7 +1037,7 @@ def feedback_list_view(request):
employees = Employee.objects.filter(
employee_work_info__reporting_manager_id=employee
) # checking the user is reporting manager or not
feedback_available = Feedback.objects.all()
if request.user.has_perm("pms.view_feedback"):
context = filter_pagination_feedback(
request, feedback_own, feedback_requested, feedback_all
@@ -1022,7 +1053,7 @@ def feedback_list_view(request):
context = filter_pagination_feedback(
request, feedback_own, feedback_requested, feedback_all
)
if feedback_own.exists() or feedback_requested.exists() or feedback_all.exists():
if feedback_available.exists():
template = "feedback/feedback_list_view.html"
else:
template = "feedback/feedback_empty.html"