def post(self, request, *args, **kwargs): try: jira_auth = get_jira_auth_from_request(request) except (ApiError, JiraTenant.DoesNotExist): self.get_response("error.html") if request.user.is_anonymous(): return self.get_response("signin.html") orgs = self.request.user.get_orgs() form = JiraConfigForm([(o.id, o.name) for o in orgs], self.request.POST) if form.is_valid(): try: org = orgs.get(id=form.cleaned_data["organization"]) except Organization.DoesNotExist: errors = form._errors.setdefault("organization", ErrorList()) errors.append("Invalid organization") else: jira_auth.update(organization=org) context = self.get_context() context.update({"is_configured": jira_auth.is_configured(), "form": form}) return self.get_response("config.html", context)
def post(self, request: Request, *args: Any, **kwargs: Any) -> HttpResponse: try: jira_auth = self.get_jira_auth() except CATCHABLE_AUTH_ERRORS: return self.get_response("error.html") if request.user.is_anonymous: return self.get_response("signin.html") orgs = self.request.user.get_orgs() form = JiraConfigForm([(o.id, o.name) for o in orgs], self.request.POST) if form.is_valid(): try: org = orgs.get(id=form.cleaned_data["organization"]) except Organization.DoesNotExist: errors = form._errors.setdefault("organization", ErrorList()) errors.append("Invalid organization") else: jira_auth.update(organization=org) bind_organization_context(org) context = self.get_context() context.update({ "is_configured": jira_auth.is_configured(), "form": form }) return self.get_response("config.html", context)
def post(self, request, *args, **kwargs): try: jira_auth = get_jira_auth_from_request(request) except (JIRAError, JiraTenant.DoesNotExist): self.get_response('error.html') if request.user.is_anonymous(): return self.get_response('signin.html') orgs = self.request.user.get_orgs() form = JiraConfigForm([(o.id, o.name) for o in orgs], self.request.POST) if form.is_valid(): try: org = orgs.get(id=form.cleaned_data['organization']) except Organization.DoesNotExist: errors = form._errors.setdefault('organization', ErrorList()) errors.append('Invalid organization') else: jira_auth.update(organization=org) context = self.get_context() context.update({ 'is_configured': jira_auth.is_configured(), 'form': form }) return self.get_response('config.html', context)
def get(self, request, *args, **kwargs): try: jira_auth = self.get_jira_auth() except (ApiError, JiraTenant.DoesNotExist): return self.get_response("error.html") if request.user.is_anonymous(): return self.get_response("signin.html") org = jira_auth.organization form_context = None if org: form_context = {"organization": org.id} form = JiraConfigForm([(o.id, o.name) for o in request.user.get_orgs()], form_context) context = self.get_context() context.update({"is_configured": jira_auth.is_configured(), "form": form}) return self.get_response("config.html", context)
def get(self, request, *args, **kwargs): try: jira_auth = self.get_jira_auth() except (JIRAError, JiraTenant.DoesNotExist): return self.get_response('error.html') if request.user.is_anonymous(): return self.get_response('signin.html') org = jira_auth.organization form_context = None if org: form_context = {'organization': org.id} form = JiraConfigForm([(o.id, o.name) for o in request.user.get_orgs()], form_context) context = self.get_context() context.update({ 'is_configured': jira_auth.is_configured(), 'form': form }) return self.get_response('config.html', context)
def get(self, request: Request, *args: Any, **kwargs: Any) -> HttpResponse: try: jira_auth = self.get_jira_auth() except CATCHABLE_AUTH_ERRORS: return self.get_response("error.html") if request.user.is_anonymous: return self.get_response("signin.html") org = jira_auth.organization form_context = None if org: form_context = {"organization": org.id} bind_organization_context(org) form = JiraConfigForm([(o.id, o.name) for o in request.user.get_orgs()], form_context) context = self.get_context() context.update({ "is_configured": jira_auth.is_configured(), "form": form }) return self.get_response("config.html", context)