Skip to content

Commit a135262

Browse files
authored
Merge pull request #99 from browserstack/refactor_templates
fix: fix support for mysql for __contains query
2 parents 07db2d1 + da4ba7c commit a135262

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Access/accessrequest_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def get_decline_access_request(request, access_type, request_id):
235235
current_ids = list(
236236
GroupAccessMapping.get_pending_access_mapping(
237237
request_id=group_name
238-
).filter(request_id__contains=date_suffix)
238+
).filter(request_id__icontains=date_suffix)
239239
)
240240
request_ids.extend(current_ids)
241241
access_type = "groupAccess"

Access/group_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def save_group_access_request(form_data, auth_user):
724724
def _create_group_access_mapping(
725725
group, user, request_id, access_tag, access_label, access_reason
726726
):
727-
access = AccessV2.get(access_type=access_tag, access_label=access_label)
727+
access = AccessV2.get(access_tag=access_tag, access_label=access_label)
728728
if not access:
729729
access = AccessV2.create(access_tag=access_tag, access_label=access_label)
730730
else:

Access/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ def decline_access(self, decline_reason=None):
858858
@staticmethod
859859
def get_pending_access_mapping(request_id):
860860
return UserAccessMapping.objects.filter(
861-
request_id__contains=request_id, status__in=["Pending", "SecondaryPending"]
861+
request_id__icontains=request_id, status__in=["Pending", "SecondaryPending"]
862862
).values_list("request_id", flat=True)
863863

864864
def update_access_status(self, current_status):
@@ -1055,7 +1055,7 @@ def get_by_request_id(request_id):
10551055
@staticmethod
10561056
def get_pending_access_mapping(request_id):
10571057
return GroupAccessMapping.objects.filter(
1058-
request_id__contains=request_id, status__in=["Pending", "SecondaryPending"]
1058+
request_id__icontains=request_id, status__in=["Pending", "SecondaryPending"]
10591059
).values_list("request_id", flat=True)
10601060

10611061
def is_pending(self):

Access/views.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Django views."""
22
import json
3-
import logging
3+
import logging, traceback
44
from rest_framework.authentication import TokenAuthentication, BasicAuthentication
55
from rest_framework.decorators import api_view
66
from django.contrib.auth.decorators import login_required
@@ -386,7 +386,7 @@ def accept_bulk(request, selector):
386386
context["returnIds"] = return_ids
387387
return JsonResponse(context, status=200)
388388
except Exception as ex:
389-
logger.error("Error processing bulk accept, Error: %s", str(ex))
389+
logger.error("Error processing bulk accept, Error: %s", traceback.format_exc())
390390
json_response = {}
391391
json_response["error"] = INVALID_REQUEST_MESSAGE
392392
json_response["success"] = False
@@ -412,7 +412,7 @@ def _get_request_ids_for_bulk_processing(posted_request_ids, selector):
412412
current_ids = list(
413413
GroupAccessMapping.get_pending_access_mapping(
414414
request_id=group_name
415-
).filter(request_id__contains=date_suffix)
415+
).filter(request_id__icontains=date_suffix)
416416
)
417417
access_request_ids.extend(current_ids)
418418
selector = "groupAccess"
@@ -439,7 +439,7 @@ def decline_access(request, access_type, request_id):
439439
context = get_decline_access_request(request, access_type, request_id)
440440
return JsonResponse(context, status=200)
441441
except Exception as ex:
442-
logger.exception("Error declining access, Error: %s", str(ex))
442+
logger.exception("Error declining access, Error: %s", traceback.format_exc())
443443
return JsonResponse(
444444
{"error": "Failed to decline the access request"}, status=400
445445
)
@@ -461,7 +461,7 @@ def remove_group_member(request):
461461
return JsonResponse(response, status=400)
462462
return JsonResponse({"message": "Success"})
463463
except Exception as ex:
464-
logger.exception("Error removing memeber from group, Error: %s", str(ex))
464+
logger.exception("Error removing memeber from group, Error: %s", traceback.format_exc())
465465
return JsonResponse({"error": "Failed to remove the user"}, status=400)
466466

467467

@@ -486,7 +486,7 @@ def all_user_access_list(request, load_ui=True):
486486
user = djangoUser.objects.get(username=username)
487487
except Exception as ex:
488488
# show all
489-
logger.exception(ex)
489+
logger.exception("Error raised in all_user_access_list: %s" % (traceback.format_exc()))
490490

491491
try:
492492
last_page = 1
@@ -562,7 +562,7 @@ def all_user_access_list(request, load_ui=True):
562562
logger.exception(
563563
"""Error fetching all users access list,
564564
request not found OR Invalid request type, Error: %s""",
565-
str(ex),
565+
traceback.format_exc(),
566566
)
567567
json_response = {}
568568
json_response["error"] = {
@@ -621,7 +621,7 @@ def mark_revoked(request):
621621
json_response["msg"] = "Success"
622622
json_response["request_ids"] = success_list
623623
except Exception as ex:
624-
logger.exception("Error Revoking User Access, Error: %s", str(ex))
624+
logger.exception("Error Revoking User Access, Error: %s", traceback.format_exc())
625625
json_response["error"] = "Error Revoking User Access"
626626
return JsonResponse(json_response, status=403)
627627

@@ -648,7 +648,7 @@ def individual_resolve(request):
648648
json_response["status_list"].append({'title': 'The Request ('+request_id+') is already resolved.', 'msg': 'The request is already in final state.'})
649649
return render(request,'EnigmaOps/accessStatus.html',json_response)
650650
except Exception as e:
651-
logger.exception(str(e))
651+
logger.exception("Error raised during individual_resolve %s" % (traceback.format_exc()))
652652
json_response["error"] = {
653653
"error_msg": "Bad request",
654654
"msg": "Error in request not found OR Invalid request type",
@@ -693,7 +693,7 @@ def ignore_failure(request, selector):
693693
return render(request, "EnigmaOps/accessStatus.html", json_response)
694694
except Exception as e:
695695
logger.debug("Error in request not found OR Invalid request type")
696-
logger.exception(e)
696+
logger.exception("Error while executing ignore_failure: %s" % (traceback.format_exc()))
697697
json_response = {}
698698
json_response["error"] = {
699699
"error_msg": str(e),
@@ -731,7 +731,7 @@ def resolve_bulk(request):
731731
return render(request, "EnigmaOps/accessStatus.html", json_response)
732732
except Exception as e:
733733
logger.debug("Error in request not found OR Invalid request type")
734-
logger.exception(e)
734+
logger.exception("Raised error during resolve_bulk: %s" % (traceback.format_exc()))
735735
json_response = {}
736736
json_response['error'] = {'error_msg': "Bad request", 'msg': "Error in request not found OR Invalid request type"}
737737
return render(request,'EnigmaOps/accessStatus.html',json_response)
@@ -744,6 +744,6 @@ def revoke_group_access(request):
744744

745745
return JsonResponse(response)
746746
except Exception as e:
747-
logger.exception(str(e))
747+
logger.exception("Error while revoking group access %s" % (traceback.format_exc()))
748748
logger.debug("Something went wrong while revoking group access")
749749
return JsonResponse({"message": "Failed to revoke group Access"}, status=400)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ all: build test lint
55
## make dev : Build and start docker containers - (web/test/db)
66
.PHONY: dev
77
dev:
8-
@docker-compose build && docker-compose up -d
8+
@docker-compose build && docker-compose up -d web celery
99

1010
## make build : Build and start docker containers - (web and db)
1111
.PHONY: build

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ services:
2727
env_file:
2828
- ./secrets/ops_mysql_dev.env
2929
volumes:
30-
- ./dbs:/var/lib/mysql --socket=/tmp/mysql.sock
30+
- ./mounts/mysql_db/data:/var/lib/mysql
3131
redis:
3232
container_name: redis
3333
image: redis:alpine

0 commit comments

Comments
 (0)