{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/153313773","pull_request_review_id":79301489,"id":153313773,"diff_hunk":"@@ -1,10 +1,45 @@\n import uuid as uuid_tools\n+from datetime import datetime\n \n from django.conf import settings\n+from django.contrib.sites.models import Site\n from django.db import models\n+\n+from entitlements.helpers import is_entitlement_expired\n from model_utils.models import TimeStampedModel\n \n \n+class CourseEntitlementManager(models.Manager):\n+    def get_queryset(self):\n+        queryset = super(CourseEntitlementManager, self).get_queryset()\n+        for entitlement in queryset:","path":"common/djangoapps/entitlements/models.py","position":15,"original_position":15,"commit_id":"edfd81403a62235fe635b525fea4fe9c8ecc7380","original_commit_id":"edfd81403a62235fe635b525fea4fe9c8ecc7380","user":{"login":"amangano-edx","id":24230895,"avatar_url":"https://avatars2.githubusercontent.com/u/24230895?v=4","gravatar_id":"","url":"https://api.github.com/users/amangano-edx","html_url":"https://github.com/amangano-edx","followers_url":"https://api.github.com/users/amangano-edx/followers","following_url":"https://api.github.com/users/amangano-edx/following{/other_user}","gists_url":"https://api.github.com/users/amangano-edx/gists{/gist_id}","starred_url":"https://api.github.com/users/amangano-edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amangano-edx/subscriptions","organizations_url":"https://api.github.com/users/amangano-edx/orgs","repos_url":"https://api.github.com/users/amangano-edx/repos","events_url":"https://api.github.com/users/amangano-edx/events{/privacy}","received_events_url":"https://api.github.com/users/amangano-edx/received_events","type":"User","site_admin":false},"body":"Will this result in us iterating over the the entire table with every query?","created_at":"2017-11-27T20:30:15Z","updated_at":"2017-11-27T20:30:15Z","html_url":"https://github.com/edx/edx-platform/pull/16627#discussion_r153313773","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/16627","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/153313773"},"html":{"href":"https://github.com/edx/edx-platform/pull/16627#discussion_r153313773"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/16627"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/16627","id":153667748,"html_url":"https://github.com/edx/edx-platform/pull/16627","diff_url":"https://github.com/edx/edx-platform/pull/16627.diff","patch_url":"https://github.com/edx/edx-platform/pull/16627.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/16627","number":16627,"state":"open","locked":false,"title":"LEARNER-2983: Adds policy for entitlements","user":{"login":"jlajoie","id":1559107,"avatar_url":"https://avatars3.githubusercontent.com/u/1559107?v=4","gravatar_id":"","url":"https://api.github.com/users/jlajoie","html_url":"https://github.com/jlajoie","followers_url":"https://api.github.com/users/jlajoie/followers","following_url":"https://api.github.com/users/jlajoie/following{/other_user}","gists_url":"https://api.github.com/users/jlajoie/gists{/gist_id}","starred_url":"https://api.github.com/users/jlajoie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlajoie/subscriptions","organizations_url":"https://api.github.com/users/jlajoie/orgs","repos_url":"https://api.github.com/users/jlajoie/repos","events_url":"https://api.github.com/users/jlajoie/events{/privacy}","received_events_url":"https://api.github.com/users/jlajoie/received_events","type":"User","site_admin":false},"body":"### Description\r\n\r\n[LEARNER-2983](https://openedx.atlassian.net/browse/LEARNER-2983)\r\n\r\nOPEN QUESTION: How do we want to handle default policies? Right now we should have a policy tied to a Django site that is sent along when creating an entitlement (e.x. example.com would link the example.com policy to the entitlement), but if an entitlement does _not_ have a policy set it uses defaults specified in lms/envs/common.py. Would we rather remove this, and do a \"get_or_create\" if a policy does not exist for a Site?\r\n\r\nRelies on a CourseEntitlementPolicy to set a regain, refund, and expiration period in days before expiring courses. Provides helper methods to detect the other functionality, as well as one for getting number of days until expiration. Override the queryset for the Entitlements Model to be dependent on policy, expiring specific policies before returning the queryset. Also adds tests for the helpers and expiration testing in the api views.\r\n\r\nFYI: @edx/learner-helio @edx/learner-heart ","created_at":"2017-11-20T16:02:50Z","updated_at":"2017-11-27T20:30:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e52fc8f0f809c0a0090ad07db8fe6426eeab71b6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mjfrey","id":2236013,"avatar_url":"https://avatars0.githubusercontent.com/u/2236013?v=4","gravatar_id":"","url":"https://api.github.com/users/mjfrey","html_url":"https://github.com/mjfrey","followers_url":"https://api.github.com/users/mjfrey/followers","following_url":"https://api.github.com/users/mjfrey/following{/other_user}","gists_url":"https://api.github.com/users/mjfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/mjfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjfrey/subscriptions","organizations_url":"https://api.github.com/users/mjfrey/orgs","repos_url":"https://api.github.com/users/mjfrey/repos","events_url":"https://api.github.com/users/mjfrey/events{/privacy}","received_events_url":"https://api.github.com/users/mjfrey/received_events","type":"User","site_admin":false},{"login":"staubina","id":2854941,"avatar_url":"https://avatars2.githubusercontent.com/u/2854941?v=4","gravatar_id":"","url":"https://api.github.com/users/staubina","html_url":"https://github.com/staubina","followers_url":"https://api.github.com/users/staubina/followers","following_url":"https://api.github.com/users/staubina/following{/other_user}","gists_url":"https://api.github.com/users/staubina/gists{/gist_id}","starred_url":"https://api.github.com/users/staubina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staubina/subscriptions","organizations_url":"https://api.github.com/users/staubina/orgs","repos_url":"https://api.github.com/users/staubina/repos","events_url":"https://api.github.com/users/staubina/events{/privacy}","received_events_url":"https://api.github.com/users/staubina/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/16627/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/16627/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/16627/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/edfd81403a62235fe635b525fea4fe9c8ecc7380","head":{"label":"edx:jlajoie/LEARNER-2983","ref":"jlajoie/LEARNER-2983","sha":"edfd81403a62235fe635b525fea4fe9c8ecc7380","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2017-11-27T05:53:37Z","pushed_at":"2017-11-27T20:01:51Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":862643,"stargazers_count":3411,"watchers_count":3411,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1938,"mirror_url":null,"archived":false,"open_issues_count":209,"forks":1938,"open_issues":209,"watchers":3411,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"ffc838250d3540c3b480d2e4230d945db6499d54","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2017-11-27T05:53:37Z","pushed_at":"2017-11-27T20:01:51Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":862643,"stargazers_count":3411,"watchers_count":3411,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1938,"mirror_url":null,"archived":false,"open_issues_count":209,"forks":1938,"open_issues":209,"watchers":3411,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/16627"},"html":{"href":"https://github.com/edx/edx-platform/pull/16627"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/16627"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/16627/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/16627/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/16627/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/edfd81403a62235fe635b525fea4fe9c8ecc7380"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"amangano-edx"}}