Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Oct 17, 2017
1 parent 79ffeec commit e5ad336
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
6 changes: 4 additions & 2 deletions orchestra/interface_api/project_management/views.py
@@ -1,4 +1,6 @@
import slacker

from django.shortcuts import get_object_or_404
from jsonview.exceptions import BadRequest
from rest_framework import generics
from rest_framework import permissions
Expand Down Expand Up @@ -41,12 +43,12 @@ def project_information_api(request):
"""
This function is used by both the project management interface
(project admins only) and for providing project information to
experts (only to experts associated with a project). We enfoce
experts (only to experts associated with a project). We enforce
both of these permissions in the view below.
"""
project_id = load_encoded_json(request.body)['project_id']
worker = Worker.objects.get(user=request.user)
worker = get_object_or_404(Worker, user=request.user)
if not (is_project_admin(request.user) or
worker.assignments.filter(task__project=project_id).exists()):
raise BadRequest('Permission denied')
Expand Down
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-10-09 18:00
# Generated by Django 1.9.13 on 2017-10-17 13:29
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import orchestra.models.core.mixins
import orchestra.utils.models


Expand All @@ -25,6 +26,11 @@ class Migration(migrations.Migration):
('completed', models.BooleanField(default=False)),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='todos', to='orchestra.Task')),
],
bases=(orchestra.utils.models.DeleteMixin, models.Model),
bases=(orchestra.models.core.mixins.TodoMixin, orchestra.utils.models.DeleteMixin, models.Model),
),
migrations.AlterField(
model_name='taskassignment',
name='worker',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='orchestra.Worker'),
),
]
21 changes: 0 additions & 21 deletions orchestra/migrations/0071_auto_20171015_2303.py

This file was deleted.

Expand Up @@ -64,8 +64,8 @@ export function orchestraService () {

export function orchestraTasks ($http) {
'ngAnnotate'
const activeState = (task) => task.state === 'in_progress' || task.state === 'returned' || task.state === 'just_added'
const pendingState = (task) => task.state === 'pending_review' || task.state === 'pending_processing'
const activeState = (task) => ['just_added', 'in_progress', 'returned'].indexOf(task.state) !== -1
const pendingState = (task) => ['pending_review', 'pending_processing'].indexOf(task.state) !== -1
const activeTask = (task) => activeState(task) && task.should_be_active
const pendingTask = (task) => (activeState(task) && !task.should_be_active) || pendingState(task)

Expand Down

0 comments on commit e5ad336

Please sign in to comment.