Skip to content

Commit 35545a9

Browse files
committed
refactor: remove duplicated method
1 parent c1e0d14 commit 35545a9

File tree

1 file changed

+0
-104
lines changed

1 file changed

+0
-104
lines changed

Access/views_helper.py

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -101,110 +101,6 @@ def decline_group_other_access(access_mapping):
101101
)
102102

103103

104-
def run_access_grant(requestId, requestObject, accessType, user, approver):
105-
message = ""
106-
107-
if not requestObject.user.state == "1":
108-
requestObject.status = "Declined"
109-
requestObject.save()
110-
logger.debug(
111-
{
112-
"requestId": requestId,
113-
"status": "Declined",
114-
"by": approver,
115-
"response": message,
116-
}
117-
)
118-
return False
119-
120-
access_module = helper.get_available_access_module_from_tag(accessType)
121-
if not access_module:
122-
return False
123-
124-
try:
125-
response = access_module.approve(
126-
user,
127-
[requestObject.access.access_label],
128-
approver,
129-
requestId,
130-
is_group=False,
131-
)
132-
if type(response) is bool:
133-
approve_success = response
134-
else:
135-
approve_success = response[0]
136-
message = str(response[1])
137-
except Exception:
138-
logger.exception(
139-
"Error while running approval module: "
140-
+ str(traceback.format_exc())
141-
)
142-
approve_success = False
143-
message = str(traceback.format_exc())
144-
if approve_success:
145-
requestObject.status = "Approved"
146-
requestObject.save()
147-
logger.debug(
148-
{
149-
"requestId": requestId,
150-
"status": "Approved",
151-
"by": approver,
152-
"response": message,
153-
}
154-
)
155-
else:
156-
requestObject.status = "GrantFailed"
157-
requestObject.save()
158-
logger.debug(
159-
{
160-
"requestId": requestId,
161-
"status": "GrantFailed",
162-
"by": approver,
163-
"response": message,
164-
}
165-
)
166-
try:
167-
destination = [
168-
access_module.access_mark_revoke_permission(accessType)
169-
]
170-
subject = str("Access Grant Failed - ") + accessType.upper()
171-
body = (
172-
"Request by "
173-
+ user.email
174-
+ " having Request ID = "
175-
+ requestId
176-
+ " is GrantFailed. Please debug and rerun the grant.<BR/>"
177-
)
178-
body = body + "Failure Reason - " + message
179-
body = (
180-
body
181-
+ "<BR/><BR/> <a target='_blank'"
182-
+ "href "
183-
+ "='https://enigma.browserstack.com/resolve/pendingFailure?access_type="
184-
+ accessType
185-
+ "'>View all failed grants</a>"
186-
)
187-
logger.debug(
188-
"Sending Grant Failed email - "
189-
+ str(destination)
190-
+ " - "
191-
+ subject
192-
+ " - "
193-
+ body
194-
)
195-
general.emailSES(destination, subject, body)
196-
except Exception:
197-
logger.debug(
198-
"Grant Failed - Error while sending email - "
199-
+ requestId
200-
+ "-"
201-
+ str(str(traceback.format_exc()))
202-
)
203-
204-
# For generic modules, approve method will send an email on "Access granted",
205-
# additional email of "Access approved" is not needed
206-
return True
207-
208104
def render_error_message(request, log_message, user_message, user_message_description):
209105
logger.error(log_message)
210106
return render(request, 'BSOps/accessStatus.html', {

0 commit comments

Comments
 (0)