diff --git a/hiring_module/.example-env b/hiring_module/.example-env deleted file mode 100644 index 72c0386..0000000 --- a/hiring_module/.example-env +++ /dev/null @@ -1,15 +0,0 @@ -SECRET_KEY=django-insecure-4ht3kx09p6eqjx1&(l#d8h5qsmg(3jdgthb2aw#gz!7un41*mr -DEBUG=True - -DATABASE_NAME=defaultdb -DATABASE_USER=avnadmin -DATABASE_PASSWORD=AVNS_R9bgbL8Sy56Ggdg3g1s -DATABASE_HOST=module-hiring-hiring-module.b.aivencloud.com -DATABASE_PORT=17645 - -EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend -EMAIL_HOST=mail.sebastiandiazdev.com -EMAIL_PORT=465 -EMAIL_USE_SSL=True -EMAIL_HOST_USER=no-reply@sebastiandiazdev.com -EMAIL_HOST_PASSWORD=w=!56S93oK$h diff --git a/hiring_module/hiring_app/templates/control_board/base.html b/hiring_module/hiring_app/templates/control_board/base.html new file mode 100644 index 0000000..dfabfbd --- /dev/null +++ b/hiring_module/hiring_app/templates/control_board/base.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} +{% load static %} +{% block title %} +Panel de control +{% endblock %} +{% block aditionalMetadata %} +{% endblock %} + +{% block content %} + +
+ {% include 'control_board/center_container.html' %} + + {% include 'control_board/table.html' with managers=managers leaders=leaders group=actualgroup%} + + +
+ {% block control_board %} + + {% endblock %} +
+ + {% include 'control_board/state_change.html' %} +
+ + +{% endblock %} \ No newline at end of file diff --git a/hiring_module/hiring_app/templates/control_board/table.html b/hiring_module/hiring_app/templates/control_board/table.html index 7fcec71..933aec3 100644 --- a/hiring_module/hiring_app/templates/control_board/table.html +++ b/hiring_module/hiring_app/templates/control_board/table.html @@ -1,4 +1,3 @@ - \ No newline at end of file +}); + diff --git a/hiring_module/hiring_app/templates/request_hiring/components/assign_manager.html b/hiring_module/hiring_app/templates/request_hiring/components/assign_manager.html index 35af09b..650f2a6 100644 --- a/hiring_module/hiring_app/templates/request_hiring/components/assign_manager.html +++ b/hiring_module/hiring_app/templates/request_hiring/components/assign_manager.html @@ -1,8 +1,6 @@ -
+ {% csrf_token %} -
diff --git a/hiring_module/hiring_app/views/control_board/administrator_dashboard_view.py b/hiring_module/hiring_app/views/control_board/administrator_dashboard_view.py index c2a613f..f3d3e22 100644 --- a/hiring_module/hiring_app/views/control_board/administrator_dashboard_view.py +++ b/hiring_module/hiring_app/views/control_board/administrator_dashboard_view.py @@ -12,7 +12,9 @@ class AdministratorDashboardView(View): # Redirect to correct dashboard based on user role @method_decorator(role_redirect) def dispatch(self, request, *args, **kwargs): - context = {} + context = { + 'actualgroup': 'admin' + } context.update(get_requests(self.request.user)) return render(request, self.template_name, context) diff --git a/hiring_module/hiring_app/views/control_board/leader_dashboard_view.py b/hiring_module/hiring_app/views/control_board/leader_dashboard_view.py index 0cd3e9c..f8394ed 100644 --- a/hiring_module/hiring_app/views/control_board/leader_dashboard_view.py +++ b/hiring_module/hiring_app/views/control_board/leader_dashboard_view.py @@ -10,7 +10,9 @@ class LeaderDashboardView(View): # Redirect to correct dashboard based on user role @method_decorator(role_redirect) def dispatch(self, request, *args, **kwargs): - context = {} + context = { + 'actualgroup': 'leader' + } context.update(get_requests(self.request.user)) return render(request, self.template_name, context) diff --git a/hiring_module/hiring_app/views/control_board/manager_dashboard_view.py b/hiring_module/hiring_app/views/control_board/manager_dashboard_view.py index c2da179..648dd73 100644 --- a/hiring_module/hiring_app/views/control_board/manager_dashboard_view.py +++ b/hiring_module/hiring_app/views/control_board/manager_dashboard_view.py @@ -10,7 +10,9 @@ class ManagerDashboardView(View): # Redirect to correct dashboard based on user role @method_decorator(role_redirect) def dispatch(self, request, *args, **kwargs): - context = {} + context = { + 'actualgroup': 'manager' + } context.update(get_requests(self.request.user)) return render(request, self.template_name, context) diff --git a/hiring_module/hiring_app/views/control_board/utilities.py b/hiring_module/hiring_app/views/control_board/utilities.py index 7cfa097..e2a1f64 100644 --- a/hiring_module/hiring_app/views/control_board/utilities.py +++ b/hiring_module/hiring_app/views/control_board/utilities.py @@ -27,23 +27,31 @@ def wrapper(request, *args, **kwargs): return wrapper def get_requests(user): - print(user) groups = [group.name for group in user.groups.all()] requests_CEX = CEXContractRequest.objects.none() requests_monitoring = MonitoringContractRequest.objects.none() - if 'admin' in groups or 'leader' in groups: + if 'admin' in groups: requests_CEX = CEXContractRequest.objects.all() requests_monitoring = MonitoringContractRequest.objects.all() + elif 'leader' in groups: + requests_CEX = CEXContractRequest.objects.filter(leader_assigned_to=user.id) + requests_monitoring = MonitoringContractRequest.objects.filter(leader_assigned_to=user.id) elif 'manager' in groups: requests_CEX = CEXContractRequest.objects.filter(manager_assigned_to=user.id) requests_monitoring = MonitoringContractRequest.objects.filter(manager_assigned_to=user.id) - + + groupManager = Group.objects.get(name='manager') + groupLeader = Group.objects.get(name='leader') + managers = list(CustomUser.objects.filter(groups=groupManager)) + leaders = list(CustomUser.objects.filter(groups=groupLeader)) return { 'requests': list(requests_CEX) + list(requests_monitoring), 'filled_requests': list(requests_CEX.filter(state='filed')) + list(requests_monitoring.filter(state='filed')), 'reviewed_requests': list(requests_CEX.filter(state='review')) + list(requests_monitoring.filter(state='review')), - 'for_validate_requests': list(requests_CEX.filter(state__in=['pending', 'incomplete'])) + list(requests_monitoring.filter(state__in=['pending', 'incomplete'])) + 'for_validate_requests': list(requests_CEX.filter(state__in=['pending', 'incomplete'])) + list(requests_monitoring.filter(state__in=['pending', 'incomplete'])), + 'leaders': leaders, + 'managers': managers, } diff --git a/hiring_module/hiring_app/views/request_hiring/assign_leader.py b/hiring_module/hiring_app/views/request_hiring/assign_leader.py index 8cfbe16..78282cd 100644 --- a/hiring_module/hiring_app/views/request_hiring/assign_leader.py +++ b/hiring_module/hiring_app/views/request_hiring/assign_leader.py @@ -21,5 +21,5 @@ def post(self, request, idContract): request.session['error_message'] = 'Selected user is not leader.' else: request.session['error_message'] = 'You do not have permission for this action.' - return redirect('hiring_app:info', idContract=idContract) + return redirect(request.META.get('HTTP_REFERER')) diff --git a/hiring_module/hiring_app/views/request_hiring/assign_manager.py b/hiring_module/hiring_app/views/request_hiring/assign_manager.py index 218f502..1117f9f 100644 --- a/hiring_module/hiring_app/views/request_hiring/assign_manager.py +++ b/hiring_module/hiring_app/views/request_hiring/assign_manager.py @@ -22,5 +22,5 @@ def post(self, request, idContract): request.session['error_message'] = 'Selected user is not manager.' else: request.session['error_message'] = 'You do not have permission for this action.' - return redirect('hiring_app:info', idContract=idContract) + return redirect(request.META.get('HTTP_REFERER')) diff --git a/hiring_module/hiring_app/views/request_hiring/request_hiring_view.py b/hiring_module/hiring_app/views/request_hiring/request_hiring_view.py index c1ace6d..69dab41 100644 --- a/hiring_module/hiring_app/views/request_hiring/request_hiring_view.py +++ b/hiring_module/hiring_app/views/request_hiring/request_hiring_view.py @@ -12,9 +12,6 @@ class RequestHiringView(View): def references(self, request, idContract): - is_admin = any(group.name == 'admin' for group in self.request.user.groups.all()) - is_leader = any(group.name == 'leader' for group in self.request.user.groups.all()) - is_manager = any(group.name == 'manager' for group in self.request.user.groups.all()) groupManager = Group.objects.get(name='manager') groupLeader = Group.objects.get(name='leader') managers = list(CustomUser.objects.filter(groups=groupManager)) @@ -35,9 +32,7 @@ def references(self, request, idContract): 'leaders': leaders, 'error_message': request.session.pop('error_message', None), 'user': self.request.user, - 'is_admin': is_admin, - 'is_leader': is_leader, - 'is_manager': is_manager, + 'actualgroup': str(self.request.user.groups.first()), 'snapshot_comment': snapshot_comment }