def get_photo_info(date_, time_, counterPart, username): """ get the information assciated with a given photo name """ if username == "": session['username'] = "******" #print("testing") logger.error("In 'get_photo_info' function, error occurred") if username == "UnitTester": try: photoInfo = Photo.objects(staffName=username) return photoInfo except Exception as e: #print("error: ", e) logger.error("In 'get_photo_info' function, error occurred: ", e) return None if not counterPart: if utils.check_if_staff(username, False): try: photoInfo = Photo.objects(date=date_, time=time_, staffName=username) except Exception as e: #print("error: ", e) logger.error("In 'get_photo_info' function, error occurred: ", e) return None else: try: photoInfo = TenantPhoto.objects(date=date_, time=time_, tenantName=username) except Exception as e: #print("error: ", e) logger.error("In 'get_photo_info' function, error occurred: ", e) return None else: if utils.check_if_staff(username, False): try: photoInfo = TenantPhoto.objects(staffName=username, date=date_, time=time_) except Exception as e: #print("error: ", e) logger.error("In 'get_photo_info' function, error occurred: ", e) return None else: try: photoInfo = Photo.objects(tenantName=username, date=date_, time=time_) except Exception as e: #print("error: ", e) logger.error("In 'get_photo_info' function, error occurred: ", e) return None return photoInfo
def get_data(tableName): mapping = { 'User': 0, 'Photo': 1, 'TenantPhoto': 2, 'PhotoNotification': 3, 'PhotoNotificationFromTenant': 4, 'Audit_FB': 5, 'Audit_non_FB': 6, 'Covid_Compliance': 7 } case = mapping.get(tableName, -1) res = None if case == 0: res = User.objects() elif case == 1: res = Photo.objects() elif case == 2: res = TenantPhoto.objects() elif case == 3: res = PhotoNotification.objects() elif case == 4: res = PhotoNotificationFromTenant.objects() elif case == 5: res = Audit_FB.objects() elif case == 6: res = Audit_non_FB.objects() elif case == 7: res = Covid_Compliance.objects() if case != -1: logger.info("admin selected table: %s", tableName)
def clean_db_post_test(self): testPhotos = Photo.objects(staffName="UnitTester") testPhotos.delete()