{"action":"created","comment":{"url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/comments/44216932","id":44216932,"diff_hunk":"@@ -0,0 +1,69 @@\n+from application import db\n+\n+# Table storing information which module is compatible with which\n+# microcontroller\n+compatibility_table = db.Table('miocrocontroller_module',\n+    db.Column('mc_id', db.Integer, db.ForeignKey('microcontroller.id')),\n+    db.Column('md_id', db.Integer, db.ForeignKey('module.id')),\n+    db.PrimaryKeyConstraint('mc_id', 'md_id'))\n+\n+\n+class Microcontroller(db.Model):\n+    \"\"\"\n+    Class being model for microcontrollers data stored in database.\n+    \"\"\"\n+\n+    id = db.Column(db.Integer, primary_key=True)\n+    name = db.Column(db.String(80))\n+\n+    modules = db.relationship('Module', secondary=compatibility_table,\n+                              backref='microcontrollers')\n+\n+    def __init__(self, mc_id, name):\n+        self.id = mc_id\n+        self.name = name\n+\n+    def __repr__(self):\n+        return self.name\n+\n+    def to_html(self):\n+        \"\"\"\n+        Represent model object in HTML. Used in application's templates.\n+        \"\"\"\n+        return \"Name: {0}\".format(self.name)\n+\n+\n+class Module(db.Model):\n+    \"\"\"\n+    Class being model for modules (that are used in microcontrollers) data\n+    stored in database.\n+    \"\"\"\n+    # Name/description of module\n+    name = db.Column(db.String(80))\n+    id = db.Column(db.Integer, primary_key=True)\n+    # Vendor of a module\n+    vendor = db.Column(db.String(80))\n+    # Unitprice of module\n+    price = db.Column(db.String(80))\n+    # Identification number of module\n+    partnumber = db.Column(db.String(80))\n+\n+    def __init__(self, name, md_id, vendor, price, partnumber):\n+        self.name = name\n+        self.id = md_id","path":"application/models.py","position":null,"original_position":53,"commit_id":"a35001bd90de9dc36936d677b53a9cc9f481297d","original_commit_id":"57f366c3582e2956370b9e5af52ebe62ca973fa7","user":{"login":"mjenczmyk","id":11525265,"avatar_url":"https://avatars.githubusercontent.com/u/11525265?v=3","gravatar_id":"","url":"https://api.github.com/users/mjenczmyk","html_url":"https://github.com/mjenczmyk","followers_url":"https://api.github.com/users/mjenczmyk/followers","following_url":"https://api.github.com/users/mjenczmyk/following{/other_user}","gists_url":"https://api.github.com/users/mjenczmyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mjenczmyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjenczmyk/subscriptions","organizations_url":"https://api.github.com/users/mjenczmyk/orgs","repos_url":"https://api.github.com/users/mjenczmyk/repos","events_url":"https://api.github.com/users/mjenczmyk/events{/privacy}","received_events_url":"https://api.github.com/users/mjenczmyk/received_events","type":"User","site_admin":false},"body":"Well, it can break consistency of database if id's in source file aren't unique (but primary key would prevent that). OK, do you think I should generate my own id's while parsing xml file?","created_at":"2015-11-07T20:45:30Z","updated_at":"2015-11-07T20:45:30Z","html_url":"https://github.com/mruwnik/mikroklocki/pull/1#discussion_r44216932","pull_request_url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/comments/44216932"},"html":{"href":"https://github.com/mruwnik/mikroklocki/pull/1#discussion_r44216932"},"pull_request":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1","id":50039596,"html_url":"https://github.com/mruwnik/mikroklocki/pull/1","diff_url":"https://github.com/mruwnik/mikroklocki/pull/1.diff","patch_url":"https://github.com/mruwnik/mikroklocki/pull/1.patch","issue_url":"https://api.github.com/repos/mruwnik/mikroklocki/issues/1","number":1,"state":"open","locked":false,"title":"Semi-finished project","user":{"login":"mjenczmyk","id":11525265,"avatar_url":"https://avatars.githubusercontent.com/u/11525265?v=3","gravatar_id":"","url":"https://api.github.com/users/mjenczmyk","html_url":"https://github.com/mjenczmyk","followers_url":"https://api.github.com/users/mjenczmyk/followers","following_url":"https://api.github.com/users/mjenczmyk/following{/other_user}","gists_url":"https://api.github.com/users/mjenczmyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mjenczmyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjenczmyk/subscriptions","organizations_url":"https://api.github.com/users/mjenczmyk/orgs","repos_url":"https://api.github.com/users/mjenczmyk/repos","events_url":"https://api.github.com/users/mjenczmyk/events{/privacy}","received_events_url":"https://api.github.com/users/mjenczmyk/received_events","type":"User","site_admin":false},"body":"First of all I'm sorry - I haven't read README carefully and I didn't notice that I should make pull requests step by step. I focused on mail sent by Magda and it wasn't written there explicitly.\r\n\r\nThat is semi-finished project. What remains to be done is to write some tests and improve code standards.\r\n\r\nSome remarks/questions:\r\n* I used Python 3.4;\r\n* to run app you have to run load_xml_to_db.py file and than fire up run.py module;\r\n* database used in app is stored in /tmp directory. In real life I would put it somewhere else;\r\n* script loading xml file is outside app package. I'm not sure if it's good solution, but in real life db is loaded once and updated from user interface, so I thought it should be fine. If you think otherwise please inform me;\r\n* I'm not sure if writing to_html method for classes in models.py file is a good idea. It breaks separation of logic and interface, but on the other hand allows using more generic templates;\r\n* After some thinking I'm going to break down functions in views.py in two: one for listing items, second for viewing some particular item. I will make that change in next commits.","created_at":"2015-11-07T16:40:45Z","updated_at":"2015-11-07T20:45:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a60cf32e9eb7dd86aa50833f08495dfbc45cdd89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1/commits","review_comments_url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1/comments","review_comment_url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mruwnik/mikroklocki/issues/1/comments","statuses_url":"https://api.github.com/repos/mruwnik/mikroklocki/statuses/a35001bd90de9dc36936d677b53a9cc9f481297d","head":{"label":"mjenczmyk:master","ref":"master","sha":"a35001bd90de9dc36936d677b53a9cc9f481297d","user":{"login":"mjenczmyk","id":11525265,"avatar_url":"https://avatars.githubusercontent.com/u/11525265?v=3","gravatar_id":"","url":"https://api.github.com/users/mjenczmyk","html_url":"https://github.com/mjenczmyk","followers_url":"https://api.github.com/users/mjenczmyk/followers","following_url":"https://api.github.com/users/mjenczmyk/following{/other_user}","gists_url":"https://api.github.com/users/mjenczmyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mjenczmyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjenczmyk/subscriptions","organizations_url":"https://api.github.com/users/mjenczmyk/orgs","repos_url":"https://api.github.com/users/mjenczmyk/repos","events_url":"https://api.github.com/users/mjenczmyk/events{/privacy}","received_events_url":"https://api.github.com/users/mjenczmyk/received_events","type":"User","site_admin":false},"repo":{"id":45700767,"name":"mikroklocki","full_name":"mjenczmyk/mikroklocki","owner":{"login":"mjenczmyk","id":11525265,"avatar_url":"https://avatars.githubusercontent.com/u/11525265?v=3","gravatar_id":"","url":"https://api.github.com/users/mjenczmyk","html_url":"https://github.com/mjenczmyk","followers_url":"https://api.github.com/users/mjenczmyk/followers","following_url":"https://api.github.com/users/mjenczmyk/following{/other_user}","gists_url":"https://api.github.com/users/mjenczmyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mjenczmyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjenczmyk/subscriptions","organizations_url":"https://api.github.com/users/mjenczmyk/orgs","repos_url":"https://api.github.com/users/mjenczmyk/repos","events_url":"https://api.github.com/users/mjenczmyk/events{/privacy}","received_events_url":"https://api.github.com/users/mjenczmyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mjenczmyk/mikroklocki","description":"","fork":true,"url":"https://api.github.com/repos/mjenczmyk/mikroklocki","forks_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/forks","keys_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/teams","hooks_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/hooks","issue_events_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/issues/events{/number}","events_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/events","assignees_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/assignees{/user}","branches_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/branches{/branch}","tags_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/tags","blobs_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/git/refs{/sha}","trees_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/statuses/{sha}","languages_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/languages","stargazers_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/stargazers","contributors_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/contributors","subscribers_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/subscribers","subscription_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/subscription","commits_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/commits{/sha}","git_commits_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/git/commits{/sha}","comments_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/comments{/number}","issue_comment_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/issues/comments{/number}","contents_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/contents/{+path}","compare_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/merges","archive_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/downloads","issues_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/issues{/number}","pulls_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/pulls{/number}","milestones_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/milestones{/number}","notifications_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/labels{/name}","releases_url":"https://api.github.com/repos/mjenczmyk/mikroklocki/releases{/id}","created_at":"2015-11-06T18:50:45Z","updated_at":"2015-11-07T03:00:58Z","pushed_at":"2015-11-07T20:24:26Z","git_url":"git://github.com/mjenczmyk/mikroklocki.git","ssh_url":"git@github.com:mjenczmyk/mikroklocki.git","clone_url":"https://github.com/mjenczmyk/mikroklocki.git","svn_url":"https://github.com/mjenczmyk/mikroklocki","homepage":null,"size":0,"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":"mruwnik:master","ref":"master","sha":"89d5cf50dd7c7a6ef613d2198c061163d4511ad5","user":{"login":"mruwnik","id":3942390,"avatar_url":"https://avatars.githubusercontent.com/u/3942390?v=3","gravatar_id":"","url":"https://api.github.com/users/mruwnik","html_url":"https://github.com/mruwnik","followers_url":"https://api.github.com/users/mruwnik/followers","following_url":"https://api.github.com/users/mruwnik/following{/other_user}","gists_url":"https://api.github.com/users/mruwnik/gists{/gist_id}","starred_url":"https://api.github.com/users/mruwnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mruwnik/subscriptions","organizations_url":"https://api.github.com/users/mruwnik/orgs","repos_url":"https://api.github.com/users/mruwnik/repos","events_url":"https://api.github.com/users/mruwnik/events{/privacy}","received_events_url":"https://api.github.com/users/mruwnik/received_events","type":"User","site_admin":false},"repo":{"id":45383655,"name":"mikroklocki","full_name":"mruwnik/mikroklocki","owner":{"login":"mruwnik","id":3942390,"avatar_url":"https://avatars.githubusercontent.com/u/3942390?v=3","gravatar_id":"","url":"https://api.github.com/users/mruwnik","html_url":"https://github.com/mruwnik","followers_url":"https://api.github.com/users/mruwnik/followers","following_url":"https://api.github.com/users/mruwnik/following{/other_user}","gists_url":"https://api.github.com/users/mruwnik/gists{/gist_id}","starred_url":"https://api.github.com/users/mruwnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mruwnik/subscriptions","organizations_url":"https://api.github.com/users/mruwnik/orgs","repos_url":"https://api.github.com/users/mruwnik/repos","events_url":"https://api.github.com/users/mruwnik/events{/privacy}","received_events_url":"https://api.github.com/users/mruwnik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mruwnik/mikroklocki","description":"","fork":false,"url":"https://api.github.com/repos/mruwnik/mikroklocki","forks_url":"https://api.github.com/repos/mruwnik/mikroklocki/forks","keys_url":"https://api.github.com/repos/mruwnik/mikroklocki/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mruwnik/mikroklocki/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mruwnik/mikroklocki/teams","hooks_url":"https://api.github.com/repos/mruwnik/mikroklocki/hooks","issue_events_url":"https://api.github.com/repos/mruwnik/mikroklocki/issues/events{/number}","events_url":"https://api.github.com/repos/mruwnik/mikroklocki/events","assignees_url":"https://api.github.com/repos/mruwnik/mikroklocki/assignees{/user}","branches_url":"https://api.github.com/repos/mruwnik/mikroklocki/branches{/branch}","tags_url":"https://api.github.com/repos/mruwnik/mikroklocki/tags","blobs_url":"https://api.github.com/repos/mruwnik/mikroklocki/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mruwnik/mikroklocki/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mruwnik/mikroklocki/git/refs{/sha}","trees_url":"https://api.github.com/repos/mruwnik/mikroklocki/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mruwnik/mikroklocki/statuses/{sha}","languages_url":"https://api.github.com/repos/mruwnik/mikroklocki/languages","stargazers_url":"https://api.github.com/repos/mruwnik/mikroklocki/stargazers","contributors_url":"https://api.github.com/repos/mruwnik/mikroklocki/contributors","subscribers_url":"https://api.github.com/repos/mruwnik/mikroklocki/subscribers","subscription_url":"https://api.github.com/repos/mruwnik/mikroklocki/subscription","commits_url":"https://api.github.com/repos/mruwnik/mikroklocki/commits{/sha}","git_commits_url":"https://api.github.com/repos/mruwnik/mikroklocki/git/commits{/sha}","comments_url":"https://api.github.com/repos/mruwnik/mikroklocki/comments{/number}","issue_comment_url":"https://api.github.com/repos/mruwnik/mikroklocki/issues/comments{/number}","contents_url":"https://api.github.com/repos/mruwnik/mikroklocki/contents/{+path}","compare_url":"https://api.github.com/repos/mruwnik/mikroklocki/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mruwnik/mikroklocki/merges","archive_url":"https://api.github.com/repos/mruwnik/mikroklocki/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mruwnik/mikroklocki/downloads","issues_url":"https://api.github.com/repos/mruwnik/mikroklocki/issues{/number}","pulls_url":"https://api.github.com/repos/mruwnik/mikroklocki/pulls{/number}","milestones_url":"https://api.github.com/repos/mruwnik/mikroklocki/milestones{/number}","notifications_url":"https://api.github.com/repos/mruwnik/mikroklocki/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mruwnik/mikroklocki/labels{/name}","releases_url":"https://api.github.com/repos/mruwnik/mikroklocki/releases{/id}","created_at":"2015-11-02T09:09:31Z","updated_at":"2015-11-02T09:09:31Z","pushed_at":"2015-11-07T20:24:26Z","git_url":"git://github.com/mruwnik/mikroklocki.git","ssh_url":"git@github.com:mruwnik/mikroklocki.git","clone_url":"https://github.com/mruwnik/mikroklocki.git","svn_url":"https://github.com/mruwnik/mikroklocki","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"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":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1"},"html":{"href":"https://github.com/mruwnik/mikroklocki/pull/1"},"issue":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/issues/1"},"comments":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/mruwnik/mikroklocki/statuses/a35001bd90de9dc36936d677b53a9cc9f481297d"}}}}