def new_jira(request): if request.method == 'POST': jform = JIRAForm(request.POST, instance=JIRA_Conf()) if jform.is_valid(): try: jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') jira_password = jform.cleaned_data.get('password') # Instantiate JIRA instance for validating url, username and password JIRA(server=jira_server, basic_auth=(jira_username, jira_password)) new_j = jform.save(commit=False) new_j.url = jira_server new_j.save() messages.add_message(request, messages.SUCCESS, 'JIRA Configuration Successfully Created.', extra_tags='alert-success') return HttpResponseRedirect(reverse('jira', )) except Exception: messages.add_message(request, messages.ERROR, 'Unable to authenticate. Please check the URL, username, and password.', extra_tags='alert-danger') else: jform = JIRAForm() add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) return render(request, 'dojo/new_jira.html', {'jform': jform})
def new_jira(request): if request.method == 'POST': jform = JIRAForm(request.POST, instance=JIRA_Instance()) if jform.is_valid(): jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') jira_password = jform.cleaned_data.get('password') logger.debug('calling get_jira_connection_raw') jira = jira_helper.get_jira_connection_raw(jira_server, jira_username, jira_password) new_j = jform.save(commit=False) new_j.url = jira_server new_j.save() messages.add_message(request, messages.SUCCESS, 'JIRA Configuration Successfully Created.', extra_tags='alert-success') create_notification( event='other', title='New addition of JIRA: %s' % jform.cleaned_data.get('configuration_name'), description='JIRA "%s" was added by %s' % (jform.cleaned_data.get('configuration_name'), request.user), url=request.build_absolute_uri(reverse('jira')), ) return HttpResponseRedirect(reverse('jira', )) else: jform = JIRAForm() add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) return render(request, 'dojo/new_jira.html', {'jform': jform})
def new_jira(request): if request.method == 'POST': jform = JIRAForm(request.POST, instance=JIRA_Conf()) if jform.is_valid(): try: jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') jira_password = jform.cleaned_data.get('password') # Instantiate JIRA instance for validating url, username and password JIRA(server=jira_server, basic_auth=(jira_username, jira_password)) new_j = jform.save(commit=False) new_j.url = jira_server new_j.save() messages.add_message( request, messages.SUCCESS, 'JIRA Configuration Successfully Created.', extra_tags='alert-success') return HttpResponseRedirect(reverse('jira', )) except Exception: messages.add_message( request, messages.ERROR, 'Unable to authenticate. Please check the URL, username, and password.', extra_tags='alert-danger') else: jform = JIRAForm() add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) return render(request, 'dojo/new_jira.html', {'jform': jform})
def edit_jira(request, jid): jira = JIRA_Conf.objects.get(pk=jid) jira_password_from_db = jira.password if request.method == 'POST': jform = JIRAForm(request.POST, instance=jira) if jform.is_valid(): try: jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') if jform.cleaned_data.get('password'): jira_password = jform.cleaned_data.get('password') else: # on edit the password is optional jira_password = jira_password_from_db # Instantiate JIRA instance for validating url, username and password JIRA(server=jira_server, basic_auth=(jira_username, jira_password), options={"verify": settings.JIRA_SSL_VERIFY}) new_j = jform.save(commit=False) new_j.url = jira_server # on edit the password is optional new_j.password = jira_password new_j.save() messages.add_message(request, messages.SUCCESS, 'JIRA Configuration Successfully Saved.', extra_tags='alert-success') create_notification( event='other', title='Edit of JIRA: %s' % jform.cleaned_data.get('configuration_name'), description='JIRA "%s" was edited by %s' % (jform.cleaned_data.get('configuration_name'), request.user), url=request.build_absolute_uri(reverse('jira')), ) return HttpResponseRedirect(reverse('jira', )) except Exception as e: logger.error(e) messages.add_message( request, messages.ERROR, 'Unable to authenticate. Please check the URL, username, and password.', extra_tags='alert-danger') else: jform = JIRAForm(instance=jira) add_breadcrumb(title="Edit JIRA Configuration", top_level=False, request=request) return render(request, 'dojo/edit_jira.html', { 'jform': jform, })
def edit_jira(request, jid): jira = JIRA_Instance.objects.get(pk=jid) jira_password_from_db = jira.password if request.method == 'POST': jform = JIRAForm(request.POST, instance=jira) if jform.is_valid(): jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') if jform.cleaned_data.get('password'): jira_password = jform.cleaned_data.get('password') else: # on edit the password is optional jira_password = jira_password_from_db jira = jira_helper.get_jira_connection_raw(jira_server, jira_username, jira_password, validate=True) new_j = jform.save(commit=False) new_j.url = jira_server # on edit the password is optional new_j.password = jira_password new_j.save() messages.add_message(request, messages.SUCCESS, 'JIRA Configuration Successfully Saved.', extra_tags='alert-success') create_notification( event='other', title='Edit of JIRA: %s' % jform.cleaned_data.get('configuration_name'), description='JIRA "%s" was edited by %s' % (jform.cleaned_data.get('configuration_name'), request.user), url=request.build_absolute_uri(reverse('jira')), ) return HttpResponseRedirect(reverse('jira', )) else: jform = JIRAForm(instance=jira) add_breadcrumb(title="Edit JIRA Configuration", top_level=False, request=request) return render(request, 'dojo/edit_jira.html', { 'jform': jform, })
def new_jira(request): if request.method == 'POST': if '_Express' in request.POST: return HttpResponseRedirect(reverse('express_jira', )) jform = JIRAForm(request.POST, instance=JIRA_Conf()) if jform.is_valid(): try: jira_server = jform.cleaned_data.get('url').rstrip('/') jira_username = jform.cleaned_data.get('username') jira_password = jform.cleaned_data.get('password') # Instantiate JIRA instance for validating url, username and password JIRA(server=jira_server, basic_auth=(jira_username, jira_password), options={"verify": settings.JIRA_SSL_VERIFY}) new_j = jform.save(commit=False) new_j.url = jira_server new_j.save() messages.add_message( request, messages.SUCCESS, 'JIRA Configuration Successfully Created.', extra_tags='alert-success') create_notification( event='other', title='New addition of JIRA: %s' % jform.cleaned_data.get('configuration_name'), description='JIRA "%s" was added by %s' % (jform.cleaned_data.get('configuration_name'), request.user), url=request.build_absolute_uri(reverse('jira')), ) return HttpResponseRedirect(reverse('jira', )) except Exception as e: logger.exception(e) messages.add_message( request, messages.ERROR, 'Unable to authenticate. Please check the URL, username, and password.', extra_tags='alert-danger') else: jform = JIRAForm() add_breadcrumb(title="New Jira Configuration", top_level=False, request=request) return render(request, 'dojo/new_jira.html', {'jform': jform})