{"action":"created","comment":{"url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/comments/49184141","id":49184141,"diff_hunk":"@@ -332,3 +360,98 @@ def copy(self, name=None):\n              action=form_buttons.add)\n         flash.assert_success_message('Role \"%s\" was saved' % new_role.name)\n         return new_role\n+\n+\n+class Tenant(Updateable, Pretty):\n+    \"\"\"Kudos to mfalesni\"\"\"\n+\n+    save_changes = form_buttons.FormButton(\"Save changes\")\n+    tenant_form = Form(\n+        fields=[\n+            ('name', Input('name')),\n+            ('description', Input('description'))\n+        ])\n+    pretty_attrs = [\"name\", \"description\"]\n+\n+    @classmethod\n+    def get_root_tenant(cls):\n+        return cls(name=\"My Company\", _default=True)\n+\n+    def __init__(self, name=None, description=None, parent_tenant=None, _default=False):\n+        self.name = name\n+        self.description = description\n+        self.parent_tenant = parent_tenant\n+        self._default = _default\n+\n+    @property\n+    def parent_tenant(self):\n+        if self._default:\n+            return None\n+        if self._parent_tenant:\n+            return self._parent_tenant\n+        return self.get_root_tenant()\n+\n+    @parent_tenant.setter\n+    def parent_tenant(self, tenant):\n+        if tenant is not None and isinstance(tenant, Project):\n+            # If we try to\n+            raise ValueError(\"Project cannot be a parent object.\")\n+        if isinstance(tenant, basestring):\n+            # If parent tenant is passed as string, we assume that tenant name was passed instead of object\n+            tenant = Tenant(tenant)\n+        self._parent_tenant = tenant","path":"cfme/configure/access_control.py","position":108,"original_position":108,"commit_id":"a2743185a2d5ccbc6feb9d38852508e701927d5a","original_commit_id":"a2743185a2d5ccbc6feb9d38852508e701927d5a","user":{"login":"mfalesni","id":2163040,"avatar_url":"https://avatars.githubusercontent.com/u/2163040?v=3","gravatar_id":"","url":"https://api.github.com/users/mfalesni","html_url":"https://github.com/mfalesni","followers_url":"https://api.github.com/users/mfalesni/followers","following_url":"https://api.github.com/users/mfalesni/following{/other_user}","gists_url":"https://api.github.com/users/mfalesni/gists{/gist_id}","starred_url":"https://api.github.com/users/mfalesni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfalesni/subscriptions","organizations_url":"https://api.github.com/users/mfalesni/orgs","repos_url":"https://api.github.com/users/mfalesni/repos","events_url":"https://api.github.com/users/mfalesni/events{/privacy}","received_events_url":"https://api.github.com/users/mfalesni/received_events","type":"User","site_admin":false},"body":"The `__eq__` would have to look like this:\r\n```python\r\ndef __eq__(self, other):\r\n    if not isinstance(other, type(self)):\r\n        return False\r\n    else:\r\n        return self.name == other.name and self.parent_tenant == other.parent_tenant\r\n```\r\nWe could check for `_default` but that would not be universal. This protects against recursion universally and also applies to the `_default` check.","created_at":"2016-01-08T12:35:45Z","updated_at":"2016-01-08T12:35:45Z","html_url":"https://github.com/RedHatQE/cfme_tests/pull/2585#discussion_r49184141","pull_request_url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585","_links":{"self":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/comments/49184141"},"html":{"href":"https://github.com/RedHatQE/cfme_tests/pull/2585#discussion_r49184141"},"pull_request":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585"}}},"pull_request":{"url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585","id":55442994,"html_url":"https://github.com/RedHatQE/cfme_tests/pull/2585","diff_url":"https://github.com/RedHatQE/cfme_tests/pull/2585.diff","patch_url":"https://github.com/RedHatQE/cfme_tests/pull/2585.patch","issue_url":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/2585","number":2585,"state":"open","locked":false,"title":"New Tenant and Project class + fisrt multi tenancy test - test_superadmin_tenant_crud","user":{"login":"patchkez","id":11808967,"avatar_url":"https://avatars.githubusercontent.com/u/11808967?v=3","gravatar_id":"","url":"https://api.github.com/users/patchkez","html_url":"https://github.com/patchkez","followers_url":"https://api.github.com/users/patchkez/followers","following_url":"https://api.github.com/users/patchkez/following{/other_user}","gists_url":"https://api.github.com/users/patchkez/gists{/gist_id}","starred_url":"https://api.github.com/users/patchkez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patchkez/subscriptions","organizations_url":"https://api.github.com/users/patchkez/orgs","repos_url":"https://api.github.com/users/patchkez/repos","events_url":"https://api.github.com/users/patchkez/events{/privacy}","received_events_url":"https://api.github.com/users/patchkez/received_events","type":"User","site_admin":false},"body":"New  test_superadmin_tenant_crud test.","created_at":"2016-01-08T09:54:49Z","updated_at":"2016-01-08T12:35:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"609d0d5de2fed1a7cd8e6a32637050e1cd6b6fbf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585/commits","review_comments_url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585/comments","review_comment_url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/2585/comments","statuses_url":"https://api.github.com/repos/RedHatQE/cfme_tests/statuses/a2743185a2d5ccbc6feb9d38852508e701927d5a","head":{"label":"patchkez:configure_tenants","ref":"configure_tenants","sha":"a2743185a2d5ccbc6feb9d38852508e701927d5a","user":{"login":"patchkez","id":11808967,"avatar_url":"https://avatars.githubusercontent.com/u/11808967?v=3","gravatar_id":"","url":"https://api.github.com/users/patchkez","html_url":"https://github.com/patchkez","followers_url":"https://api.github.com/users/patchkez/followers","following_url":"https://api.github.com/users/patchkez/following{/other_user}","gists_url":"https://api.github.com/users/patchkez/gists{/gist_id}","starred_url":"https://api.github.com/users/patchkez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patchkez/subscriptions","organizations_url":"https://api.github.com/users/patchkez/orgs","repos_url":"https://api.github.com/users/patchkez/repos","events_url":"https://api.github.com/users/patchkez/events{/privacy}","received_events_url":"https://api.github.com/users/patchkez/received_events","type":"User","site_admin":false},"repo":{"id":43669554,"name":"cfme_tests","full_name":"patchkez/cfme_tests","owner":{"login":"patchkez","id":11808967,"avatar_url":"https://avatars.githubusercontent.com/u/11808967?v=3","gravatar_id":"","url":"https://api.github.com/users/patchkez","html_url":"https://github.com/patchkez","followers_url":"https://api.github.com/users/patchkez/followers","following_url":"https://api.github.com/users/patchkez/following{/other_user}","gists_url":"https://api.github.com/users/patchkez/gists{/gist_id}","starred_url":"https://api.github.com/users/patchkez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patchkez/subscriptions","organizations_url":"https://api.github.com/users/patchkez/orgs","repos_url":"https://api.github.com/users/patchkez/repos","events_url":"https://api.github.com/users/patchkez/events{/privacy}","received_events_url":"https://api.github.com/users/patchkez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/patchkez/cfme_tests","description":"CloudForms Management Engine - Functional tests","fork":true,"url":"https://api.github.com/repos/patchkez/cfme_tests","forks_url":"https://api.github.com/repos/patchkez/cfme_tests/forks","keys_url":"https://api.github.com/repos/patchkez/cfme_tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/patchkez/cfme_tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/patchkez/cfme_tests/teams","hooks_url":"https://api.github.com/repos/patchkez/cfme_tests/hooks","issue_events_url":"https://api.github.com/repos/patchkez/cfme_tests/issues/events{/number}","events_url":"https://api.github.com/repos/patchkez/cfme_tests/events","assignees_url":"https://api.github.com/repos/patchkez/cfme_tests/assignees{/user}","branches_url":"https://api.github.com/repos/patchkez/cfme_tests/branches{/branch}","tags_url":"https://api.github.com/repos/patchkez/cfme_tests/tags","blobs_url":"https://api.github.com/repos/patchkez/cfme_tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/patchkez/cfme_tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/patchkez/cfme_tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/patchkez/cfme_tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/patchkez/cfme_tests/statuses/{sha}","languages_url":"https://api.github.com/repos/patchkez/cfme_tests/languages","stargazers_url":"https://api.github.com/repos/patchkez/cfme_tests/stargazers","contributors_url":"https://api.github.com/repos/patchkez/cfme_tests/contributors","subscribers_url":"https://api.github.com/repos/patchkez/cfme_tests/subscribers","subscription_url":"https://api.github.com/repos/patchkez/cfme_tests/subscription","commits_url":"https://api.github.com/repos/patchkez/cfme_tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/patchkez/cfme_tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/patchkez/cfme_tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/patchkez/cfme_tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/patchkez/cfme_tests/contents/{+path}","compare_url":"https://api.github.com/repos/patchkez/cfme_tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/patchkez/cfme_tests/merges","archive_url":"https://api.github.com/repos/patchkez/cfme_tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/patchkez/cfme_tests/downloads","issues_url":"https://api.github.com/repos/patchkez/cfme_tests/issues{/number}","pulls_url":"https://api.github.com/repos/patchkez/cfme_tests/pulls{/number}","milestones_url":"https://api.github.com/repos/patchkez/cfme_tests/milestones{/number}","notifications_url":"https://api.github.com/repos/patchkez/cfme_tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/patchkez/cfme_tests/labels{/name}","releases_url":"https://api.github.com/repos/patchkez/cfme_tests/releases{/id}","created_at":"2015-10-05T06:57:06Z","updated_at":"2015-10-05T06:57:08Z","pushed_at":"2016-01-08T09:17:05Z","git_url":"git://github.com/patchkez/cfme_tests.git","ssh_url":"git@github.com:patchkez/cfme_tests.git","clone_url":"https://github.com/patchkez/cfme_tests.git","svn_url":"https://github.com/patchkez/cfme_tests","homepage":"","size":8096,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RedHatQE:master","ref":"master","sha":"e796abe0411f706eb7914cbd449701f5a9eece6d","user":{"login":"RedHatQE","id":534870,"avatar_url":"https://avatars.githubusercontent.com/u/534870?v=3","gravatar_id":"","url":"https://api.github.com/users/RedHatQE","html_url":"https://github.com/RedHatQE","followers_url":"https://api.github.com/users/RedHatQE/followers","following_url":"https://api.github.com/users/RedHatQE/following{/other_user}","gists_url":"https://api.github.com/users/RedHatQE/gists{/gist_id}","starred_url":"https://api.github.com/users/RedHatQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RedHatQE/subscriptions","organizations_url":"https://api.github.com/users/RedHatQE/orgs","repos_url":"https://api.github.com/users/RedHatQE/repos","events_url":"https://api.github.com/users/RedHatQE/events{/privacy}","received_events_url":"https://api.github.com/users/RedHatQE/received_events","type":"Organization","site_admin":false},"repo":{"id":8061086,"name":"cfme_tests","full_name":"RedHatQE/cfme_tests","owner":{"login":"RedHatQE","id":534870,"avatar_url":"https://avatars.githubusercontent.com/u/534870?v=3","gravatar_id":"","url":"https://api.github.com/users/RedHatQE","html_url":"https://github.com/RedHatQE","followers_url":"https://api.github.com/users/RedHatQE/followers","following_url":"https://api.github.com/users/RedHatQE/following{/other_user}","gists_url":"https://api.github.com/users/RedHatQE/gists{/gist_id}","starred_url":"https://api.github.com/users/RedHatQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RedHatQE/subscriptions","organizations_url":"https://api.github.com/users/RedHatQE/orgs","repos_url":"https://api.github.com/users/RedHatQE/repos","events_url":"https://api.github.com/users/RedHatQE/events{/privacy}","received_events_url":"https://api.github.com/users/RedHatQE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RedHatQE/cfme_tests","description":"CloudForms Management Engine - Functional tests","fork":false,"url":"https://api.github.com/repos/RedHatQE/cfme_tests","forks_url":"https://api.github.com/repos/RedHatQE/cfme_tests/forks","keys_url":"https://api.github.com/repos/RedHatQE/cfme_tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RedHatQE/cfme_tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RedHatQE/cfme_tests/teams","hooks_url":"https://api.github.com/repos/RedHatQE/cfme_tests/hooks","issue_events_url":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/events{/number}","events_url":"https://api.github.com/repos/RedHatQE/cfme_tests/events","assignees_url":"https://api.github.com/repos/RedHatQE/cfme_tests/assignees{/user}","branches_url":"https://api.github.com/repos/RedHatQE/cfme_tests/branches{/branch}","tags_url":"https://api.github.com/repos/RedHatQE/cfme_tests/tags","blobs_url":"https://api.github.com/repos/RedHatQE/cfme_tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RedHatQE/cfme_tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RedHatQE/cfme_tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/RedHatQE/cfme_tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RedHatQE/cfme_tests/statuses/{sha}","languages_url":"https://api.github.com/repos/RedHatQE/cfme_tests/languages","stargazers_url":"https://api.github.com/repos/RedHatQE/cfme_tests/stargazers","contributors_url":"https://api.github.com/repos/RedHatQE/cfme_tests/contributors","subscribers_url":"https://api.github.com/repos/RedHatQE/cfme_tests/subscribers","subscription_url":"https://api.github.com/repos/RedHatQE/cfme_tests/subscription","commits_url":"https://api.github.com/repos/RedHatQE/cfme_tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/RedHatQE/cfme_tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/RedHatQE/cfme_tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/RedHatQE/cfme_tests/contents/{+path}","compare_url":"https://api.github.com/repos/RedHatQE/cfme_tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RedHatQE/cfme_tests/merges","archive_url":"https://api.github.com/repos/RedHatQE/cfme_tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RedHatQE/cfme_tests/downloads","issues_url":"https://api.github.com/repos/RedHatQE/cfme_tests/issues{/number}","pulls_url":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls{/number}","milestones_url":"https://api.github.com/repos/RedHatQE/cfme_tests/milestones{/number}","notifications_url":"https://api.github.com/repos/RedHatQE/cfme_tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RedHatQE/cfme_tests/labels{/name}","releases_url":"https://api.github.com/repos/RedHatQE/cfme_tests/releases{/id}","created_at":"2013-02-06T21:59:17Z","updated_at":"2015-10-15T14:24:03Z","pushed_at":"2016-01-08T12:12:08Z","git_url":"git://github.com/RedHatQE/cfme_tests.git","ssh_url":"git@github.com:RedHatQE/cfme_tests.git","clone_url":"https://github.com/RedHatQE/cfme_tests.git","svn_url":"https://github.com/RedHatQE/cfme_tests","homepage":"","size":9934,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":77,"forks":39,"open_issues":77,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585"},"html":{"href":"https://github.com/RedHatQE/cfme_tests/pull/2585"},"issue":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/2585"},"comments":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/issues/2585/comments"},"review_comments":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585/comments"},"review_comment":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/pulls/2585/commits"},"statuses":{"href":"https://api.github.com/repos/RedHatQE/cfme_tests/statuses/a2743185a2d5ccbc6feb9d38852508e701927d5a"}}}}