def get(self, request, app_name): context = {} context['app'] = app_name context['form'] = SetEnvForm(initial=context) response = self.get_envs(request, app_name) if response.status_code == 200: envs = response.content.split('\n') context['envs'] = envs return TemplateResponse(request, self.template, context) return TemplateResponse(request, self.template, {'errors': response.content})
def post(self, request, app_name): context = {} context['app'] = app_name response = self.get_envs(request, app_name) if response.status_code == 200: form = SetEnvForm(request.POST) context['form'] = form if not form.is_valid(): return TemplateResponse(request, self.template, context) envs = response.content.split('\n') envs.append(request.POST['env']) context['envs'] = envs response = self.set_env(request, app_name, form) if response.status_code == 200: context['message'] = response.content return TemplateResponse(request, self.template, context) context['errors'] = response.content return TemplateResponse(request, self.template, context)