def _get_tags_repository(self, name_repository): token = DashboardView._get_token_user(self) headers = HEADERS_REPOSITORY_TOPIC url = URL_REPOSITORY_TOPIC.format(self.request.user, name_repository, token) response = requests.get(url, headers=headers) tags = self._format_tags_to_string(response.json()) return tags
def form_valid(self, form): form_data = form.cleaned_data token = DashboardView._get_token_user(self) data_json = self.format_tags_to_json(form_data) headers = HEADERS_REPOSITORY_TOPIC url = URL_REPOSITORY_TOPIC.format(self.request.user, form_data['name_repository'], token) response = requests.put(url, headers=headers, data=data_json) if response.status_code == 200: messages.success(self.request, 'Tags alteradas com sucesso!') return redirect('dashboard') else: messages.error(self.request, 'Ocorreu um erro ao alterar a tag!') return render(self.request, 'edit_tag.html', {'form': form})