{"action":"created","comment":{"url":"https://api.github.com/repos/reed-college/lemur/pulls/comments/70706502","id":70706502,"diff_hunk":"@@ -0,0 +1,270 @@\n+\n+from datetime import datetime\n+from flask.ext.login import UserMixin, AnonymousUserMixin\n+from myapp import db, login_manager\n+\n+# Association tables for Many-To-Many relationships between various tables\n+association_table_class_user = db.Table('association_class_user',\n+                                        db.Column('class_id', db.String(64),\n+                                                  db.ForeignKey('Class.id')),\n+                                        db.Column('user_id', db.String(64),\n+                                                  db.ForeignKey('User.id')))\n+association_table_class_lab = db.Table('association_class_lab',\n+                                       db.Column('class_id', db.String(64),\n+                                                 db.ForeignKey('Class.id')),\n+                                       db.Column('lab_id', db.String(64),\n+                                                 db.ForeignKey(\n+                                                    'Lab.id')))\n+association_table_user_lab = db.Table('association_user_lab',\n+                                      db.Column('user_id', db.String(64),\n+                                                db.ForeignKey('User.id')),\n+                                      db.Column('lab_id', db.String(64),\n+                                                db.ForeignKey(\n+                                                    'Lab.id')))\n+\n+\n+# set up class to track the date and time information for an object\n+class DateTimeInfo(object):\n+    created_on = db.Column(db.DateTime, default=datetime.now)\n+    updated_on = db.Column(db.DateTime, default=datetime.now,\n+                           onupdate=datetime.now)\n+\n+\n+# Store general info of a lab\n+class Lab(db.Model):\n+    __tablename__ = 'Lab'\n+    id = db.Column(db.String(128), nullable=False, unique=True,\n+                   primary_key=True)\n+    name = db.Column(db.String(128), nullable=False)\n+    class_name = db.Column(db.String(128), nullable=False)\n+    prof_name = db.Column(db.String(128), nullable=False)\n+    # lab description contained in description variable\n+    description = db.Column(db.String(4096))\n+    status = db.Column(db.Enum('Activated', 'Downloadable', 'Unactivated',\n+                               name='status'))\n+\n+    # one-to-many: a lab can have multiple experiments\n+    experiments = db.relationship('Experiment', back_populates='lab',\n+                                  cascade=\"all, delete, delete-orphan\")\n+    # Many-to-Many: a class can have multiple labs and a lab can have multiple\n+    # classes\n+    classes = db.relationship(\"Class\", secondary=association_table_class_lab,\n+                              back_populates=\"labs\")\n+    # Many-to-Many: a user can have multiple labs and a lab can have multiple\n+    # users\n+    users = db.relationship(\"User\", secondary=association_table_user_lab,\n+                            back_populates=\"labs\")\n+\n+    def __repr__(self):\n+        # Representation of class object in string format\n+        tpl = ('Lab<id: {id}, name: {name}'\n+               ', class_name: {class_name}, prof_name: {prof_name}'\n+               ', description: {description}, status: {status}'\n+               ', experiments: {experiments}, classes: {classes}'\n+               ', users: {users}>')\n+        formatted = tpl.format(id=self.id, name=self.name,\n+                               class_name=self.class_name,\n+                               prof_name=self.prof_name,\n+                               description=self.description,\n+                               status=self.status,\n+                               experiments=[e.name for e in self.experiments],\n+                               classes=[c.name for c in self.classes],\n+                               users=[u.name for u in self.users])\n+        return formatted\n+\n+\n+# Store experiments' info of a lab\n+class Experiment(db.Model):\n+    __tablename__ = 'Experiment'\n+    id = db.Column(db.String(128), nullable=False, unique=True,\n+                   primary_key=True)\n+    name = db.Column(db.String(512), nullable=False)\n+    description = db.Column(db.String(512))\n+    order = db.Column(db.Integer, nullable=False)\n+    # Type of value expected for this experiment\n+    value_type = db.Column(db.Enum('Number', 'Text', name='value_type'))\n+    # Value range only applies when the type is a number\n+    value_range = db.Column(db.String(64))\n+    # Value candidates only applies when the type is text\n+    value_candidates = db.Column(db.String(512))\n+\n+    # Many-to-One: a lab can have multiple experiments\n+    lab_id = db.Column(db.String(128), db.ForeignKey('Lab.id'))\n+    lab = db.relationship(\"Lab\", back_populates=\"experiments\")\n+\n+    # one-to-many: a experiment can have multiple data\n+    observations = db.relationship('Observation', back_populates='experiment',\n+                                   cascade=\"all, delete, delete-orphan\")\n+\n+    def __repr__(self):\n+        tpl = ('Lab<id: {id}, name: {name}, description: {description}'\n+               ', order: {order}, value_type: {value_type}'\n+               ', value_range: {value_range}'\n+               ', value_candidates: {value_candidates}'\n+               ', lab_id: {lab_id}, lab:{lab}'\n+               ', observations: {observations}>')\n+        formatted = tpl.format(id=self.id, name=self.name,\n+                               description=self.description,\n+                               order=self.order,\n+                               value_type=self.value_type,\n+                               value_range=self.value_range,\n+                               value_candidates=self.value_candidates,\n+                               lab_id=self.lab_id,\n+                               lab=self.lab.name,\n+                               observations=[ob.id for ob in self.observations])\n+        return formatted\n+\n+\n+# Store data entered by students\n+class Observation(db.Model, DateTimeInfo):\n+    __tablename__ = 'Observation'\n+    id = db.Column(db.String(128), nullable=False, unique=True,\n+                   primary_key=True)\n+    student_name = db.Column(db.String(256), nullable=False)","path":"myapp/models.py","position":null,"original_position":123,"commit_id":"5e7567d96e1cf828c2efb4c62bdc4895a9863299","original_commit_id":"b99e5862355a6966b5fb50ff81288f5cf27ab8f6","user":{"login":"AIasd","id":12670254,"avatar_url":"https://avatars.githubusercontent.com/u/12670254?v=3","gravatar_id":"","url":"https://api.github.com/users/AIasd","html_url":"https://github.com/AIasd","followers_url":"https://api.github.com/users/AIasd/followers","following_url":"https://api.github.com/users/AIasd/following{/other_user}","gists_url":"https://api.github.com/users/AIasd/gists{/gist_id}","starred_url":"https://api.github.com/users/AIasd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIasd/subscriptions","organizations_url":"https://api.github.com/users/AIasd/orgs","repos_url":"https://api.github.com/users/AIasd/repos","events_url":"https://api.github.com/users/AIasd/events{/privacy}","received_events_url":"https://api.github.com/users/AIasd/received_events","type":"User","site_admin":false},"body":"Hmm.. I think that the student_name for each Observation should not be the name of a single student but the names of a group of students in a string format(e.g. 'tim,andrew,bob'). So when the admin edit the data, the admin can sort according to these strings.","created_at":"2016-07-13T20:54:27Z","updated_at":"2016-07-13T20:54:27Z","html_url":"https://github.com/reed-college/lemur/pull/9#discussion_r70706502","pull_request_url":"https://api.github.com/repos/reed-college/lemur/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/comments/70706502"},"html":{"href":"https://github.com/reed-college/lemur/pull/9#discussion_r70706502"},"pull_request":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/reed-college/lemur/pulls/9","id":75399773,"html_url":"https://github.com/reed-college/lemur/pull/9","diff_url":"https://github.com/reed-college/lemur/pull/9.diff","patch_url":"https://github.com/reed-college/lemur/pull/9.patch","issue_url":"https://api.github.com/repos/reed-college/lemur/issues/9","number":9,"state":"open","locked":false,"title":"Mergeprep1","user":{"login":"howelle","id":15080091,"avatar_url":"https://avatars.githubusercontent.com/u/15080091?v=3","gravatar_id":"","url":"https://api.github.com/users/howelle","html_url":"https://github.com/howelle","followers_url":"https://api.github.com/users/howelle/followers","following_url":"https://api.github.com/users/howelle/following{/other_user}","gists_url":"https://api.github.com/users/howelle/gists{/gist_id}","starred_url":"https://api.github.com/users/howelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howelle/subscriptions","organizations_url":"https://api.github.com/users/howelle/orgs","repos_url":"https://api.github.com/users/howelle/repos","events_url":"https://api.github.com/users/howelle/events{/privacy}","received_events_url":"https://api.github.com/users/howelle/received_events","type":"User","site_admin":false},"body":"The merge contains minor changes to Notes and requirements files. Some files have also been moved (config.py, __main__.py). There is an error_log folder/file, an __init__ file to make up for the movement of __main__, a dataforms.py file for login info, and a config.cfg file. Most substantial changes are in models.py (schema.py), views.py (main.py), and utility.py. ","created_at":"2016-06-28T00:06:27Z","updated_at":"2016-07-13T20:54:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1178c8078b0649e9fecfa2867b7a5255dbdd8bb3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/reed-college/lemur/pulls/9/commits","review_comments_url":"https://api.github.com/repos/reed-college/lemur/pulls/9/comments","review_comment_url":"https://api.github.com/repos/reed-college/lemur/pulls/comments{/number}","comments_url":"https://api.github.com/repos/reed-college/lemur/issues/9/comments","statuses_url":"https://api.github.com/repos/reed-college/lemur/statuses/5e7567d96e1cf828c2efb4c62bdc4895a9863299","head":{"label":"reed-college:mergeprep1","ref":"mergeprep1","sha":"5e7567d96e1cf828c2efb4c62bdc4895a9863299","user":{"login":"reed-college","id":6775928,"avatar_url":"https://avatars.githubusercontent.com/u/6775928?v=3","gravatar_id":"","url":"https://api.github.com/users/reed-college","html_url":"https://github.com/reed-college","followers_url":"https://api.github.com/users/reed-college/followers","following_url":"https://api.github.com/users/reed-college/following{/other_user}","gists_url":"https://api.github.com/users/reed-college/gists{/gist_id}","starred_url":"https://api.github.com/users/reed-college/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reed-college/subscriptions","organizations_url":"https://api.github.com/users/reed-college/orgs","repos_url":"https://api.github.com/users/reed-college/repos","events_url":"https://api.github.com/users/reed-college/events{/privacy}","received_events_url":"https://api.github.com/users/reed-college/received_events","type":"Organization","site_admin":false},"repo":{"id":59132723,"name":"lemur","full_name":"reed-college/lemur","owner":{"login":"reed-college","id":6775928,"avatar_url":"https://avatars.githubusercontent.com/u/6775928?v=3","gravatar_id":"","url":"https://api.github.com/users/reed-college","html_url":"https://github.com/reed-college","followers_url":"https://api.github.com/users/reed-college/followers","following_url":"https://api.github.com/users/reed-college/following{/other_user}","gists_url":"https://api.github.com/users/reed-college/gists{/gist_id}","starred_url":"https://api.github.com/users/reed-college/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reed-college/subscriptions","organizations_url":"https://api.github.com/users/reed-college/orgs","repos_url":"https://api.github.com/users/reed-college/repos","events_url":"https://api.github.com/users/reed-college/events{/privacy}","received_events_url":"https://api.github.com/users/reed-college/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reed-college/lemur","description":"Bio data collector","fork":false,"url":"https://api.github.com/repos/reed-college/lemur","forks_url":"https://api.github.com/repos/reed-college/lemur/forks","keys_url":"https://api.github.com/repos/reed-college/lemur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reed-college/lemur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reed-college/lemur/teams","hooks_url":"https://api.github.com/repos/reed-college/lemur/hooks","issue_events_url":"https://api.github.com/repos/reed-college/lemur/issues/events{/number}","events_url":"https://api.github.com/repos/reed-college/lemur/events","assignees_url":"https://api.github.com/repos/reed-college/lemur/assignees{/user}","branches_url":"https://api.github.com/repos/reed-college/lemur/branches{/branch}","tags_url":"https://api.github.com/repos/reed-college/lemur/tags","blobs_url":"https://api.github.com/repos/reed-college/lemur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reed-college/lemur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reed-college/lemur/git/refs{/sha}","trees_url":"https://api.github.com/repos/reed-college/lemur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reed-college/lemur/statuses/{sha}","languages_url":"https://api.github.com/repos/reed-college/lemur/languages","stargazers_url":"https://api.github.com/repos/reed-college/lemur/stargazers","contributors_url":"https://api.github.com/repos/reed-college/lemur/contributors","subscribers_url":"https://api.github.com/repos/reed-college/lemur/subscribers","subscription_url":"https://api.github.com/repos/reed-college/lemur/subscription","commits_url":"https://api.github.com/repos/reed-college/lemur/commits{/sha}","git_commits_url":"https://api.github.com/repos/reed-college/lemur/git/commits{/sha}","comments_url":"https://api.github.com/repos/reed-college/lemur/comments{/number}","issue_comment_url":"https://api.github.com/repos/reed-college/lemur/issues/comments{/number}","contents_url":"https://api.github.com/repos/reed-college/lemur/contents/{+path}","compare_url":"https://api.github.com/repos/reed-college/lemur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reed-college/lemur/merges","archive_url":"https://api.github.com/repos/reed-college/lemur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reed-college/lemur/downloads","issues_url":"https://api.github.com/repos/reed-college/lemur/issues{/number}","pulls_url":"https://api.github.com/repos/reed-college/lemur/pulls{/number}","milestones_url":"https://api.github.com/repos/reed-college/lemur/milestones{/number}","notifications_url":"https://api.github.com/repos/reed-college/lemur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reed-college/lemur/labels{/name}","releases_url":"https://api.github.com/repos/reed-college/lemur/releases{/id}","deployments_url":"https://api.github.com/repos/reed-college/lemur/deployments","created_at":"2016-05-18T16:24:19Z","updated_at":"2016-06-15T18:34:13Z","pushed_at":"2016-07-13T20:31:54Z","git_url":"git://github.com/reed-college/lemur.git","ssh_url":"git@github.com:reed-college/lemur.git","clone_url":"https://github.com/reed-college/lemur.git","svn_url":"https://github.com/reed-college/lemur","homepage":null,"size":5038,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"reed-college:master","ref":"master","sha":"e978a91ecc912b89362286d34ca7fe3bbf15e674","user":{"login":"reed-college","id":6775928,"avatar_url":"https://avatars.githubusercontent.com/u/6775928?v=3","gravatar_id":"","url":"https://api.github.com/users/reed-college","html_url":"https://github.com/reed-college","followers_url":"https://api.github.com/users/reed-college/followers","following_url":"https://api.github.com/users/reed-college/following{/other_user}","gists_url":"https://api.github.com/users/reed-college/gists{/gist_id}","starred_url":"https://api.github.com/users/reed-college/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reed-college/subscriptions","organizations_url":"https://api.github.com/users/reed-college/orgs","repos_url":"https://api.github.com/users/reed-college/repos","events_url":"https://api.github.com/users/reed-college/events{/privacy}","received_events_url":"https://api.github.com/users/reed-college/received_events","type":"Organization","site_admin":false},"repo":{"id":59132723,"name":"lemur","full_name":"reed-college/lemur","owner":{"login":"reed-college","id":6775928,"avatar_url":"https://avatars.githubusercontent.com/u/6775928?v=3","gravatar_id":"","url":"https://api.github.com/users/reed-college","html_url":"https://github.com/reed-college","followers_url":"https://api.github.com/users/reed-college/followers","following_url":"https://api.github.com/users/reed-college/following{/other_user}","gists_url":"https://api.github.com/users/reed-college/gists{/gist_id}","starred_url":"https://api.github.com/users/reed-college/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reed-college/subscriptions","organizations_url":"https://api.github.com/users/reed-college/orgs","repos_url":"https://api.github.com/users/reed-college/repos","events_url":"https://api.github.com/users/reed-college/events{/privacy}","received_events_url":"https://api.github.com/users/reed-college/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reed-college/lemur","description":"Bio data collector","fork":false,"url":"https://api.github.com/repos/reed-college/lemur","forks_url":"https://api.github.com/repos/reed-college/lemur/forks","keys_url":"https://api.github.com/repos/reed-college/lemur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reed-college/lemur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reed-college/lemur/teams","hooks_url":"https://api.github.com/repos/reed-college/lemur/hooks","issue_events_url":"https://api.github.com/repos/reed-college/lemur/issues/events{/number}","events_url":"https://api.github.com/repos/reed-college/lemur/events","assignees_url":"https://api.github.com/repos/reed-college/lemur/assignees{/user}","branches_url":"https://api.github.com/repos/reed-college/lemur/branches{/branch}","tags_url":"https://api.github.com/repos/reed-college/lemur/tags","blobs_url":"https://api.github.com/repos/reed-college/lemur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reed-college/lemur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reed-college/lemur/git/refs{/sha}","trees_url":"https://api.github.com/repos/reed-college/lemur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reed-college/lemur/statuses/{sha}","languages_url":"https://api.github.com/repos/reed-college/lemur/languages","stargazers_url":"https://api.github.com/repos/reed-college/lemur/stargazers","contributors_url":"https://api.github.com/repos/reed-college/lemur/contributors","subscribers_url":"https://api.github.com/repos/reed-college/lemur/subscribers","subscription_url":"https://api.github.com/repos/reed-college/lemur/subscription","commits_url":"https://api.github.com/repos/reed-college/lemur/commits{/sha}","git_commits_url":"https://api.github.com/repos/reed-college/lemur/git/commits{/sha}","comments_url":"https://api.github.com/repos/reed-college/lemur/comments{/number}","issue_comment_url":"https://api.github.com/repos/reed-college/lemur/issues/comments{/number}","contents_url":"https://api.github.com/repos/reed-college/lemur/contents/{+path}","compare_url":"https://api.github.com/repos/reed-college/lemur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reed-college/lemur/merges","archive_url":"https://api.github.com/repos/reed-college/lemur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reed-college/lemur/downloads","issues_url":"https://api.github.com/repos/reed-college/lemur/issues{/number}","pulls_url":"https://api.github.com/repos/reed-college/lemur/pulls{/number}","milestones_url":"https://api.github.com/repos/reed-college/lemur/milestones{/number}","notifications_url":"https://api.github.com/repos/reed-college/lemur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reed-college/lemur/labels{/name}","releases_url":"https://api.github.com/repos/reed-college/lemur/releases{/id}","deployments_url":"https://api.github.com/repos/reed-college/lemur/deployments","created_at":"2016-05-18T16:24:19Z","updated_at":"2016-06-15T18:34:13Z","pushed_at":"2016-07-13T20:31:54Z","git_url":"git://github.com/reed-college/lemur.git","ssh_url":"git@github.com:reed-college/lemur.git","clone_url":"https://github.com/reed-college/lemur.git","svn_url":"https://github.com/reed-college/lemur","homepage":null,"size":5038,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/9"},"html":{"href":"https://github.com/reed-college/lemur/pull/9"},"issue":{"href":"https://api.github.com/repos/reed-college/lemur/issues/9"},"comments":{"href":"https://api.github.com/repos/reed-college/lemur/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/reed-college/lemur/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/reed-college/lemur/statuses/5e7567d96e1cf828c2efb4c62bdc4895a9863299"}}}}
{"actor":{"display_login":"AIasd"}}