def jira_setting(request): if request.method == 'POST': jira_url = request.POST.get('jira_url') jira_username = request.POST.get('jira_username') jira_password = request.POST.get('jira_password') username = signing.dumps(jira_username) password = signing.dumps(jira_password) save_data = jirasetting(jira_server=jira_url, jira_username=username, jira_password=password) save_data.save() return render(request, 'jira_setting_form.html')
def post(self, request): all_jira_settings = jirasetting.objects.filter() jira_server = "" for jira in all_jira_settings: jira_server = jira.jira_server setting_id = uuid.uuid4() jira_url = request.POST.get("jira_url") jira_username = request.POST.get("jira_username") jira_password = request.POST.get("jira_password") j_username = signing.dumps(jira_username) password = signing.dumps(jira_password) setting_dat = SettingsDb( setting_id=setting_id, setting_scanner="Jira", ) setting_dat.save() save_data = jirasetting( setting_id=setting_id, jira_server=jira_url, jira_username=j_username, jira_password=password, ) save_data.save() options = {"server": jira_server} try: jira_ser = JIRA(options, basic_auth=(jira_username, jira_password), max_retries=0) jira_projects = jira_ser.projects() print(len(jira_projects)) jira_info = True SettingsDb.objects.filter(setting_id=setting_id).update( setting_status=jira_info) except Exception as e: print(e) jira_info = False SettingsDb.objects.filter(setting_id=setting_id).update( setting_status=jira_info) return HttpResponseRedirect(reverse("archerysettings:settings"))
def jira_setting(request): """ :param request: :return: """ username = request.user.username all_jira_settings = jirasetting.objects.filter(username=username) for jira in all_jira_settings: global jira_url, j_username, password jira_url = jira.jira_server j_username = signing.loads(jira.jira_username) password = signing.loads(jira.jira_password) jira_server = jira_url jira_username = j_username jira_password = password if request.method == 'POST': jira_url = request.POST.get('jira_url') jira_username = request.POST.get('jira_username') jira_password = request.POST.get('jira_password') j_username = signing.dumps(jira_username) password = signing.dumps(jira_password) save_data = jirasetting(username=username, jira_server=jira_url, jira_username=j_username, jira_password=password) save_data.save() return HttpResponseRedirect(reverse('webscanners:setting')) return render( request, 'jira_setting_form.html', { 'jira_server': jira_server, 'jira_username': jira_username, 'jira_password': jira_password, })