{"action":"created","comment":{"url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/comments/50604063","id":50604063,"diff_hunk":"@@ -97,3 +97,70 @@ def save(self, **kwargs):\n \n     class Meta:\n         app_label = 'api'\n+\n+\n+class Condition(models.Model):\n+    CRITERIA_TYPES = (\n+        ('EQUALS', 'EQUALS'),\n+        ('GREATER', 'GREATER'),\n+        ('LESSER', 'LESSER')\n+    )\n+\n+    NODE_TYPES = (\n+        ('AND', 'AND'),\n+        ('OR', 'OR'),\n+        ('NOT', 'NOT'),\n+        ('CRITERIA', 'CRITERIA')\n+    )\n+\n+    parent = models.ForeignKey('self', on_delete=models.CASCADE, related_name='children', blank=True, null=True)\n+    element = models.ForeignKey(Element, blank=True, null=True)\n+    node_type = models.CharField(max_length=8, choices=NODE_TYPES, null=True, blank=True)\n+    criteria_type = models.CharField(max_length=8, choices=CRITERIA_TYPES, null=True, blank=True)\n+    value = models.TextField(blank=True, null=True)\n+    last_modified = models.DateTimeField(auto_now=True)\n+    created = models.DateTimeField(auto_now_add=True)\n+\n+    def save(self, **kwargs):\n+        if self.node_type:\n+            if (self.node_type, self.node_type) not in self.NODE_TYPES:\n+                raise IntegrityError('Invalid condition node type')\n+\n+            if self.node_type is 'CRITERIA':\n+                if not self.criteria_type:\n+                    raise IntegrityError('\"CRITERIA\" node type requires a criteria type')\n+\n+                if (self.criteria_type, self.criteria_type) not in self.CRITERIA_TYPES:\n+                    raise IntegrityError('Invalid criteria_type for condition')\n+\n+                # if self.parent.count() is not 0:\n+                #     raise IntegrityError('CRITERIA can not have child nodes')\n+\n+                if not self.element:\n+                    raise IntegrityError('CRITERIA must have an element')\n+\n+            # if self.node_type is 'NOT' and len(self.children) is not 1:","path":"src-django/api/models.py","position":46,"original_position":46,"commit_id":"70124a822dfd501dbb47e5565894b761696bfe51","original_commit_id":"70124a822dfd501dbb47e5565894b761696bfe51","user":{"login":"Trinovantes","id":458691,"avatar_url":"https://avatars.githubusercontent.com/u/458691?v=3","gravatar_id":"","url":"https://api.github.com/users/Trinovantes","html_url":"https://github.com/Trinovantes","followers_url":"https://api.github.com/users/Trinovantes/followers","following_url":"https://api.github.com/users/Trinovantes/following{/other_user}","gists_url":"https://api.github.com/users/Trinovantes/gists{/gist_id}","starred_url":"https://api.github.com/users/Trinovantes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Trinovantes/subscriptions","organizations_url":"https://api.github.com/users/Trinovantes/orgs","repos_url":"https://api.github.com/users/Trinovantes/repos","events_url":"https://api.github.com/users/Trinovantes/events{/privacy}","received_events_url":"https://api.github.com/users/Trinovantes/received_events","type":"User","site_admin":false},"body":"should also perform some assertion checks to make sure `AND` `OR` `NOT` nodes do not have any unnecessary fields filled","created_at":"2016-01-22T23:14:13Z","updated_at":"2016-01-22T23:14:13Z","html_url":"https://github.com/SanaMobile/sana.protocol_builder/pull/299#discussion_r50604063","pull_request_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299","_links":{"self":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/comments/50604063"},"html":{"href":"https://github.com/SanaMobile/sana.protocol_builder/pull/299#discussion_r50604063"},"pull_request":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299"}}},"pull_request":{"url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299","id":56953481,"html_url":"https://github.com/SanaMobile/sana.protocol_builder/pull/299","diff_url":"https://github.com/SanaMobile/sana.protocol_builder/pull/299.diff","patch_url":"https://github.com/SanaMobile/sana.protocol_builder/pull/299.patch","issue_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/299","number":299,"state":"open","locked":false,"title":"Create models for conditional logic","user":{"login":"Kapin","id":995382,"avatar_url":"https://avatars.githubusercontent.com/u/995382?v=3","gravatar_id":"","url":"https://api.github.com/users/Kapin","html_url":"https://github.com/Kapin","followers_url":"https://api.github.com/users/Kapin/followers","following_url":"https://api.github.com/users/Kapin/following{/other_user}","gists_url":"https://api.github.com/users/Kapin/gists{/gist_id}","starred_url":"https://api.github.com/users/Kapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kapin/subscriptions","organizations_url":"https://api.github.com/users/Kapin/orgs","repos_url":"https://api.github.com/users/Kapin/repos","events_url":"https://api.github.com/users/Kapin/events{/privacy}","received_events_url":"https://api.github.com/users/Kapin/received_events","type":"User","site_admin":false},"body":"I'm not sure the best way to get the children # validation working because django doesn't allow for OneToMany as a specifier. Otherwise, this should be the basis for conditonals","created_at":"2016-01-22T22:59:34Z","updated_at":"2016-01-22T23:14:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e5955289282dc5df327528ff04a7a9e979c7de3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299/commits","review_comments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299/comments","review_comment_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/299/comments","statuses_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/statuses/70124a822dfd501dbb47e5565894b761696bfe51","head":{"label":"SanaMobile:josh/condition_models","ref":"josh/condition_models","sha":"70124a822dfd501dbb47e5565894b761696bfe51","user":{"login":"SanaMobile","id":6865473,"avatar_url":"https://avatars.githubusercontent.com/u/6865473?v=3","gravatar_id":"","url":"https://api.github.com/users/SanaMobile","html_url":"https://github.com/SanaMobile","followers_url":"https://api.github.com/users/SanaMobile/followers","following_url":"https://api.github.com/users/SanaMobile/following{/other_user}","gists_url":"https://api.github.com/users/SanaMobile/gists{/gist_id}","starred_url":"https://api.github.com/users/SanaMobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SanaMobile/subscriptions","organizations_url":"https://api.github.com/users/SanaMobile/orgs","repos_url":"https://api.github.com/users/SanaMobile/repos","events_url":"https://api.github.com/users/SanaMobile/events{/privacy}","received_events_url":"https://api.github.com/users/SanaMobile/received_events","type":"Organization","site_admin":false},"repo":{"id":25015456,"name":"sana.protocol_builder","full_name":"SanaMobile/sana.protocol_builder","owner":{"login":"SanaMobile","id":6865473,"avatar_url":"https://avatars.githubusercontent.com/u/6865473?v=3","gravatar_id":"","url":"https://api.github.com/users/SanaMobile","html_url":"https://github.com/SanaMobile","followers_url":"https://api.github.com/users/SanaMobile/followers","following_url":"https://api.github.com/users/SanaMobile/following{/other_user}","gists_url":"https://api.github.com/users/SanaMobile/gists{/gist_id}","starred_url":"https://api.github.com/users/SanaMobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SanaMobile/subscriptions","organizations_url":"https://api.github.com/users/SanaMobile/orgs","repos_url":"https://api.github.com/users/SanaMobile/repos","events_url":"https://api.github.com/users/SanaMobile/events{/privacy}","received_events_url":"https://api.github.com/users/SanaMobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SanaMobile/sana.protocol_builder","description":"Web app for building Sana Protocols","fork":false,"url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder","forks_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/forks","keys_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/teams","hooks_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/hooks","issue_events_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/events{/number}","events_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/events","assignees_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/assignees{/user}","branches_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/branches{/branch}","tags_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/tags","blobs_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/statuses/{sha}","languages_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/languages","stargazers_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/stargazers","contributors_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/contributors","subscribers_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/subscribers","subscription_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/subscription","commits_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/contents/{+path}","compare_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/merges","archive_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/downloads","issues_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues{/number}","pulls_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls{/number}","milestones_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/milestones{/number}","notifications_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/labels{/name}","releases_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/releases{/id}","deployments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/deployments","created_at":"2014-10-10T01:24:58Z","updated_at":"2016-01-21T07:31:15Z","pushed_at":"2016-01-22T22:59:34Z","git_url":"git://github.com/SanaMobile/sana.protocol_builder.git","ssh_url":"git@github.com:SanaMobile/sana.protocol_builder.git","clone_url":"https://github.com/SanaMobile/sana.protocol_builder.git","svn_url":"https://github.com/SanaMobile/sana.protocol_builder","homepage":"","size":5530,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":32,"forks":3,"open_issues":32,"watchers":4,"default_branch":"master"}},"base":{"label":"SanaMobile:master","ref":"master","sha":"7af5e0b7ede2fa4c746afc7acdce5c03ec422649","user":{"login":"SanaMobile","id":6865473,"avatar_url":"https://avatars.githubusercontent.com/u/6865473?v=3","gravatar_id":"","url":"https://api.github.com/users/SanaMobile","html_url":"https://github.com/SanaMobile","followers_url":"https://api.github.com/users/SanaMobile/followers","following_url":"https://api.github.com/users/SanaMobile/following{/other_user}","gists_url":"https://api.github.com/users/SanaMobile/gists{/gist_id}","starred_url":"https://api.github.com/users/SanaMobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SanaMobile/subscriptions","organizations_url":"https://api.github.com/users/SanaMobile/orgs","repos_url":"https://api.github.com/users/SanaMobile/repos","events_url":"https://api.github.com/users/SanaMobile/events{/privacy}","received_events_url":"https://api.github.com/users/SanaMobile/received_events","type":"Organization","site_admin":false},"repo":{"id":25015456,"name":"sana.protocol_builder","full_name":"SanaMobile/sana.protocol_builder","owner":{"login":"SanaMobile","id":6865473,"avatar_url":"https://avatars.githubusercontent.com/u/6865473?v=3","gravatar_id":"","url":"https://api.github.com/users/SanaMobile","html_url":"https://github.com/SanaMobile","followers_url":"https://api.github.com/users/SanaMobile/followers","following_url":"https://api.github.com/users/SanaMobile/following{/other_user}","gists_url":"https://api.github.com/users/SanaMobile/gists{/gist_id}","starred_url":"https://api.github.com/users/SanaMobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SanaMobile/subscriptions","organizations_url":"https://api.github.com/users/SanaMobile/orgs","repos_url":"https://api.github.com/users/SanaMobile/repos","events_url":"https://api.github.com/users/SanaMobile/events{/privacy}","received_events_url":"https://api.github.com/users/SanaMobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SanaMobile/sana.protocol_builder","description":"Web app for building Sana Protocols","fork":false,"url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder","forks_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/forks","keys_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/teams","hooks_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/hooks","issue_events_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/events{/number}","events_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/events","assignees_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/assignees{/user}","branches_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/branches{/branch}","tags_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/tags","blobs_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/statuses/{sha}","languages_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/languages","stargazers_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/stargazers","contributors_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/contributors","subscribers_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/subscribers","subscription_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/subscription","commits_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/contents/{+path}","compare_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/merges","archive_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/downloads","issues_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues{/number}","pulls_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls{/number}","milestones_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/milestones{/number}","notifications_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/labels{/name}","releases_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/releases{/id}","deployments_url":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/deployments","created_at":"2014-10-10T01:24:58Z","updated_at":"2016-01-21T07:31:15Z","pushed_at":"2016-01-22T22:59:34Z","git_url":"git://github.com/SanaMobile/sana.protocol_builder.git","ssh_url":"git@github.com:SanaMobile/sana.protocol_builder.git","clone_url":"https://github.com/SanaMobile/sana.protocol_builder.git","svn_url":"https://github.com/SanaMobile/sana.protocol_builder","homepage":"","size":5530,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":32,"forks":3,"open_issues":32,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299"},"html":{"href":"https://github.com/SanaMobile/sana.protocol_builder/pull/299"},"issue":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/299"},"comments":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/issues/299/comments"},"review_comments":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299/comments"},"review_comment":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/pulls/299/commits"},"statuses":{"href":"https://api.github.com/repos/SanaMobile/sana.protocol_builder/statuses/70124a822dfd501dbb47e5565894b761696bfe51"}}}}