Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
red-group-test
red-ci-cd
Commits
a1533c35
Commit
a1533c35
authored
Nov 26, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added company and department object on template user list
parent
49f9b3cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
app/applicationlayer/cms/master/template/account/views.py
app/applicationlayer/cms/master/template/account/views.py
+11
-1
app/applicationlayer/management/batchupload/views.py
app/applicationlayer/management/batchupload/views.py
+15
-18
No files found.
app/applicationlayer/cms/master/template/account/views.py
View file @
a1533c35
...
...
@@ -6,6 +6,7 @@ from app.entities import models
from
rest_framework.response
import
Response
from
django.db.models
import
Q
from
rest_framework
import
status
from
django.db.models
import
F
class
UserListTemplate
(
APIView
):
...
...
@@ -22,9 +23,18 @@ class UserListTemplate(APIView):
Q
(
create_change_request_template
=
True
)
)
.
values_list
(
'id_number'
)
user_list
=
models
.
User
.
objects
.
filter
(
code__in
=
verified_users
)
)
.
annotate
(
company_code
=
F
(
'department__company__code'
),
company_name
=
F
(
'department__company__name'
),
department_code
=
F
(
'department__code'
),
department_name
=
F
(
'department__name'
)
)
.
values
()
print
(
user_list
)
page
=
self
.
paginate_queryset
(
user_list
)
...
...
app/applicationlayer/management/batchupload/views.py
View file @
a1533c35
import
copy
,
datetime
import
os
import
datetime
import
threading
import
configparser
import
pandas
as
pd
import
io
,
os
from
datetime
import
datetime
from
app.entities
import
enums
from
django.db
import
transaction
...
...
@@ -20,22 +21,19 @@ from app.entities.models import (
AllowedCompany
,
Company
,
Department
,
UserHistory
,
MasterAttachment
)
from
app.applicationlayer.utils
import
(
CustomPagination
,
status_message_response
,
status_message_response
,
main_threading
,
PaginationForETL
)
from
rest_framework.exceptions
import
ParseError
from
django.db.models
import
Q
from
rest_framework.exceptions
import
ParseError
from
rest_framework.decorators
import
action
from
django.contrib.auth.hashers
import
make_password
from
app.entities
import
enums
from
django_filters.rest_framework
import
DjangoFilterBackend
from
rest_framework.filters
import
SearchFilter
,
OrderingFilter
from
app.applicationlayer.management.batchupload.table_filters
import
ExtractTransformLoadFilter
from
django.db.models
import
F
,
Value
from
django.core.files.base
import
ContentFile
import
configparser
config
=
configparser
.
ConfigParser
()
config_file
=
os
.
path
.
join
(
'./'
,
'env.ini'
)
config
.
read
(
config_file
)
...
...
@@ -68,7 +66,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
message
=
status_message_response
(
200
,
'success'
,
'
list of filename found
'
,
''
,
serializer
.
data
)
...
...
@@ -94,7 +92,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
message
=
status_message_response
(
200
,
'success'
,
'List of
Change Request Form
found'
,
'List of
User
found'
,
serializer
.
data
)
...
...
@@ -116,7 +114,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
message
=
status_message_response
(
200
,
'success'
,
'
file been download
'
,
''
,
serializer
.
data
)
return
self
.
get_paginated_response
(
message
)
...
...
@@ -132,7 +130,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
attach_user
.
first
()
.
delete
()
departments
=
Department
.
objects
.
exclude
(
id
=
1
)
.
annotate
(
Privilege_Company
=
F
(
'company__name'
),
Privilege_Company
=
F
(
'company__name'
),
Privilege_Department
=
F
(
'name'
),
Privilege_Department_Code
=
F
(
'code'
)
)
.
values
(
...
...
@@ -193,7 +191,7 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
message
=
status_message_response
(
200
,
'success'
,
'
List of Change Request Form
found'
,
'
User File format is
found'
,
serializer
.
data
)
return
self
.
get_paginated_response
(
message
)
...
...
@@ -330,7 +328,6 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
view_all
=
True
if
keys
[
'View_All_CR'
]
==
'Yes'
else
False
approve_cr
=
True
if
keys
[
'Approve_CR'
]
==
'Yes'
else
False
privilege_
=
keys
[
'Privilege_Department'
]
privilege_object
=
{
"id_number"
:
current_user
,
"company_pivot"
:
privilege_department_code
.
company
,
...
...
@@ -357,11 +354,11 @@ class BatchUploadViewSet(viewsets.ModelViewSet):
status
=
status
.
HTTP_400_BAD_REQUEST
)
#
except KeyError as e:
#
return Response(
#
{"message": f"Missing column {e.args[0]}"},
#
status=status.HTTP_400_BAD_REQUEST
#
)
except
KeyError
as
e
:
return
Response
(
{
"message"
:
f
"Missing column {e.args[0]}"
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
# except ValueError as e:
# return Response(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment