diff --git a/base/templates/base/audit_tag/employee_account_block_unblock.html b/base/templates/base/audit_tag/employee_account_block_unblock.html new file mode 100644 index 000000000..58e15593c --- /dev/null +++ b/base/templates/base/audit_tag/employee_account_block_unblock.html @@ -0,0 +1,18 @@ +{% load i18n %} +{% csrf_token %} +
+

{% trans 'Employee Account Block/Unblock' %}

+
+
+ {% csrf_token %} +
+ + + +
+
+ +
+ +
+ \ No newline at end of file diff --git a/base/templates/base/general_settings.html b/base/templates/base/general_settings.html index 6f9b25606..1f03a2aac 100644 --- a/base/templates/base/general_settings.html +++ b/base/templates/base/general_settings.html @@ -22,4 +22,5 @@ {% include "settings/encashment_settings.html" %} {% endif %} {% include "base/audit_tag/history_tracking_fields.html" %} +{% include "base/audit_tag/employee_account_block_unblock.html" %} {% endblock settings %} \ No newline at end of file diff --git a/base/urls.py b/base/urls.py index 091d2d6b1..b4a0f7212 100644 --- a/base/urls.py +++ b/base/urls.py @@ -571,6 +571,7 @@ urlpatterns = [ path("settings/save-time/", views.save_time_format, name="save_time_format"), path("settings/get-time-format/", views.get_time_format, name="get-time-format"), path("history-field-settings",views.history_field_settings,name="history-field-settings"), + path("enable-account-block-unblock",views.enable_account_block_unblock,name="enable-account-block-unblock"), path( "settings/attendance-settings-view/", views.validation_condition_view, diff --git a/base/views.py b/base/views.py index 6dd9636be..ec8ea8ce0 100644 --- a/base/views.py +++ b/base/views.py @@ -28,7 +28,7 @@ from django.views.decorators.csrf import csrf_exempt from employee.filters import EmployeeFilter from employee.forms import ActiontypeForm from horilla_audit.forms import HistoryTrackingFieldsForm -from horilla_audit.models import AuditTag, HistoryTrackingFields +from horilla_audit.models import AccountBlockUnblock, AuditTag, HistoryTrackingFields from notifications.models import Notification from notifications.base.models import AbstractNotification from notifications.signals import notify @@ -409,9 +409,9 @@ def home(request): "completed_field_count": "0", }, ) - announcements = Announcement.objects.all().order_by('-created_on') + announcements = Announcement.objects.all().order_by("-created_on") announcement_list = announcements.filter(employees=request.user.employee_get) - announcement_list =announcement_list | announcements.filter(employees__isnull=True) + announcement_list = announcement_list | announcements.filter(employees__isnull=True) if request.user.has_perm("base.view_announcement"): announcement_list = announcements general_expire = AnnouncementExpire.objects.all().first() @@ -3853,6 +3853,10 @@ def general_settings(request): instance = AnnouncementExpire.objects.first() form = AnnouncementExpireForm(instance=instance) encashment_instance = EncashmentGeneralSettings.objects.first() + enabled_block_unblock = ( + AccountBlockUnblock.objects.exists() + and AccountBlockUnblock.objects.first().is_enabled + ) encashment_form = EncashmentGeneralSettingsForm(instance=encashment_instance) history_tracking_instance = HistoryTrackingFields.objects.first() history_fields_form_initial = {} @@ -3876,6 +3880,7 @@ def general_settings(request): "form": form, "encashment_form": encashment_form, "history_fields_form": history_fields_form, + "enabled_block_unblock": enabled_block_unblock, }, ) @@ -4028,6 +4033,22 @@ def history_field_settings(request): return redirect(general_settings) +def enable_account_block_unblock(request): + if request.method == "POST": + enabled = request.POST.get("enable_block_account") + if enabled == "on": + enabled = True + else: + enabled = False + if AccountBlockUnblock.objects.exists(): + instance = AccountBlockUnblock.objects.first() + instance.is_enabled = enabled + instance.save() + else: + AccountBlockUnblock.objects.create(is_enabled=enabled) + return redirect(general_settings) + + @login_required @permission_required("attendance.view_attendancevalidationcondition") def validation_condition_view(request): diff --git a/employee/templates/employee/view/individual.html b/employee/templates/employee/view/individual.html index 62b00547a..939630e7c 100644 --- a/employee/templates/employee/view/individual.html +++ b/employee/templates/employee/view/individual.html @@ -112,25 +112,27 @@ /> {% endif %} - {% if perms.change_employee %} - {% if employee.employee_user_id.is_active %} -
- {% csrf_token %} - -
- {% else %} -
- {% csrf_token %} - -
+ {% if enabled_block_unblock %} + {% if perms.change_employee %} + {% if employee.employee_user_id.is_active %} +
+ {% csrf_token %} + +
+ {% else %} +
+ {% csrf_token %} + +
+ {% endif %} {% endif %} {% endif %} diff --git a/horilla_audit/models.py b/horilla_audit/models.py index 1d9940ae1..7936896c4 100644 --- a/horilla_audit/models.py +++ b/horilla_audit/models.py @@ -132,3 +132,7 @@ class HistoryTrackingFields(models.Model): # employee_id = models.ForeignKey("Employee", on_delete=models.PROTECT) # history_id = models.ForeignKey(HorillaAuditLog, on_delete=models.PROTECT) # message = models.TextField() + + +class AccountBlockUnblock(models.Model): + is_enabled = models.BooleanField(default=False, null=True, blank=True)