From a63ffc204d868bb1a0667f47774fcfa6d1f756be Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 18 Sep 2024 15:49:21 +0530 Subject: [PATCH] [UPDT] BASE: Add additional fields to sign up page --- base/views.py | 40 ++- .../templates/employee/view/individual.html | 3 +- static/index/index.js | 14 +- .../horilla_user_signup.html | 276 +++++++++--------- 4 files changed, 187 insertions(+), 146 deletions(-) diff --git a/base/views.py b/base/views.py index d78d2b510..5e2310f17 100644 --- a/base/views.py +++ b/base/views.py @@ -19,6 +19,7 @@ from django.contrib.auth import authenticate, login, logout from django.contrib.auth.models import Group, Permission, User from django.contrib.auth.views import PasswordResetConfirmView, PasswordResetView from django.core.mail import EmailMultiAlternatives +from django.core.management import call_command from django.core.paginator import Paginator from django.db.models import ProtectedError, Q from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse @@ -210,6 +211,36 @@ def initialize_database_condition(): return initialize_database +def load_demo_database(request): + # Core data files + data_files = [ + "user_data.json", + "employee_info_data.json", + "base_data.json", + "work_info_data.json", + ] + optional_apps = { + "attendance": "attendance_data.json", + "leave": "leave_data.json", + "asset_data": "asset_data.json", + "recruitment": "recruitment_data.json", + "pms": "pms_data.json", + } + + # Add data files for installed apps + data_files += [ + file for app, file in optional_apps.items() if apps.is_installed(app) + ] + + # Load all data files + for file in data_files: + file_path = path.join(settings.BASE_DIR, "load_data", file) + call_command("loaddata", file_path) + + messages.success(request, _("Database loaded successfully.")) + return redirect(home) + + def initialize_database(request): """ Handles the database initialization process via a user interface. @@ -251,10 +282,14 @@ def initialize_database_user(request): """ if request.method == "POST": form_data = request.__dict__.get("_post") - first_name = form_data.get("firstname") - last_name = form_data.get("lastname") username = form_data.get("username") password = form_data.get("password") + confirm_password = form_data.get("confirm_password") + if password != confirm_password: + return render(request, "initialize_database/horilla_user_signup.html") + first_name = form_data.get("firstname") + last_name = form_data.get("lastname") + badge_id = form_data.get("badge_id") email = form_data.get("email") phone = form_data.get("phone") user = User.objects.filter(username=username).first() @@ -265,6 +300,7 @@ def initialize_database_user(request): ) employee = Employee() employee.employee_user_id = user + employee.badge_id = badge_id employee.employee_first_name = first_name employee.employee_last_name = last_name employee.email = email diff --git a/employee/templates/employee/view/individual.html b/employee/templates/employee/view/individual.html index 7c017d70b..2ef178638 100644 --- a/employee/templates/employee/view/individual.html +++ b/employee/templates/employee/view/individual.html @@ -190,6 +190,7 @@ {% if next != None %} @@ -201,7 +202,7 @@ {% if previous != None %} + data-action="previous" style="color:hsl(8, 77%, 56%);" class="ms-1 me-2 fw-bold"> {% else %} diff --git a/static/index/index.js b/static/index/index.js index bd62b7848..77190c76e 100644 --- a/static/index/index.js +++ b/static/index/index.js @@ -424,14 +424,22 @@ $(document).on('keydown', function (event) { } else if (event.keyCode === 39) { // Key code for the right arrow key if (!isInputFocused) { - // Click on the next button in detail view modal - $('[data-action="next"]').click(); + var $modal = $('.oh-modal--show'); + var $nextButton = $modal.length ? $modal.find('[data-action="next"]') : $('[data-action="next"]'); // Click on the next button in detail view modal + if ($nextButton.length) { + $nextButton[0].click() + } } } else if (event.keyCode === 37) { // Key code for the left arrow key if (!isInputFocused) { // Click on the previous button in detail view modal - $('[data-action="previous"]').click(); + var $modal = $('.oh-modal--show'); + var $previousButton = $modal.length ? $modal.find('[data-action="previous"]') : $('[data-action="previous"]'); + if ($previousButton.length) { + $previousButton[0].click(); + + } } } }); diff --git a/templates/initialize_database/horilla_user_signup.html b/templates/initialize_database/horilla_user_signup.html index 8316a7ac0..26a2adb34 100644 --- a/templates/initialize_database/horilla_user_signup.html +++ b/templates/initialize_database/horilla_user_signup.html @@ -1,157 +1,153 @@ {% load i18n %}
- Horilla HRMS - + Horilla HRMS +
-

- {% trans "Sign Up" %} +

+ {% trans "Sign Up" %}

- {% trans "Please sign up to access the Horilla HRMS." %} + {% trans "Please sign up to access the Horilla HRMS." %}

-
- {% csrf_token %} -
-
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
- -
- - + + {% csrf_token %} +
+
+
+ + +
+
+
+
+ + +
-
-
-
-
-
- - -
+
+
+
+ + +
+
+
+
+ + +
+
-
-
- - -
+
+
+
+ + +
+
+
+
+ + +
+
-
- + +
+
+
+ +
+ + +
+
+
+
+
+ +
+ + +
+
+
+
+