{"action":"created","comment":{"url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/comments/47449816","id":47449816,"diff_hunk":"@@ -245,12 +252,124 @@ class DbTab(Tab):\n             tkMessageBox.showerror(\"Adding user to restaurants failed\", \"Either we failed to connect to the database, or the user or one of the restaurants doesn't exist or the mapping already exists\")\n             return\n \n+class UserDialog(Toplevel, object):\n+    __metaclass__ = ABCMeta\n+    @abstractmethod\n+    def button_ok_action(self): pass\n+    @abstractmethod\n+    def fill_initial_values(self): pass\n+\n+    def __init__(self, parent, db):\n+        Toplevel.__init__(self, parent)\n+        self.parent = parent\n+        self._db = db\n+        self.transient(parent)\n+\n+        # Setting font since the default is weird and jumbles-up hebrew with apostrophe (stackoverflow.com/q/34220597/2134702)\n+        self.restaurants_list = Listbox(self, selectmode='multiple', exportselection=0, font=('Tahoma', 8))\n+        self.restaurants_list_scrollbar = Scrollbar(self, command=self.restaurants_list.yview)\n+        self.restaurants_list['yscrollcommand'] = self.restaurants_list_scrollbar.set\n+        self.choose_restaurants_label = Label(self, text=\"Restaurants:\")\n+\n+        self.user_label = Label(self, text=\"Person Name:\")\n+        self.user_text = Text(self, height=1, width=18)\n+\n+        self.ok_button = Button(self, text=\"OK\", command=self._button_ok)\n+        self.cancel_button = Button(self, text=\"Cancel\", command=self._button_cancel)\n+\n+        self.columnconfigure(0, weight=0)\n+        self.columnconfigure(1, weight=0)\n+        self.columnconfigure(2, weight=0)\n+        self.columnconfigure(3, weight=0)\n+        self.columnconfigure(4, weight=1)\n+        self.rowconfigure(0, weight=0)\n+        self.rowconfigure(1, weight=0)\n+        self.rowconfigure(2, weight=1)\n+\n+        #layout\n+        self.user_label.grid(row=0, column=0, sticky=E + N)\n+        self.user_text.grid(row=0, column=1, sticky=W + N)\n+        self.choose_restaurants_label.grid(row=2, column=0, sticky=E + N)\n+        self.restaurants_list.grid(row=2, column=1, sticky=W + E + S + N)\n+        self.restaurants_list_scrollbar.grid(row=2, column=2, sticky=W + S + N)\n+        self.ok_button.grid(row=3, column=1, sticky=E + S + N)\n+        self.cancel_button.grid(row=3, column=2, sticky=W + S + N)\n+\n+        #fill up fields\n+        available_restaurants = set(self._db.get_all_restaurants())\n+        #chosen_restaurants = set(CrossReferencer.find_restaurants({user}))\n+        self.restaurants_list.delete(0, END)\n+        for item in available_restaurants:\n+            self.restaurants_list.insert(END, item)\n+\n+        self.fill_initial_values()\n+\n+        self.wait_visibility()\n+        self.grab_set() #makes window modal\n+\n+    def _button_ok(self):\n+        self.button_ok_action()\n+        self.destroy()\n+\n+    def _button_cancel(self):\n+        self.destroy()\n+\n+class AddUserDialog(UserDialog):\n+    def button_ok_action(self):\n+        person_name = self.user_text.get(\"1.0\", END).strip()\n+\n+        if not person_name:\n+            tkMessageBox.showerror(\"Adding a person failed\", \"Person name cannot be empty!\")\n+            return\n+\n+        selected_restaurants = [self._db.get_all_restaurants()[int(x)] for x in self.restaurants_list.curselection()]\n+        try:\n+            self._db.add_person(person_name)\n+            self._db.add_person_to_restaurants(person_name, selected_restaurants)\n+        except Exception as e:\n+            tkMessageBox.showerror(\"Adding a person failed\", \"Operation failed!\")\n+            print 'GOT AN EXCEPTION!' + str(e)\n+\n+    def fill_initial_values(self):\n+        pass\n+\n+class EditUserDialog(UserDialog):\n+    def __init__(self, parent, db, user_name):\n+        self.user_name = user_name\n+        super(self.__class__, self).__init__(parent, db)\n+\n+    def button_ok_action(self):\n+        person_name = self.user_text.get(\"1.0\", END).strip()\n+\n+        if not person_name:\n+            tkMessageBox.showerror(\"Adding a person failed\", \"Person name cannot be empty!\")","path":"ui.pyw","position":173,"original_position":173,"commit_id":"89ae3c90b242a548446fed2c1024b5690194c15a","original_commit_id":"89ae3c90b242a548446fed2c1024b5690194c15a","user":{"login":"eranbrodet","id":5731399,"avatar_url":"https://avatars.githubusercontent.com/u/5731399?v=3","gravatar_id":"","url":"https://api.github.com/users/eranbrodet","html_url":"https://github.com/eranbrodet","followers_url":"https://api.github.com/users/eranbrodet/followers","following_url":"https://api.github.com/users/eranbrodet/following{/other_user}","gists_url":"https://api.github.com/users/eranbrodet/gists{/gist_id}","starred_url":"https://api.github.com/users/eranbrodet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eranbrodet/subscriptions","organizations_url":"https://api.github.com/users/eranbrodet/orgs","repos_url":"https://api.github.com/users/eranbrodet/repos","events_url":"https://api.github.com/users/eranbrodet/events{/privacy}","received_events_url":"https://api.github.com/users/eranbrodet/received_events","type":"User","site_admin":false},"body":"This is not adding person","created_at":"2015-12-13T20:39:30Z","updated_at":"2015-12-13T20:39:30Z","html_url":"https://github.com/eranbrodet/lunch_helper/pull/3#discussion_r47449816","pull_request_url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/comments/47449816"},"html":{"href":"https://github.com/eranbrodet/lunch_helper/pull/3#discussion_r47449816"},"pull_request":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3","id":53506107,"html_url":"https://github.com/eranbrodet/lunch_helper/pull/3","diff_url":"https://github.com/eranbrodet/lunch_helper/pull/3.diff","patch_url":"https://github.com/eranbrodet/lunch_helper/pull/3.patch","issue_url":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/3","number":3,"state":"open","locked":false,"title":"User management ui update","user":{"login":"afiefh","id":212188,"avatar_url":"https://avatars.githubusercontent.com/u/212188?v=3","gravatar_id":"","url":"https://api.github.com/users/afiefh","html_url":"https://github.com/afiefh","followers_url":"https://api.github.com/users/afiefh/followers","following_url":"https://api.github.com/users/afiefh/following{/other_user}","gists_url":"https://api.github.com/users/afiefh/gists{/gist_id}","starred_url":"https://api.github.com/users/afiefh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afiefh/subscriptions","organizations_url":"https://api.github.com/users/afiefh/orgs","repos_url":"https://api.github.com/users/afiefh/repos","events_url":"https://api.github.com/users/afiefh/events{/privacy}","received_events_url":"https://api.github.com/users/afiefh/received_events","type":"User","site_admin":false},"body":"Now adding and editing users is done in dedicated dialogues","created_at":"2015-12-13T18:37:23Z","updated_at":"2015-12-13T20:39:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26cf4ca399f52118e2bba623d4351be88fb5f709","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3/commits","review_comments_url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3/comments","review_comment_url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/3/comments","statuses_url":"https://api.github.com/repos/eranbrodet/lunch_helper/statuses/89ae3c90b242a548446fed2c1024b5690194c15a","head":{"label":"afiefh:user_dialogues","ref":"user_dialogues","sha":"89ae3c90b242a548446fed2c1024b5690194c15a","user":{"login":"afiefh","id":212188,"avatar_url":"https://avatars.githubusercontent.com/u/212188?v=3","gravatar_id":"","url":"https://api.github.com/users/afiefh","html_url":"https://github.com/afiefh","followers_url":"https://api.github.com/users/afiefh/followers","following_url":"https://api.github.com/users/afiefh/following{/other_user}","gists_url":"https://api.github.com/users/afiefh/gists{/gist_id}","starred_url":"https://api.github.com/users/afiefh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afiefh/subscriptions","organizations_url":"https://api.github.com/users/afiefh/orgs","repos_url":"https://api.github.com/users/afiefh/repos","events_url":"https://api.github.com/users/afiefh/events{/privacy}","received_events_url":"https://api.github.com/users/afiefh/received_events","type":"User","site_admin":false},"repo":{"id":47822541,"name":"lunch_helper","full_name":"afiefh/lunch_helper","owner":{"login":"afiefh","id":212188,"avatar_url":"https://avatars.githubusercontent.com/u/212188?v=3","gravatar_id":"","url":"https://api.github.com/users/afiefh","html_url":"https://github.com/afiefh","followers_url":"https://api.github.com/users/afiefh/followers","following_url":"https://api.github.com/users/afiefh/following{/other_user}","gists_url":"https://api.github.com/users/afiefh/gists{/gist_id}","starred_url":"https://api.github.com/users/afiefh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afiefh/subscriptions","organizations_url":"https://api.github.com/users/afiefh/orgs","repos_url":"https://api.github.com/users/afiefh/repos","events_url":"https://api.github.com/users/afiefh/events{/privacy}","received_events_url":"https://api.github.com/users/afiefh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afiefh/lunch_helper","description":"","fork":true,"url":"https://api.github.com/repos/afiefh/lunch_helper","forks_url":"https://api.github.com/repos/afiefh/lunch_helper/forks","keys_url":"https://api.github.com/repos/afiefh/lunch_helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afiefh/lunch_helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afiefh/lunch_helper/teams","hooks_url":"https://api.github.com/repos/afiefh/lunch_helper/hooks","issue_events_url":"https://api.github.com/repos/afiefh/lunch_helper/issues/events{/number}","events_url":"https://api.github.com/repos/afiefh/lunch_helper/events","assignees_url":"https://api.github.com/repos/afiefh/lunch_helper/assignees{/user}","branches_url":"https://api.github.com/repos/afiefh/lunch_helper/branches{/branch}","tags_url":"https://api.github.com/repos/afiefh/lunch_helper/tags","blobs_url":"https://api.github.com/repos/afiefh/lunch_helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afiefh/lunch_helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afiefh/lunch_helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/afiefh/lunch_helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afiefh/lunch_helper/statuses/{sha}","languages_url":"https://api.github.com/repos/afiefh/lunch_helper/languages","stargazers_url":"https://api.github.com/repos/afiefh/lunch_helper/stargazers","contributors_url":"https://api.github.com/repos/afiefh/lunch_helper/contributors","subscribers_url":"https://api.github.com/repos/afiefh/lunch_helper/subscribers","subscription_url":"https://api.github.com/repos/afiefh/lunch_helper/subscription","commits_url":"https://api.github.com/repos/afiefh/lunch_helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/afiefh/lunch_helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/afiefh/lunch_helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/afiefh/lunch_helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/afiefh/lunch_helper/contents/{+path}","compare_url":"https://api.github.com/repos/afiefh/lunch_helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afiefh/lunch_helper/merges","archive_url":"https://api.github.com/repos/afiefh/lunch_helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afiefh/lunch_helper/downloads","issues_url":"https://api.github.com/repos/afiefh/lunch_helper/issues{/number}","pulls_url":"https://api.github.com/repos/afiefh/lunch_helper/pulls{/number}","milestones_url":"https://api.github.com/repos/afiefh/lunch_helper/milestones{/number}","notifications_url":"https://api.github.com/repos/afiefh/lunch_helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afiefh/lunch_helper/labels{/name}","releases_url":"https://api.github.com/repos/afiefh/lunch_helper/releases{/id}","created_at":"2015-12-11T11:16:45Z","updated_at":"2015-12-11T11:16:46Z","pushed_at":"2015-12-13T18:36:42Z","git_url":"git://github.com/afiefh/lunch_helper.git","ssh_url":"git@github.com:afiefh/lunch_helper.git","clone_url":"https://github.com/afiefh/lunch_helper.git","svn_url":"https://github.com/afiefh/lunch_helper","homepage":null,"size":37,"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":"eranbrodet:master","ref":"master","sha":"f93e7db06c75f89d52549def819035f73a23c692","user":{"login":"eranbrodet","id":5731399,"avatar_url":"https://avatars.githubusercontent.com/u/5731399?v=3","gravatar_id":"","url":"https://api.github.com/users/eranbrodet","html_url":"https://github.com/eranbrodet","followers_url":"https://api.github.com/users/eranbrodet/followers","following_url":"https://api.github.com/users/eranbrodet/following{/other_user}","gists_url":"https://api.github.com/users/eranbrodet/gists{/gist_id}","starred_url":"https://api.github.com/users/eranbrodet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eranbrodet/subscriptions","organizations_url":"https://api.github.com/users/eranbrodet/orgs","repos_url":"https://api.github.com/users/eranbrodet/repos","events_url":"https://api.github.com/users/eranbrodet/events{/privacy}","received_events_url":"https://api.github.com/users/eranbrodet/received_events","type":"User","site_admin":false},"repo":{"id":47819999,"name":"lunch_helper","full_name":"eranbrodet/lunch_helper","owner":{"login":"eranbrodet","id":5731399,"avatar_url":"https://avatars.githubusercontent.com/u/5731399?v=3","gravatar_id":"","url":"https://api.github.com/users/eranbrodet","html_url":"https://github.com/eranbrodet","followers_url":"https://api.github.com/users/eranbrodet/followers","following_url":"https://api.github.com/users/eranbrodet/following{/other_user}","gists_url":"https://api.github.com/users/eranbrodet/gists{/gist_id}","starred_url":"https://api.github.com/users/eranbrodet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eranbrodet/subscriptions","organizations_url":"https://api.github.com/users/eranbrodet/orgs","repos_url":"https://api.github.com/users/eranbrodet/repos","events_url":"https://api.github.com/users/eranbrodet/events{/privacy}","received_events_url":"https://api.github.com/users/eranbrodet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eranbrodet/lunch_helper","description":"","fork":false,"url":"https://api.github.com/repos/eranbrodet/lunch_helper","forks_url":"https://api.github.com/repos/eranbrodet/lunch_helper/forks","keys_url":"https://api.github.com/repos/eranbrodet/lunch_helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eranbrodet/lunch_helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eranbrodet/lunch_helper/teams","hooks_url":"https://api.github.com/repos/eranbrodet/lunch_helper/hooks","issue_events_url":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/events{/number}","events_url":"https://api.github.com/repos/eranbrodet/lunch_helper/events","assignees_url":"https://api.github.com/repos/eranbrodet/lunch_helper/assignees{/user}","branches_url":"https://api.github.com/repos/eranbrodet/lunch_helper/branches{/branch}","tags_url":"https://api.github.com/repos/eranbrodet/lunch_helper/tags","blobs_url":"https://api.github.com/repos/eranbrodet/lunch_helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eranbrodet/lunch_helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eranbrodet/lunch_helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/eranbrodet/lunch_helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eranbrodet/lunch_helper/statuses/{sha}","languages_url":"https://api.github.com/repos/eranbrodet/lunch_helper/languages","stargazers_url":"https://api.github.com/repos/eranbrodet/lunch_helper/stargazers","contributors_url":"https://api.github.com/repos/eranbrodet/lunch_helper/contributors","subscribers_url":"https://api.github.com/repos/eranbrodet/lunch_helper/subscribers","subscription_url":"https://api.github.com/repos/eranbrodet/lunch_helper/subscription","commits_url":"https://api.github.com/repos/eranbrodet/lunch_helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/eranbrodet/lunch_helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/eranbrodet/lunch_helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/eranbrodet/lunch_helper/contents/{+path}","compare_url":"https://api.github.com/repos/eranbrodet/lunch_helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eranbrodet/lunch_helper/merges","archive_url":"https://api.github.com/repos/eranbrodet/lunch_helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eranbrodet/lunch_helper/downloads","issues_url":"https://api.github.com/repos/eranbrodet/lunch_helper/issues{/number}","pulls_url":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls{/number}","milestones_url":"https://api.github.com/repos/eranbrodet/lunch_helper/milestones{/number}","notifications_url":"https://api.github.com/repos/eranbrodet/lunch_helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eranbrodet/lunch_helper/labels{/name}","releases_url":"https://api.github.com/repos/eranbrodet/lunch_helper/releases{/id}","created_at":"2015-12-11T10:20:54Z","updated_at":"2015-12-11T12:13:45Z","pushed_at":"2015-12-13T18:37:23Z","git_url":"git://github.com/eranbrodet/lunch_helper.git","ssh_url":"git@github.com:eranbrodet/lunch_helper.git","clone_url":"https://github.com/eranbrodet/lunch_helper.git","svn_url":"https://github.com/eranbrodet/lunch_helper","homepage":null,"size":35,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3"},"html":{"href":"https://github.com/eranbrodet/lunch_helper/pull/3"},"issue":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/3"},"comments":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/eranbrodet/lunch_helper/statuses/89ae3c90b242a548446fed2c1024b5690194c15a"}}}}