{"action":"created","issue":{"url":"https://api.github.com/repos/stephenmcd/cartridge/issues/82","labels_url":"https://api.github.com/repos/stephenmcd/cartridge/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/stephenmcd/cartridge/issues/82/comments","events_url":"https://api.github.com/repos/stephenmcd/cartridge/issues/82/events","html_url":"https://github.com/stephenmcd/cartridge/pull/82","id":9792913,"number":82,"title":"Refactor product view to use class-based views","user":{"login":"lorin","id":446305,"avatar_url":"https://avatars.githubusercontent.com/u/446305?v=3","gravatar_id":"","url":"https://api.github.com/users/lorin","html_url":"https://github.com/lorin","followers_url":"https://api.github.com/users/lorin/followers","following_url":"https://api.github.com/users/lorin/following{/other_user}","gists_url":"https://api.github.com/users/lorin/gists{/gist_id}","starred_url":"https://api.github.com/users/lorin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorin/subscriptions","organizations_url":"https://api.github.com/users/lorin/orgs","repos_url":"https://api.github.com/users/lorin/repos","events_url":"https://api.github.com/users/lorin/events{/privacy}","received_events_url":"https://api.github.com/users/lorin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2013-01-09T04:00:46Z","updated_at":"2015-03-10T14:25:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/stephenmcd/cartridge/pulls/82","html_url":"https://github.com/stephenmcd/cartridge/pull/82","diff_url":"https://github.com/stephenmcd/cartridge/pull/82.diff","patch_url":"https://github.com/stephenmcd/cartridge/pull/82.patch"},"body":"This is a proposed refactoring of the product view code to use class-based views. There are no (intentional) changes to the behavior in this commit.\r\n\r\nThe motivation behind this proposed change is to make it easier for users to extend Cartridge through subclassing. For example, if a Cartridge user wanted to be able to use a subclass of the Product class in their template, all they would need to do is:\r\n 1. subclass the proposed `ProductDetailView` class\r\n 2. Override the `get_object` method in the subclass\r\n 3. Add a line in *urls.py* in their project to use the subclass\r\n\r\nThe main change is replacing the `cartridge.shop.views.product` function  with the `cartridge.shop.views.ProductDetailView` class.\r\n\r\nThe only other required change was the `cartridge.shop.forms.AddProductForm.__init__` method. This change was needed because the Django class-based views don't support passing a positional argument to the `__init__` method of forms. However, the Django class-based view code automatically passes `request.POST` as an argument called `data` (see `django.views.generic.edit.FormMixin.get_form_kwargs`), so I made a change to use `data` as a keyword argument as a replacement for the positional argument."},"comment":{"url":"https://api.github.com/repos/stephenmcd/cartridge/issues/comments/78063633","html_url":"https://github.com/stephenmcd/cartridge/pull/82#issuecomment-78063633","issue_url":"https://api.github.com/repos/stephenmcd/cartridge/issues/82","id":78063633,"user":{"login":"auvipy","id":6212603,"avatar_url":"https://avatars.githubusercontent.com/u/6212603?v=3","gravatar_id":"","url":"https://api.github.com/users/auvipy","html_url":"https://github.com/auvipy","followers_url":"https://api.github.com/users/auvipy/followers","following_url":"https://api.github.com/users/auvipy/following{/other_user}","gists_url":"https://api.github.com/users/auvipy/gists{/gist_id}","starred_url":"https://api.github.com/users/auvipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auvipy/subscriptions","organizations_url":"https://api.github.com/users/auvipy/orgs","repos_url":"https://api.github.com/users/auvipy/repos","events_url":"https://api.github.com/users/auvipy/events{/privacy}","received_events_url":"https://api.github.com/users/auvipy/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T14:25:54Z","updated_at":"2015-03-10T14:25:54Z","body":"@stephenmcd I do belive using cbv and cbgv is good where necessary. and we can use fbv or cbv both where necessary. even django core team is planning to upgrade its contrib apps using cbv where necessary :)\r\n"}}