{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-notifications/pulls/comments/24109221","id":24109221,"diff_hunk":"@@ -0,0 +1,256 @@\n+\"\"\"\n+Django ORM models to support the Notification Store SQL backend\n+\"\"\"\n+\n+from django.db import models\n+\n+from model_utils.models import TimeStampedModel\n+\n+from edx_notifications.base_data import DictField\n+\n+from edx_notifications.data import (\n+    NotificationMessage,\n+    NotificationType,\n+    NotificationUserMap,\n+)\n+from edx_notifications import const\n+\n+\n+class SQLNotificationType(models.Model):\n+    \"\"\"\n+    Notification Type information\n+    \"\"\"\n+\n+    # the internal name is the primary key\n+    name = models.CharField(primary_key=True, max_length=255)\n+\n+    class Meta(object):\n+        \"\"\"\n+        ORM metadata about this class\n+        \"\"\"\n+        app_label = 'edx_notifications'  # since we have this models.py file not in the root app directory\n+        db_table = 'edx_notifications_notificationtype'\n+\n+    def to_data_object(self, options=None):  # pylint: disable=unused-argument\n+        \"\"\"\n+        Generate a NotificationType data object\n+        \"\"\"\n+\n+        return NotificationType(\n+            name=self.name,\n+        )\n+\n+    @classmethod\n+    def from_data_object(cls, msg_type):\n+        \"\"\"\n+        create a ORM model object from a NotificationType\n+        \"\"\"\n+\n+        obj = SQLNotificationType()\n+        obj.load_from_data_object(msg_type)\n+        return obj\n+\n+    def load_from_data_object(self, msg_type):\n+        \"\"\"\n+        Hydrate ourselves from a passed in user_map\n+        \"\"\"\n+\n+        self.name = msg_type.name  # pylint: disable=attribute-defined-outside-init","path":"edx_notifications/stores/sql/models.py","position":58,"original_position":58,"commit_id":"90b47f7a737e306a52cb97603e28fb6deef13f82","original_commit_id":"0a1727596a63c40359e988cf4e55815283166e0c","user":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?v=3","gravatar_id":"","url":"https://api.github.com/users/cpennington","html_url":"https://github.com/cpennington","followers_url":"https://api.github.com/users/cpennington/followers","following_url":"https://api.github.com/users/cpennington/following{/other_user}","gists_url":"https://api.github.com/users/cpennington/gists{/gist_id}","starred_url":"https://api.github.com/users/cpennington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpennington/subscriptions","organizations_url":"https://api.github.com/users/cpennington/orgs","repos_url":"https://api.github.com/users/cpennington/repos","events_url":"https://api.github.com/users/cpennington/events{/privacy}","received_events_url":"https://api.github.com/users/cpennington/received_events","type":"User","site_admin":false},"body":"Why two methods for this? Why not just instantiate the `SQLNotificationType` with a name directly?","created_at":"2015-02-04T19:04:23Z","updated_at":"2015-02-04T19:04:23Z","html_url":"https://github.com/edx/edx-notifications/pull/12#discussion_r24109221","pull_request_url":"https://api.github.com/repos/edx/edx-notifications/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/comments/24109221"},"html":{"href":"https://github.com/edx/edx-notifications/pull/12#discussion_r24109221"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-notifications/pulls/12","id":28491511,"html_url":"https://github.com/edx/edx-notifications/pull/12","diff_url":"https://github.com/edx/edx-notifications/pull/12.diff","patch_url":"https://github.com/edx/edx-notifications/pull/12.patch","issue_url":"https://api.github.com/repos/edx/edx-notifications/issues/12","number":12,"state":"open","locked":false,"title":"For ongoing reviews/comments","user":{"login":"chrisndodge","id":2362917,"avatar_url":"https://avatars.githubusercontent.com/u/2362917?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisndodge","html_url":"https://github.com/chrisndodge","followers_url":"https://api.github.com/users/chrisndodge/followers","following_url":"https://api.github.com/users/chrisndodge/following{/other_user}","gists_url":"https://api.github.com/users/chrisndodge/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisndodge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisndodge/subscriptions","organizations_url":"https://api.github.com/users/chrisndodge/orgs","repos_url":"https://api.github.com/users/chrisndodge/repos","events_url":"https://api.github.com/users/chrisndodge/events{/privacy}","received_events_url":"https://api.github.com/users/chrisndodge/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-02T18:37:25Z","updated_at":"2015-02-04T19:04:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0ac7cfcb31298225b1102a5e2db9cfc662229c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-notifications/pulls/12/commits","review_comments_url":"https://api.github.com/repos/edx/edx-notifications/pulls/12/comments","review_comment_url":"https://api.github.com/repos/edx/edx-notifications/pulls/comments/{number}","comments_url":"https://api.github.com/repos/edx/edx-notifications/issues/12/comments","statuses_url":"https://api.github.com/repos/edx/edx-notifications/statuses/90b47f7a737e306a52cb97603e28fb6deef13f82","head":{"label":"edx:master","ref":"master","sha":"90b47f7a737e306a52cb97603e28fb6deef13f82","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":29154572,"name":"edx-notifications","full_name":"edx/edx-notifications","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/edx-notifications","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-notifications","forks_url":"https://api.github.com/repos/edx/edx-notifications/forks","keys_url":"https://api.github.com/repos/edx/edx-notifications/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-notifications/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-notifications/teams","hooks_url":"https://api.github.com/repos/edx/edx-notifications/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-notifications/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-notifications/events","assignees_url":"https://api.github.com/repos/edx/edx-notifications/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-notifications/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-notifications/tags","blobs_url":"https://api.github.com/repos/edx/edx-notifications/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-notifications/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-notifications/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-notifications/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-notifications/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-notifications/languages","stargazers_url":"https://api.github.com/repos/edx/edx-notifications/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-notifications/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-notifications/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-notifications/subscription","commits_url":"https://api.github.com/repos/edx/edx-notifications/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-notifications/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-notifications/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-notifications/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-notifications/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-notifications/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-notifications/merges","archive_url":"https://api.github.com/repos/edx/edx-notifications/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-notifications/downloads","issues_url":"https://api.github.com/repos/edx/edx-notifications/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-notifications/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-notifications/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-notifications/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-notifications/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-notifications/releases{/id}","created_at":"2015-01-12T20:11:02Z","updated_at":"2015-02-04T18:34:31Z","pushed_at":"2015-02-04T18:34:30Z","git_url":"git://github.com/edx/edx-notifications.git","ssh_url":"git@github.com:edx/edx-notifications.git","clone_url":"https://github.com/edx/edx-notifications.git","svn_url":"https://github.com/edx/edx-notifications","homepage":null,"size":1036,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"edx:empty","ref":"empty","sha":"e624fc3ebe0bc444ac580f93c4c971b4bb878c95","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":29154572,"name":"edx-notifications","full_name":"edx/edx-notifications","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/edx-notifications","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-notifications","forks_url":"https://api.github.com/repos/edx/edx-notifications/forks","keys_url":"https://api.github.com/repos/edx/edx-notifications/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-notifications/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-notifications/teams","hooks_url":"https://api.github.com/repos/edx/edx-notifications/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-notifications/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-notifications/events","assignees_url":"https://api.github.com/repos/edx/edx-notifications/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-notifications/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-notifications/tags","blobs_url":"https://api.github.com/repos/edx/edx-notifications/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-notifications/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-notifications/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-notifications/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-notifications/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-notifications/languages","stargazers_url":"https://api.github.com/repos/edx/edx-notifications/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-notifications/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-notifications/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-notifications/subscription","commits_url":"https://api.github.com/repos/edx/edx-notifications/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-notifications/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-notifications/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-notifications/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-notifications/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-notifications/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-notifications/merges","archive_url":"https://api.github.com/repos/edx/edx-notifications/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-notifications/downloads","issues_url":"https://api.github.com/repos/edx/edx-notifications/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-notifications/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-notifications/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-notifications/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-notifications/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-notifications/releases{/id}","created_at":"2015-01-12T20:11:02Z","updated_at":"2015-02-04T18:34:31Z","pushed_at":"2015-02-04T18:34:30Z","git_url":"git://github.com/edx/edx-notifications.git","ssh_url":"git@github.com:edx/edx-notifications.git","clone_url":"https://github.com/edx/edx-notifications.git","svn_url":"https://github.com/edx/edx-notifications","homepage":null,"size":1036,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/12"},"html":{"href":"https://github.com/edx/edx-notifications/pull/12"},"issue":{"href":"https://api.github.com/repos/edx/edx-notifications/issues/12"},"comments":{"href":"https://api.github.com/repos/edx/edx-notifications/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-notifications/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-notifications/statuses/90b47f7a737e306a52cb97603e28fb6deef13f82"}}}}