{"action":"created","issue":{"url":"https://api.github.com/repos/swcarpentry/amy/issues/909","repository_url":"https://api.github.com/repos/swcarpentry/amy","labels_url":"https://api.github.com/repos/swcarpentry/amy/issues/909/labels{/name}","comments_url":"https://api.github.com/repos/swcarpentry/amy/issues/909/comments","events_url":"https://api.github.com/repos/swcarpentry/amy/issues/909/events","html_url":"https://github.com/swcarpentry/amy/issues/909","id":166312271,"number":909,"title":"Delete views respond to GET requests instead of POST ones","user":{"login":"chrismedrela","id":1645996,"avatar_url":"https://avatars.githubusercontent.com/u/1645996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismedrela","html_url":"https://github.com/chrismedrela","followers_url":"https://api.github.com/users/chrismedrela/followers","following_url":"https://api.github.com/users/chrismedrela/following{/other_user}","gists_url":"https://api.github.com/users/chrismedrela/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismedrela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismedrela/subscriptions","organizations_url":"https://api.github.com/users/chrismedrela/orgs","repos_url":"https://api.github.com/users/chrismedrela/repos","events_url":"https://api.github.com/users/chrismedrela/events{/privacy}","received_events_url":"https://api.github.com/users/chrismedrela/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swcarpentry/amy/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-19T11:51:11Z","updated_at":"2016-07-19T12:09:45Z","closed_at":"2016-07-19T12:09:44Z","body":"This can be easily fixed with a better version of DeleteContextView that I'll introduce in `instructor-training` branch:\r\n```python\r\nclass DeleteViewContext(DeleteView):\r\n    \"\"\"\r\n    Class-based view for deleting objects that extends default template context\r\n    by adding proper page title.\r\n\r\n    GET requests are redirected to appropriate update views.\r\n\r\n    ProtectedErrors are handled.\r\n    \"\"\"\r\n    success_message = '{} was deleted successfully.'\r\n\r\n    def delete(self, request, *args, **kwargs):\r\n        '''Workaround for https://code.djangoproject.com/ticket/21926'''\r\n        messages.success(\r\n            self.request,\r\n            self.success_message.format(self.get_object())\r\n        )\r\n        try:\r\n            return super().delete(request, *args, **kwargs)\r\n        except ProtectedError as e:\r\n            return failed_to_delete(self.request, self.object,\r\n                                    e.protected_objects)\r\n\r\n    def get(self, request, *args, **kwargs):\r\n        self.object = self.get_object()\r\n        return redirect(self.object.get_absolute_url())\r\n```\r\nMost of the function-based deletion views can be converted to class-based."},"comment":{"url":"https://api.github.com/repos/swcarpentry/amy/issues/comments/233612862","html_url":"https://github.com/swcarpentry/amy/issues/909#issuecomment-233612862","issue_url":"https://api.github.com/repos/swcarpentry/amy/issues/909","id":233612862,"user":{"login":"chrismedrela","id":1645996,"avatar_url":"https://avatars.githubusercontent.com/u/1645996?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismedrela","html_url":"https://github.com/chrismedrela","followers_url":"https://api.github.com/users/chrismedrela/followers","following_url":"https://api.github.com/users/chrismedrela/following{/other_user}","gists_url":"https://api.github.com/users/chrismedrela/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismedrela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismedrela/subscriptions","organizations_url":"https://api.github.com/users/chrismedrela/orgs","repos_url":"https://api.github.com/users/chrismedrela/repos","events_url":"https://api.github.com/users/chrismedrela/events{/privacy}","received_events_url":"https://api.github.com/users/chrismedrela/received_events","type":"User","site_admin":false},"created_at":"2016-07-19T12:09:44Z","updated_at":"2016-07-19T12:09:44Z","body":"That's right, it's duplicate ==> closing."}}
{"actor":{"display_login":"chrismedrela"}}