diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-08 12:04:45 +0300 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-08 12:04:45 +0300 |
| commit | 958d67efbe6724d5b1b4cd56347e44464bc74d7d (patch) | |
| tree | 691486278592e013fa83f9b5341f51eeadf14d42 | |
| parent | 693a23d17c8783e51a97fd5a2439b5d1ceaa003c (diff) | |
Add job to models
| -rw-r--r-- | opendc/models/job.py | 19 | ||||
| -rw-r--r-- | opendc/models/task.py | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/opendc/models/job.py b/opendc/models/job.py new file mode 100644 index 00000000..fb133a72 --- /dev/null +++ b/opendc/models/job.py @@ -0,0 +1,19 @@ +from opendc.models.model import Model + +class Job(Model): + + JSON_TO_PYTHON_DICT = { + 'Job': { + 'id': 'id', + 'name': 'name' + } + } + + TABLE_NAME = 'jobs' + COLUMNS = ['id', 'name'] + COLUMNS_PRIMARY_KEY = ['id'] + + def google_id_has_at_least(self, google_id, authorization_level): + """Return True if the user has at least the given auth level over this Job.""" + + return authorization_level not in ['EDIT', 'OWN'] diff --git a/opendc/models/task.py b/opendc/models/task.py index aa9838a5..da0f5785 100644 --- a/opendc/models/task.py +++ b/opendc/models/task.py @@ -7,14 +7,14 @@ class Task(Model): 'id': 'id', 'startTick': 'start_tick', 'totalFlopCount': 'total_flop_count', - 'traceId': 'trace_id', + 'jobId': 'job_id', 'taskDependencyId': 'task_dependency_id', 'parallelizability': 'parallelizability' } } TABLE_NAME = 'tasks' - COLUMNS = ['id', 'start_tick', 'total_flop_count', 'trace_id', 'task_dependency_id', 'parallelizability'] + COLUMNS = ['id', 'start_tick', 'total_flop_count', 'job_id', 'task_dependency_id', 'parallelizability'] COLUMNS_PRIMARY_KEY = ['id'] def google_id_has_at_least(self, google_id, authorization_level): |
