{"action":"created","comment":{"url":"https://api.github.com/repos/edx/ecommerce/pulls/comments/90406045","pull_request_review_id":10913060,"id":90406045,"diff_hunk":"@@ -111,6 +111,33 @@ class Range(AbstractRange):\n         null=True\n     )\n \n+    def save(self, *args, **kwargs):\n+        self.clean()\n+        super(Range, self).save(*args, **kwargs)  # pylint: disable=bad-super-call\n+\n+    def clean(self):\n+        \"\"\" Validation for model fields. \"\"\"\n+        if self.catalog and (self.catalog_query or self.course_seat_types):\n+            logger.exception(\n+                'Failed to create Coupon. Catalog and dynamic catalog fields may not be set in the same coupon.'\n+            )\n+            raise ValidationError(_('Catalog and dynamic catalog fields may not be set in the same coupon.'))\n+\n+        # If catalog is not set catalog_query and course_seat_types must be set\n+        if not self.catalog:\n+            if not self.catalog_query:\n+                logger.exception('Failed to create Coupon. Multiple courses coupon must have catalog_query.')\n+                raise ValidationError(\n+                    _('Multiple courses coupon can not be created without catalog_query parameter.')\n+                )\n+            if not self.course_seat_types:\n+                logger.exception(\n+                    'Failed to create Coupon. Multiple courses coupon must have course_seat_types.'\n+                )\n+                raise ValidationError(\n+                    _('Multiple courses coupon can not be created without course_seat_types parameter.')\n+                )\n+","path":"ecommerce/extensions/offer/models.py","position":30,"original_position":30,"commit_id":"476a968ca1832d500ae79d537a4a3f3dfb2e8ba0","original_commit_id":"476a968ca1832d500ae79d537a4a3f3dfb2e8ba0","user":{"login":"marjev","id":6833568,"avatar_url":"https://avatars.githubusercontent.com/u/6833568?v=3","gravatar_id":"","url":"https://api.github.com/users/marjev","html_url":"https://github.com/marjev","followers_url":"https://api.github.com/users/marjev/followers","following_url":"https://api.github.com/users/marjev/following{/other_user}","gists_url":"https://api.github.com/users/marjev/gists{/gist_id}","starred_url":"https://api.github.com/users/marjev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marjev/subscriptions","organizations_url":"https://api.github.com/users/marjev/orgs","repos_url":"https://api.github.com/users/marjev/repos","events_url":"https://api.github.com/users/marjev/events{/privacy}","received_events_url":"https://api.github.com/users/marjev/received_events","type":"User","site_admin":false},"body":"All of these messages are mentioning `Coupon` even though this is a Range validation.\r\nDo we want to couple the two that tightly?\r\n\r\nIn future, we or someone from the Open Source Community might decide to create a Range for a new type of products (that aren't Coupons).\r\n\r\nI think we shouldn't make an assumption that Ranges will be created solely for the purpose of Coupon creation.","created_at":"2016-12-01T09:06:17Z","updated_at":"2016-12-01T09:24:43Z","html_url":"https://github.com/edx/ecommerce/pull/1032#discussion_r90406045","pull_request_url":"https://api.github.com/repos/edx/ecommerce/pulls/1032","_links":{"self":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/comments/90406045"},"html":{"href":"https://github.com/edx/ecommerce/pull/1032#discussion_r90406045"},"pull_request":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/1032"}}},"pull_request":{"url":"https://api.github.com/repos/edx/ecommerce/pulls/1032","id":95491467,"html_url":"https://github.com/edx/ecommerce/pull/1032","diff_url":"https://github.com/edx/ecommerce/pull/1032.diff","patch_url":"https://github.com/edx/ecommerce/pull/1032.patch","issue_url":"https://api.github.com/repos/edx/ecommerce/issues/1032","number":1032,"state":"open","locked":false,"title":"[SOL-2140] Add Backend Validation for Catalog Query","user":{"login":"iivic","id":16685686,"avatar_url":"https://avatars.githubusercontent.com/u/16685686?v=3","gravatar_id":"","url":"https://api.github.com/users/iivic","html_url":"https://github.com/iivic","followers_url":"https://api.github.com/users/iivic/followers","following_url":"https://api.github.com/users/iivic/following{/other_user}","gists_url":"https://api.github.com/users/iivic/gists{/gist_id}","starred_url":"https://api.github.com/users/iivic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iivic/subscriptions","organizations_url":"https://api.github.com/users/iivic/orgs","repos_url":"https://api.github.com/users/iivic/repos","events_url":"https://api.github.com/users/iivic/events{/privacy}","received_events_url":"https://api.github.com/users/iivic/received_events","type":"User","site_admin":false},"body":"@marjev @vkaracic @mjfrey I made the backend validation for `catalog_query` parameter and since it's tied closely with the `course_seat_types` field some validation is included for this field as well but there will be a separate PR for it with more validation.\r\nhttps://openedx.atlassian.net/browse/SOL-2140","created_at":"2016-11-28T12:40:22Z","updated_at":"2016-12-01T09:24:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8f6c0429b512c24131c6bb44d784fb82f1618ec","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/ecommerce/pulls/1032/commits","review_comments_url":"https://api.github.com/repos/edx/ecommerce/pulls/1032/comments","review_comment_url":"https://api.github.com/repos/edx/ecommerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/ecommerce/issues/1032/comments","statuses_url":"https://api.github.com/repos/edx/ecommerce/statuses/476a968ca1832d500ae79d537a4a3f3dfb2e8ba0","head":{"label":"edx:iivic/SOL-2140","ref":"iivic/SOL-2140","sha":"476a968ca1832d500ae79d537a4a3f3dfb2e8ba0","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":30175039,"name":"ecommerce","full_name":"edx/ecommerce","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/ecommerce","description":"Django application used to manage edX's product catalog and handle orders for those products.","fork":false,"url":"https://api.github.com/repos/edx/ecommerce","forks_url":"https://api.github.com/repos/edx/ecommerce/forks","keys_url":"https://api.github.com/repos/edx/ecommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/ecommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/ecommerce/teams","hooks_url":"https://api.github.com/repos/edx/ecommerce/hooks","issue_events_url":"https://api.github.com/repos/edx/ecommerce/issues/events{/number}","events_url":"https://api.github.com/repos/edx/ecommerce/events","assignees_url":"https://api.github.com/repos/edx/ecommerce/assignees{/user}","branches_url":"https://api.github.com/repos/edx/ecommerce/branches{/branch}","tags_url":"https://api.github.com/repos/edx/ecommerce/tags","blobs_url":"https://api.github.com/repos/edx/ecommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/ecommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/ecommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/ecommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/ecommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/ecommerce/languages","stargazers_url":"https://api.github.com/repos/edx/ecommerce/stargazers","contributors_url":"https://api.github.com/repos/edx/ecommerce/contributors","subscribers_url":"https://api.github.com/repos/edx/ecommerce/subscribers","subscription_url":"https://api.github.com/repos/edx/ecommerce/subscription","commits_url":"https://api.github.com/repos/edx/ecommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/ecommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/ecommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/ecommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/ecommerce/contents/{+path}","compare_url":"https://api.github.com/repos/edx/ecommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/ecommerce/merges","archive_url":"https://api.github.com/repos/edx/ecommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/ecommerce/downloads","issues_url":"https://api.github.com/repos/edx/ecommerce/issues{/number}","pulls_url":"https://api.github.com/repos/edx/ecommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/ecommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/ecommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/ecommerce/labels{/name}","releases_url":"https://api.github.com/repos/edx/ecommerce/releases{/id}","deployments_url":"https://api.github.com/repos/edx/ecommerce/deployments","created_at":"2015-02-02T06:55:15Z","updated_at":"2016-11-13T18:33:43Z","pushed_at":"2016-11-30T21:06:53Z","git_url":"git://github.com/edx/ecommerce.git","ssh_url":"git@github.com:edx/ecommerce.git","clone_url":"https://github.com/edx/ecommerce.git","svn_url":"https://github.com/edx/ecommerce","homepage":"","size":13442,"stargazers_count":43,"watchers_count":43,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":19,"forks":48,"open_issues":19,"watchers":43,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"325c3efe057393e3305995350379f282fedc15f3","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":30175039,"name":"ecommerce","full_name":"edx/ecommerce","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/ecommerce","description":"Django application used to manage edX's product catalog and handle orders for those products.","fork":false,"url":"https://api.github.com/repos/edx/ecommerce","forks_url":"https://api.github.com/repos/edx/ecommerce/forks","keys_url":"https://api.github.com/repos/edx/ecommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/ecommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/ecommerce/teams","hooks_url":"https://api.github.com/repos/edx/ecommerce/hooks","issue_events_url":"https://api.github.com/repos/edx/ecommerce/issues/events{/number}","events_url":"https://api.github.com/repos/edx/ecommerce/events","assignees_url":"https://api.github.com/repos/edx/ecommerce/assignees{/user}","branches_url":"https://api.github.com/repos/edx/ecommerce/branches{/branch}","tags_url":"https://api.github.com/repos/edx/ecommerce/tags","blobs_url":"https://api.github.com/repos/edx/ecommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/ecommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/ecommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/ecommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/ecommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/ecommerce/languages","stargazers_url":"https://api.github.com/repos/edx/ecommerce/stargazers","contributors_url":"https://api.github.com/repos/edx/ecommerce/contributors","subscribers_url":"https://api.github.com/repos/edx/ecommerce/subscribers","subscription_url":"https://api.github.com/repos/edx/ecommerce/subscription","commits_url":"https://api.github.com/repos/edx/ecommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/ecommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/ecommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/ecommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/ecommerce/contents/{+path}","compare_url":"https://api.github.com/repos/edx/ecommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/ecommerce/merges","archive_url":"https://api.github.com/repos/edx/ecommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/ecommerce/downloads","issues_url":"https://api.github.com/repos/edx/ecommerce/issues{/number}","pulls_url":"https://api.github.com/repos/edx/ecommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/ecommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/ecommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/ecommerce/labels{/name}","releases_url":"https://api.github.com/repos/edx/ecommerce/releases{/id}","deployments_url":"https://api.github.com/repos/edx/ecommerce/deployments","created_at":"2015-02-02T06:55:15Z","updated_at":"2016-11-13T18:33:43Z","pushed_at":"2016-11-30T21:06:53Z","git_url":"git://github.com/edx/ecommerce.git","ssh_url":"git@github.com:edx/ecommerce.git","clone_url":"https://github.com/edx/ecommerce.git","svn_url":"https://github.com/edx/ecommerce","homepage":"","size":13442,"stargazers_count":43,"watchers_count":43,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":19,"forks":48,"open_issues":19,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/1032"},"html":{"href":"https://github.com/edx/ecommerce/pull/1032"},"issue":{"href":"https://api.github.com/repos/edx/ecommerce/issues/1032"},"comments":{"href":"https://api.github.com/repos/edx/ecommerce/issues/1032/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/1032/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/ecommerce/pulls/1032/commits"},"statuses":{"href":"https://api.github.com/repos/edx/ecommerce/statuses/476a968ca1832d500ae79d537a4a3f3dfb2e8ba0"}}}}
{"actor":{"display_login":"marjev"}}