def add(self): if not self.request.user.has_perm('testcases.add_bug'): response = {'rc': 1, 'response': 'Permission denied'} return self.ajax_response(response=response) bug_id = request.GET.get('bug_id') bug_system_id = request.GET.get('bug_system_id') try: validate_bug_id(bug_id, bug_system_id) except ValidationError as e: return self.ajax_response({'rc': 1, 'response': str(e)}) bz_external_track = True if request.GET.get( 'bz_external_track', False) else False try: tcr.add_bug(bug_id=bug_id, bug_system_id=bug_system_id, bz_external_track=bz_external_track) except Exception as e: msg = str(e) if str(e) else 'Failed to add bug %s' % bug_id return self.ajax_response({'rc': 1, 'response': msg}) self.default_ajax_response.update({ 'run_bug_count': self.get_run_bug_count(), 'caserun_bugs_count': self.case_run.get_bugs_count(), }) return self.ajax_response()
def add(self): if not self.request.user.has_perm('testcases.add_bug'): return JsonResponse({'rc': 1, 'response': 'Permission denied'}) bug_id = request.GET.get('bug_id') bug_system_id = request.GET.get('bug_system_id') try: validate_bug_id(bug_id, bug_system_id) except ValidationError as error: return JsonResponse({'rc': 1, 'response': str(error)}) bz_external_track = True if request.GET.get( 'bz_external_track', False) else False try: test_case_run.add_bug(bug_id=bug_id, bug_system_id=bug_system_id, bz_external_track=bz_external_track) except ValueError as error: msg = str(error) if str( error) else 'Failed to add bug %s' % bug_id return JsonResponse({'rc': 1, 'response': msg}) return JsonResponse({ 'rc': 0, 'response': 'ok', 'run_bug_count': self.get_run_bug_count(), 'caserun_bugs_count': self.case_run.get_bugs_count() })
def update_bugs_to_caseruns(request): ''' Add one or more bugs to or remove that from\n one or more caserun at a time. ''' data, error = clean_bug_form(request) if error: return say_no(error) runs = TestCaseRun.objects.filter(pk__in=data['runs']) bug_system_id = data['bug_system_id'] bug_ids = data['bugs'] try: validate_bug_id(bug_ids, bug_system_id) except ValidationError as e: return say_no(str(e)) bz_external_track = data['bz_external_track'] action = data['action'] try: if action == "add": for run in runs: for bug_id in bug_ids: run.add_bug(bug_id=bug_id, bug_system_id=bug_system_id, bz_external_track=bz_external_track) else: bugs = Bug.objects.filter(bug_id__in=bug_ids) for run in runs: for bug in bugs: if bug.case_run_id == run.pk: run.remove_bug(bug.bug_id, run.pk) except Exception as e: return say_no(str(e)) return say_yes()
def update_bugs_to_caseruns(request): """ Add one or more bugs to or remove that from\n one or more caserun at a time. """ data, error = clean_bug_form(request) if error: return say_no(error) runs = TestCaseRun.objects.filter(pk__in=data['runs']) bug_system_id = data['bug_system_id'] bug_ids = data['bugs'] try: validate_bug_id(bug_ids, bug_system_id) except NitrateException as e: return say_no(str(e)) bz_external_track = data['bz_external_track'] action = data['action'] try: if action == "add": for run in runs: for bug_id in bug_ids: run.add_bug(bug_id=bug_id, bug_system_id=bug_system_id, bz_external_track=bz_external_track) else: bugs = TestCaseBug.objects.filter(bug_id__in=bug_ids) for run in runs: for bug in bugs: if bug.case_run_id == run.pk: run.remove_bug(bug.bug_id, run.pk) except Exception as e: return say_no(str(e)) return say_yes()
def clean(self): super(CaseBugForm, self).clean() bug_id = self.cleaned_data['bug_id'] bug_system_id = self.cleaned_data['bug_system'].pk validate_bug_id(bug_id, bug_system_id) return self.cleaned_data
def clean(self): super(CaseBugForm, self).clean() bug_id = self.cleaned_data['bug_id'] bug_system_id = self.cleaned_data['bug_system'].pk try: validate_bug_id(bug_id, bug_system_id) except NitrateException as e: raise forms.ValidationError(str(e)) return self.cleaned_data
def clean(self): super(AttachCaseRunBugForm, self).clean() bug_id = self.cleaned_data['bug_id'] bug_system_id = self.cleaned_data['bug_system_id'] try: validate_bug_id(bug_id, bug_system_id) except NitrateException as e: raise ValidationError(str(e)) return self.cleaned_data
def update_bugs_to_caseruns(request): """ Add one or more bugs to or remove that from\n one or more caserun at a time. """ data, error = clean_bug_form(request) if error: return say_no(error) runs = TestExecution.objects.filter(pk__in=data['runs']) bug_system_id = data['bug_system_id'] bug_ids = data['bugs'] try: validate_bug_id(bug_ids, bug_system_id) except ValidationError as error: return say_no(str(error)) bz_external_track = data['bz_external_track'] action = data['action'] try: if action == "add": for run in runs: for bug_id in bug_ids: # todo: TestExecution.add_bug and TestCase.add_bug should be removed # once this function has been refactored to JSON RPC run.add_bug(bug_id=bug_id, bug_system_id=bug_system_id, bz_external_track=bz_external_track) else: bugs = Bug.objects.filter(bug_id__in=bug_ids) for run in runs: for bug in bugs: if bug.case_run_id == run.pk: run.remove_bug(bug.bug_id, run.pk) except ValueError as error: return say_no(str(error)) return say_yes()