def test_header_edit(request): """ Edit Test Header :param request: :return: """ if request.method == 'POST': test_header_id = request.POST.get('editTestHeaderId', '') test_header_name = request.POST.get('editTestHeaderName', '') test_header = get_object_or_404(Module, pk=test_header_id) if 'test_header_save' in request.POST: test_headers = Module.objects.filter(project=None).exclude( pk=test_header.id) try: if check_testheader_duplicate(test_header_name, test_headers): messages.error(request, 'Test Header name duplicated') else: test_header.name = test_header_name test_header.save() messages.success(request, 'Test Header is saved.') except ValueError as e: messages.error(request, str(e)) elif 'test_header_delete' in request.POST: test_header.delete() context = context_project_dashboard(request) context['last_tab'] = 'test_headers' return render(request, 'projects/project_dashboard.html', context)
def test_header_new(request): """ Add new Test Header as Module which project is null :param request: :return: """ if request.method == 'POST': form = TestHeaderForm(request.POST) if form.is_valid(): test_header = form.save(commit=False) test_headers = Module.objects.filter(project=None).exclude( pk=test_header.id) if check_testheader_duplicate(test_header.name, test_headers): messages.error(request, 'Test Header name duplicated') else: test_header = form.save() messages.success( request, 'Test Header {0} is added'.format(test_header.name)) else: messages.error(request, form.errors) context = context_project_dashboard(request) context['last_tab'] = 'test_headers' return render(request, 'projects/project_dashboard.html', context)
def testrail_configuration_delete(request, testrail_id): testrail = get_object_or_404(TestRailConfiguration, pk=testrail_id) testrail.delete() context = context_project_dashboard(request) context['last_tab'] = 'test_rails' return render(request, 'projects/project_dashboard.html', context)
def language_new(request): if request.method == 'POST': form = LanguageNewForm(request.POST) if form.is_valid(): language = form.save() else: messages.error(request, form.errors) context = context_project_dashboard(request) context['last_tab'] = 'languages' return render(request, 'projects/project_dashboard.html', context)
def project_dashboard(request): """ View of project dashboard, include project config, testheader config, testrail config, node type config, edge type config :param request: :return: """ context = context_project_dashboard(request) if context['project']: return render(request, 'projects/project_dashboard.html', context) else: return redirect('graphs:projects_for_selection')
def node_type_new(request): """ Add new NodeType from apps/graphs :param request: :return: """ if request.method == 'POST': form = NodeTypeNewForm(request.POST) node_or_edge_type_new(request, form) context = context_project_dashboard(request) context['last_tab'] = 'node_types' return render(request, 'projects/project_dashboard.html', context)
def node_type_edit(request): """ Edit NodeType from apps/graphs :param request: :return: """ type_id = request.POST.get('editNodeTypeId', '') node_type = get_object_or_404(NodeType, pk=type_id) if request.method == 'POST': node_or_edge_type_edit(request, node_type) context = context_project_dashboard(request) context['last_tab'] = 'node_types' return render(request, 'projects/project_dashboard.html', context)
def language_edit(request): if request.method == 'POST': language_id = request.POST.get('editLanguageId', '') project_id = request.POST.get('editLanguageProject', '') name = request.POST.get('editLanguageName', '') root_path = request.POST.get('editLanguageRootPath', '') language = get_object_or_404(Language, pk=language_id) language.project_id = project_id language.name = name language.root_path = root_path language.save() context = context_project_dashboard(request) context['last_tab'] = 'languages' return render(request, 'projects/project_dashboard.html', context)
def testrail_configuration_update(request, testrail_id): suites = [] testrail = get_object_or_404(TestRailConfiguration, pk=testrail_id) client = APIClient(testrail.instance.host) client.user = testrail.instance.username client.password = testrail.instance.password testrail_find_suites = client.send_get('get_suites/' + str(testrail.project_id)) for suite in testrail_find_suites: suites.append(suite['name']) if testrail.test_suite != suites: testrail.test_suite = suites testrail.save() context = context_project_dashboard(request) context['last_tab'] = 'test_rails' return render(request, 'projects/project_dashboard.html', context)
def testrail_configuration_new(request): if request.method == 'GET': context = {'form': TestrailConfigurationForm()} return render(request, 'testcases/tc_testrails_new.html', context) elif request.method == 'POST': # print(request.POST) instance = get_object_or_404(TestRailInstance, username='******') testrail_projects = get_projects_from_testrail(instance) form = TestrailConfigurationForm(request.POST) if form.is_valid(): suites = [] testrail_new = form.save(commit=False) testrail_find = next(item for item in testrail_projects if item['name'] == testrail_new.project_name) testrail_new.project_id = testrail_find['id'] client = APIClient(testrail_new.instance.host) client.user = testrail_new.instance.username client.password = testrail_new.instance.password testrail_find_suites = client.send_get( 'get_suites/' + str(testrail_new.project_id)) for suite in testrail_find_suites: suites.append(suite['name']) testrail_new.test_suite = suites testrail_new.save() else: messages.error(request, form.errors) context = context_project_dashboard(request) context['last_tab'] = 'test_rails' return render(request, 'projects/project_dashboard.html', context)