def diff_remove(hash_session, diff_id): logTraffic(CLOUD_URL, endpoint='/private/<hash_session>/diff/remove/<diff_id>') if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session) current_user = access_resp[1] if current_user is not None: try: logAccess(CLOUD_URL, 'cloud', '/private/<hash_session>/diff/remove/<diff_id>') diff = DiffModel.objects.with_id(diff_id) except: print(str(traceback.print_exc())) return fk.Response(str(traceback.print_exc()), status.HTTP_500_INTERNAL_SERVER_ERROR) if diff is None: return fk.Response('Unable to find this diff.', status.HTTP_404_NOT_FOUND) else: if diff.sender == current_user or diff.targeted == current_user: diff.delete() logStat(deleted=True, diff=diff) return cloud_response( 200, 'Deletion succeeded', 'The diff %s was succesfully deleted.' % diff_id) else: return fk.Response('Unauthorized action on this diff.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Unauthorized action on this diff.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)
def project_remove(hash_session, project_id): logTraffic(CLOUD_URL, endpoint='/private/<hash_session>/project/remove/<project_id>') if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session) current_user = access_resp[1] if current_user is not None: logAccess(CLOUD_URL, 'cloud', '/private/<hash_session>/project/remove/<project_id>') project = ProjectModel.objects.with_id(project_id) if project == None or (project != None and project.owner != current_user): return fk.Response('Unauthorized action on this project.', status.HTTP_401_UNAUTHORIZED) else: storage_manager.delete_project_files(project, logStat) project.delete() logStat(deleted=True, project=project) return cloud_response( 200, 'Deletion succeeded', 'The project %s was succesfully deleted.' % project_id) else: return fk.Response('Unauthorized action on this project.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)
def diff_remove(diff_id): logTraffic(CLOUD_URL, endpoint='/private/diff/remove/<diff_id>') hash_session = basicAuthSession(fk.request) if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session, ACC_SEC, CNT_SEC) current_user = access_resp[1] if current_user is not None: try: logAccess(CLOUD_URL, 'cloud', '/private/diff/remove/<diff_id>') diff = DiffModel.objects.with_id(diff_id) except: print(str(traceback.print_exc())) return fk.Response(str(traceback.print_exc()), status.HTTP_500_INTERNAL_SERVER_ERROR) if diff is None: return fk.Response('Unable to find this diff.', status.HTTP_404_NOT_FOUND) else: if diff.sender == current_user or diff.targeted == current_user or current_user.group == "admin": diff.delete() logStat(deleted=True, diff=diff) return cloud_response(200, 'Deletion succeeded', 'The diff %s was succesfully deleted.'%diff_id) else: return fk.Response('Unauthorized action on this diff.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Unauthorized action on this diff.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)
def record_remove(record_id): logTraffic(CLOUD_URL, endpoint='/private/record/remove/<record_id>') hash_session = basicAuthSession(fk.request) if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session, ACC_SEC, CNT_SEC) current_user = access_resp[1] if current_user is None: return fk.Response('Unauthorized action on this record.', status.HTTP_401_UNAUTHORIZED) else: try: logAccess(CLOUD_URL, 'cloud', '/private/record/remove/<record_id>') record = RecordModel.objects.with_id(record_id) except: print(str(traceback.print_exc())) if record is None: return fk.Response('Unable to find this record.', status.HTTP_404_NOT_FOUND) return fk.redirect('{0}:{1}/error/?code=204'.format( VIEW_HOST, VIEW_PORT)) else: if record.project.owner == current_user or current_user.group == "admin": storage_manager.delete_record_files(record, logStat) logStat(deleted=True, record=record) env_id = None if record.environment: env_id = str(record.environment.id) record.delete() if env_id: try: record.project.history.remove(env_id) record.project.save() except: pass return cloud_response( 200, 'Deletion succeeded', 'The record %s was succesfully deleted.' % record_id) else: return fk.Response('Unauthorized action on this record.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)
def project_remove(project_id): logTraffic(CLOUD_URL, endpoint='/private/project/remove/<project_id>') hash_session = basicAuthSession(fk.request) if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session, ACC_SEC, CNT_SEC) current_user = access_resp[1] if current_user is not None: logAccess(CLOUD_URL, 'cloud', '/private/project/remove/<project_id>') project = ProjectModel.objects.with_id(project_id) if project == None or (project != None and project.owner != current_user and current_user.group != "admin"): return fk.Response('Unauthorized action on this project.', status.HTTP_401_UNAUTHORIZED) else: storage_manager.delete_project_files(project, logStat) project.delete() logStat(deleted=True, project=project) return cloud_response(200, 'Deletion succeeded', 'The project %s was succesfully deleted.'%project_id) else: return fk.Response('Unauthorized action on this project.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)
def record_remove(record_id): logTraffic(CLOUD_URL, endpoint='/private/record/remove/<record_id>') hash_session = basicAuthSession(fk.request) if fk.request.method in ['GET', 'DELETE']: access_resp = access_manager.check_cloud(hash_session, ACC_SEC, CNT_SEC) current_user = access_resp[1] if current_user is None: return fk.Response('Unauthorized action on this record.', status.HTTP_401_UNAUTHORIZED) else: try: logAccess(CLOUD_URL, 'cloud', '/private/record/remove/<record_id>') record = RecordModel.objects.with_id(record_id) except: print(str(traceback.print_exc())) if record is None: return fk.Response('Unable to find this record.', status.HTTP_404_NOT_FOUND) return fk.redirect('{0}:{1}/error/?code=204'.format(VIEW_HOST, VIEW_PORT)) else: if record.project.owner == current_user or current_user.group == "admin": storage_manager.delete_record_files(record, logStat) logStat(deleted=True, record=record) env_id = None if record.environment: env_id = str(record.environment.id) record.delete() if env_id: try: record.project.history.remove(env_id) record.project.save() except: pass return cloud_response(200, 'Deletion succeeded', 'The record %s was succesfully deleted.'%record_id) else: return fk.Response('Unauthorized action on this record.', status.HTTP_401_UNAUTHORIZED) else: return fk.Response('Endpoint does not support this HTTP method.', status.HTTP_405_METHOD_NOT_ALLOWED)