Commit facbcbef authored by John Red Medrano's avatar John Red Medrano

bug fixed on change request department endpoint

parent 02429581
......@@ -24,13 +24,11 @@ class ChangeRequestCompanyViewSet(viewsets.ModelViewSet):
http_method_names = ['get']
def list(self, request, *args, **kwargs):
print(self.request.user.code)
queryset = self.filter_queryset(self.get_queryset())
allowed = AllowedCompany.objects.filter(
id_number=self.request.user.code
).values('company_pivot')
# print(allowed)
queryset = queryset.filter(code__in=allowed)
page = self.paginate_queryset(queryset)
......
......@@ -14,6 +14,8 @@ from app.applicationlayer.cms.master.department.table_filters import (
ChangeRequestDepartmentFilterSet
)
from app.helper.decorators import rms
from django.db.models import Q
from rest_framework.exceptions import ParseError
class ChangeRequestDepartmentViewSet(viewsets.ModelViewSet):
......@@ -26,12 +28,13 @@ class ChangeRequestDepartmentViewSet(viewsets.ModelViewSet):
ordering_fields = '__all__'
search_fields = ('name', 'company__name', 'code')
@rms.department_list
# @rms.department_list
def list(self, request, *args, **kwargs):
company = self.request.query_params['company_code']
queryset = self.filter_queryset(self.get_queryset())
allowed = AllowedCompany.objects.filter(
id_number=self.request.user.code
Q(id_number=self.request.user.code) &
Q(company_pivot=company)
).values('group_pivots')
queryset = queryset.filter(code__in=allowed)
page = self.paginate_queryset(queryset)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,12 +36,12 @@ CREATE TABLE IF NOT EXISTS `allowed_company` (
CONSTRAINT `allowed_company_id_number_id_7c5c7fc8_fk_auth_user_code` FOREIGN KEY (`id_number_id`) REFERENCES `auth_user` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
-- Dumping data for table rms_db.allowed_company: ~1 rows (approximately)
-- Dumping data for table rms_db.allowed_company: ~2 rows (approximately)
DELETE FROM `allowed_company`;
/*!40000 ALTER TABLE `allowed_company` DISABLE KEYS */;
INSERT INTO `allowed_company` (`id`, `create_change_request`, `create_change_request_template`, `view_all_change_request`, `created_at`, `deleted_at`, `company_pivot_id`, `group_pivots_id`, `id_number_id`) VALUES
(24, 1, 1, 1, '2019-09-18 15:01:40.721221', NULL, 'COMPANY-20190917-0000001', 'DEPARTMENT-20190917-0000001', 'USER-20190917-0000001'),
(25, 1, 1, 1, '2019-09-18 15:01:40.745227', NULL, 'COMPANY-20190917-0000001', 'DEPARTMENT-20190917-0000001', 'USER-20190917-0000001');
(25, 1, 1, 1, '2019-09-18 15:01:40.745227', NULL, 'COMPANY-20190917-0000001', 'DEPARTMENT-20190917-0000002', 'USER-20190917-0000001');
/*!40000 ALTER TABLE `allowed_company` ENABLE KEYS */;
-- Dumping structure for table rms_db.applications
......@@ -100,7 +100,7 @@ CREATE TABLE IF NOT EXISTS `authtoken_token` (
DELETE FROM `authtoken_token`;
/*!40000 ALTER TABLE `authtoken_token` DISABLE KEYS */;
INSERT INTO `authtoken_token` (`key`, `created`, `user_id`) VALUES
('b7b77207fd444444355e6abf3883c11771d1a48e', '2019-09-18 15:15:10.827183', 1);
('b7b77207fd444444355e6abf3883c11771d1a48e', '2019-09-18 15:39:15.636649', 1);
/*!40000 ALTER TABLE `authtoken_token` ENABLE KEYS */;
-- Dumping structure for table rms_db.auth_access_token
......@@ -355,7 +355,7 @@ CREATE TABLE IF NOT EXISTS `auth_user_application` (
CONSTRAINT `auth_user_application_user_id_7b07e391_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
-- Dumping data for table rms_db.auth_user_application: ~0 rows (approximately)
-- Dumping data for table rms_db.auth_user_application: ~3 rows (approximately)
DELETE FROM `auth_user_application`;
/*!40000 ALTER TABLE `auth_user_application` DISABLE KEYS */;
INSERT INTO `auth_user_application` (`id`, `user_id`, `application_id`) VALUES
......@@ -847,7 +847,7 @@ CREATE TABLE IF NOT EXISTS `django_migrations` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
-- Dumping data for table rms_db.django_migrations: ~22 rows (approximately)
-- Dumping data for table rms_db.django_migrations: ~23 rows (approximately)
DELETE FROM `django_migrations`;
/*!40000 ALTER TABLE `django_migrations` DISABLE KEYS */;
INSERT INTO `django_migrations` (`id`, `app`, `name`, `applied`) VALUES
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment