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
21b10756
Commit
21b10756
authored
Sep 20, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added delete template draft fixed bug on change password user level
parent
93715e78
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
251 additions
and
281 deletions
+251
-281
app/accesslayer/views.py
app/accesslayer/views.py
+2
-2
app/applicationlayer/cms/template/views.py
app/applicationlayer/cms/template/views.py
+39
-42
app/applicationlayer/cms/utils_cr.py
app/applicationlayer/cms/utils_cr.py
+25
-0
app/applicationlayer/management/account/serializer.py
app/applicationlayer/management/account/serializer.py
+8
-5
app/applicationlayer/management/account/views.py
app/applicationlayer/management/account/views.py
+13
-11
app/datalayer/serializer_handler.py
app/datalayer/serializer_handler.py
+6
-2
app/entities/migrations/0005_auto_20190919_1625.py
app/entities/migrations/0005_auto_20190919_1625.py
+18
-0
app/helper/email_service/sender.py
app/helper/email_service/sender.py
+1
-0
env.template.ini
env.template.ini
+5
-5
requirements/RMSv2.postman_collection_091619
requirements/RMSv2.postman_collection_091619
+134
-214
No files found.
app/accesslayer/views.py
View file @
21b10756
...
...
@@ -154,10 +154,10 @@ class ForgotPassword(APIView):
user
=
existingUser
,
)
.
save
()
url
=
f
"{settings.FRONT_END_URL}/
account/forgot-password-
reset"
\
url
=
f
"{settings.FRONT_END_URL}/
forgot-password/
reset"
\
f
"?token={TOKEN}"
args
=
[
str
(
PASSCODE
),
str
(
url
),
str
(
existingUser
.
email
),
user
]
args
=
[
str
(
PASSCODE
),
str
(
url
),
user
,
str
(
existingUser
.
email
)
]
# t1 = threading.Thread(target=sender.forgot_password, args=(args,))
# t1.start()
...
...
app/applicationlayer/cms/template/views.py
View file @
21b10756
...
...
@@ -22,7 +22,9 @@ from rest_framework.exceptions import ValidationError
from
django.db
import
transaction
,
IntegrityError
,
connection
from
app.applicationlayer.utils
import
QuerySetHelper
,
CustomPagination
,
status_message_response
from
app.businesslayer.changerequest
import
change_request
from
app.applicationlayer.cms.utils_cr
import
number_generator
,
crhistory_save
from
app.applicationlayer.cms.utils_cr
import
(
number_generator
,
crhistory_save
,
entity_log_bulk
)
from
django.shortcuts
import
get_object_or_404
from
rest_framework.generics
import
GenericAPIView
...
...
@@ -33,6 +35,7 @@ from django.db.models import Q
from
app.applicationlayer.management.account.serializer
import
ChangeRequestList
from
app.applicationlayer.utils
import
log_save
from
rest_framework.exceptions
import
ParseError
class
UserList
(
APIView
):
...
...
@@ -122,72 +125,66 @@ class ChangeRequestTemplatesViewset(meviewsets.ModelViewSet):
serializer
=
self
.
get_serializer
(
instance
)
return
Response
(
serializer
.
data
)
# @transaction.atomic()
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
# try:
template_no
=
self
.
kwargs
[
'template_no'
]
enum_approver
=
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateApprovers
.
value
enum_stake
=
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateStakeHolders
.
value
enum_attach
=
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateAttachments
.
value
enum_detail
=
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateDetails
.
value
enum_header
=
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateHeader
.
value
approver
=
models
.
ChangeRequestTemplateApprovers
.
objects
.
filter
(
template_no
=
template_no
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateApprovers
.
value
,
approver
.
values
()[
0
][
'id'
],
approver
.
values
()[
0
],
''
)
approver
.
delete
()
if
approver
.
count
()
>
0
:
entity_log_bulk
(
approver
,
enum_approver
,
models
.
ChangeRequestTemplateApprovers
)
stake
=
models
.
ChangeRequestTemplateStakeHolders
.
objects
.
filter
(
template_no
=
template_no
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateStakeHolders
.
value
,
stake
.
first
()[
'id'
],
stake
.
values
()
.
first
(),
''
)
stake
.
delete
()
if
stake
.
count
()
>
0
:
entity_log_bulk
(
approver
,
enum_stake
,
models
.
ChangeRequestTemplateStakeHolders
)
attachment
=
models
.
ChangeRequestTemplateAttachments
.
objects
.
filter
(
template_no
=
template_no
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateAttachments
.
value
,
attachment
.
first
()[
'id'
],
attachment
.
values
()
.
first
(),
''
)
attachment
.
delete
()
if
attachment
.
count
()
>
0
:
entity_log_bulk
(
approver
,
enum_attach
,
models
.
ChangeRequestTemplateAttachments
)
details
=
models
.
ChangeRequestTemplateDetails
.
objects
.
filter
(
template_no
=
template_no
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateHeader
.
value
,
details
.
first
()[
'id'
],
details
.
values
()
.
first
(),
''
)
details
.
delete
()
if
details
.
count
()
>
0
:
entity_log_bulk
(
approver
,
enum_detail
,
models
.
ChangeRequestTemplateDetails
)
header
=
models
.
ChangeRequestTemplateHeader
.
objects
.
filter
(
template_no
=
template_no
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
enums
.
LogEntitiesEnum
.
ChangeRequestTemplateHeader
.
value
,
header
.
first
()[
'id'
],
header
.
values
()
.
first
(),
''
)
header
.
delete
()
if
header
.
count
()
>
0
:
entity_log_bulk
(
approver
,
enum_header
,
models
.
ChangeRequestTemplateHeader
)
return
Response
({
"message"
:
"Deleted"
},
status
=
status
.
HTTP_200_OK
)
# except Exception as e:
# return Response(e,
...
...
app/applicationlayer/cms/utils_cr.py
View file @
21b10756
...
...
@@ -8,11 +8,36 @@ from datetime import timedelta
from
django.db.models
import
Q
from
app.applicationlayer.utils
import
main_threading
,
notification_create
from
app.helper.email_service
import
sender
from
app.applicationlayer.utils
import
log_save
from
app.entities
import
enums
from
django.forms.models
import
model_to_dict
from
rest_framework.exceptions
import
ParseError
from
django.db
import
IntegrityError
from
rest_framework.exceptions
import
APIException
CR_FRONT_LINK
=
settings
.
CR_FRONT_LINK
# NOTIFICATION = settings.NOTIFICATION
def
entity_log_bulk
(
queryset
,
entity
,
tbl
):
try
:
print
(
entity
)
for
data
in
queryset
:
test
=
model_to_dict
(
data
)
log_save
(
enums
.
LogEnum
.
DELETED
.
value
,
entity
,
test
[
'id'
],
test
,
''
)
tbl
.
objects
.
filter
(
id
=
test
[
'id'
])
.
delete
()
return
True
except
IntegrityError
as
exc
:
raise
APIException
(
detail
=
exc
)
def
get_dept_details
(
dept_no
):
dept_instance
=
models
.
Department
.
objects
.
filter
(
code
=
dept_no
)
...
...
app/applicationlayer/management/account/serializer.py
View file @
21b10756
...
...
@@ -57,12 +57,12 @@ class ChangePasswordSerializer(serializers.Serializer):
def
validate
(
self
,
data
):
instance
=
self
.
context
.
get
(
'view'
)
.
kwargs
[
'
pk
'
]
instance
=
self
.
context
.
get
(
'view'
)
.
kwargs
[
'
code
'
]
old_password
=
data
[
'old_password'
]
new_password
=
data
[
'new_password'
]
instance_password
=
User
.
objects
.
filter
(
id
=
instance
code
=
str
(
instance
)
)
validated_password
=
check_password
(
...
...
@@ -74,14 +74,17 @@ class ChangePasswordSerializer(serializers.Serializer):
password
=
re
.
match
(
'([A-Za-z]+[0-9]|[0-9]+[A-Za-z])[A-Za-z0-9]*'
,
data
[
'new_password'
]
new_password
)
print
(
"password"
)
print
(
password
)
print
(
password
)
if
password
:
new_password
=
make_password
(
data
[
'new_password'
]
)
new_password
=
make_password
(
new_password
)
instance_password
.
update
(
password
=
new_password
)
instance
=
User
.
objects
.
get
(
id
=
instance
)
# instance = User.objects.get(code=str(instance)
)
return
instance
elif
len
(
new_password
)
<=
5
:
...
...
app/applicationlayer/management/account/views.py
View file @
21b10756
...
...
@@ -153,9 +153,9 @@ class UserViewSet(viewsets.ModelViewSet):
code__in
=
request
.
data
[
'application'
]
)
instance2
=
User
.
objects
.
get
(
id
=
serializer
.
data
[
'id'
]
)
#
instance2 = User.objects.get(
#
id=serializer.data['id']
#
)
instance
.
application
.
set
(
app
)
...
...
@@ -224,12 +224,12 @@ class UserViewSet(viewsets.ModelViewSet):
methods
=
[
'put'
],
url_path
=
'change-password'
,
name
=
"Change Password of User"
)
@
decorators
.
error_safe
#
@decorators.error_safe
@
transaction
.
atomic
def
ChangePassword
(
self
,
request
,
pk
=
None
):
def
ChangePassword
(
self
,
request
,
code
=
None
):
self
.
serializer_class
=
serializer
.
ChangePasswordSerializer
serialized
=
self
.
get_serializer
(
data
=
request
.
data
,
context
=
{
'id'
:
pk
})
serialized
=
self
.
get_serializer
(
data
=
request
.
data
,
context
=
{
'id'
:
code
})
if
serialized
.
is_valid
():
...
...
@@ -239,14 +239,16 @@ class UserViewSet(viewsets.ModelViewSet):
if
form
[
'new_password'
]
!=
form
[
'new_password_confirm'
]:
raise
Exception
(
'Passwords must match'
)
existingUser
=
User
.
objects
.
filter
(
id
=
pk
)
.
first
()
existingUser
=
User
.
objects
.
filter
(
code
=
code
)
pk
=
existingUser
.
values
()
.
first
()[
'id'
]
if
existingUser
:
existingUser
.
set_password
(
form
[
'new_password_confirm'
])
fromObj
=
copy
.
copy
(
existingUser
)
existingUser
.
save
()
toObj
=
copy
.
copy
(
existingUser
)
existingUser
.
first
()
.
set_password
(
form
[
'new_password_confirm'
])
fromObj
=
copy
.
copy
(
existingUser
.
first
()
)
existingUser
.
first
()
.
save
()
toObj
=
copy
.
copy
(
existingUser
.
first
()
)
log_save
(
enums
.
LogEnum
.
UPDATE
.
value
,
...
...
app/datalayer/serializer_handler.py
View file @
21b10756
from
rest_framework.views
import
exception_handler
from
__future__
import
unicode_literals
from
django.db
import
IntegrityError
from
rest_framework.views
import
Response
,
exception_handler
from
rest_framework
import
status
from
itertools
import
islice
def
custom_exception_handler
(
exc
,
context
):
...
...
@@ -6,6 +10,7 @@ def custom_exception_handler(exc, context):
# to get the standard error response.
response
=
exception_handler
(
exc
,
context
)
# Update the structure of the response data.
if
response
is
not
None
:
error_message
=
{}
...
...
@@ -25,5 +30,4 @@ def custom_exception_handler(exc, context):
error_message
[
'message'
]
=
value
response
.
data
=
error_message
return
response
app/entities/migrations/0005_auto_20190919_1625.py
0 → 100644
View file @
21b10756
# Generated by Django 2.2 on 2019-09-19 16:25
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'entities'
,
'0004_auto_20190918_1104'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'entitylog'
,
name
=
'entity'
,
field
=
models
.
CharField
(
choices
=
[(
'USER'
,
'USER'
),
(
'APPLICATION'
,
'APPLICATION'
),
(
'COMPANY'
,
'COMPANY'
),
(
'DEPARTMENT'
,
'DEPARTMENT'
),
(
'MODULE'
,
'MODULE'
),
(
'ChangeRequestTemplateHeader'
,
'ChangeRequestTemplateHeader'
),
(
'ChangeRequestTemplateApprovers'
,
'ChangeRequestTemplateApprovers'
),
(
'ChangeRequestTemplateStakeHolders'
,
'ChangeRequestTemplateStakeHolders'
),
(
'ChangeRequestTemplateAttachments'
,
'ChangeRequestTemplateAttachments'
),
(
'ChangeRequestTemplateDetails'
,
'ChangeRequestTemplateDetails'
)],
default
=
'Add'
,
max_length
=
50
),
),
]
app/helper/email_service/sender.py
View file @
21b10756
...
...
@@ -60,6 +60,7 @@ def forgot_password(args):
FC
=
F
.
read
()
FC
=
FC
.
replace
(
'{name}'
,
recipient
)
FC
=
FC
.
replace
(
'{code}'
,
reset_code
)
FC
=
FC
.
replace
(
'{url}'
,
url
)
...
...
env.template.ini
View file @
21b10756
...
...
@@ -6,7 +6,7 @@ DATABASE_PASSWORD =
DATABASE_HOST =
DATABASE_PORT
=
SESSION_TIMEOUT =
FRONT_END_URL
=
FRONT_END_URL
=
http://devweb.rmsv2.oneberrysystem.com
AUTH_ACCESSS_TOKEN_TIMEOUT
=
USER_DEFAULT_PASSWORD =
CATCH_EMAIL
=
gladys@tirsolutions.com
...
...
@@ -20,7 +20,7 @@ DATABASE_PASSWORD =
DATABASE_HOST =
DATABASE_PORT
=
SESSION_TIMEOUT =
FRONT_END_URL
=
FRONT_END_URL
=
http://devweb.rmsv2.oneberrysystem.com
AUTH_ACCESSS_TOKEN_TIMEOUT
=
USER_DEFAULT_PASSWORD =
CATCH_EMAIL
=
gladys@tirsolutions.com
...
...
@@ -34,7 +34,7 @@ DATABASE_PASSWORD =
DATABASE_HOST =
DATABASE_PORT
=
SESSION_TIMEOUT =
FRONT_END_URL
=
FRONT_END_URL
=
http://devweb.rmsv2.oneberrysystem.com
AUTH_ACCESSS_TOKEN_TIMEOUT
=
USER_DEFAULT_PASSWORD =
CATCH_EMAIL
=
gladys@tirsolutions.com
...
...
@@ -44,11 +44,11 @@ CR_LINK = http://devweb.rms.oneberrysystem.com/cms/change-request/form/view
DATABASE_ENGINE
=
django.db.backends.mysql
DATABASE_NAME
=
rms_db
DATABASE_USER
=
root
DATABASE_PASSWORD
=
123
DATABASE_PASSWORD
=
password
DATABASE_HOST
=
localhost
DATABASE_PORT
=
3306
SESSION_TIMEOUT
=
30
FRONT_END_URL
=
FRONT_END_URL
=
http://devweb.rmsv2.oneberrysystem.com
AUTH_ACCESSS_TOKEN_TIMEOUT
=
3600
USER_DEFAULT_PASSWORD
=
password
CATCH_EMAIL
=
gladys@tirsolutions.com
...
...
requirements/RMSv2.postman_collection_091619
View file @
21b10756
This diff is collapsed.
Click to expand it.
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