Exemplo n.º 1
0
def create_results():
    """Create results when migrating."""
    from pybossa.core import project_repo, task_repo, result_repo
    from pybossa.model.result import Result

    projects = project_repo.filter_by(published=True)

    for project in projects:
        print "Working on project: %s" % project.short_name
        tasks = task_repo.filter_tasks_by(state='completed',
                                          project_id=project.id)
        print "Analyzing %s tasks" % len(tasks)
        for task in tasks:
            result = result_repo.get_by(project_id=project.id, task_id=task.id)
            if result is None:
                result = Result(project_id=project.id,
                                task_id=task.id,
                                task_run_ids=[tr.id for tr in task.task_runs],
                                last_version=True)
                db.session.add(result)
        db.session.commit()
        print "Project %s completed!" % project.short_name
Exemplo n.º 2
0
    def test_admin_user_cannot_save_results(self):
        """Test admin users cannot save results of a specific project"""

        result = Result()

        assert_raises(Forbidden, ensure_authorized_to, 'create', result)
Exemplo n.º 3
0
    def test_anonymous_user_cannot_save_results(self):
        """Test anonymous users cannot save results of a specific project"""

        result = Result()

        assert_raises(Unauthorized, ensure_authorized_to, 'create', result)
Exemplo n.º 4
0
    def test_authenticated_user_cannot_delete_results(self):
        """Test authenticated users cannot delete results of a specific project"""

        result = Result()

        assert_raises(Forbidden, ensure_authorized_to, 'delete', result)
Exemplo n.º 5
0
    def test_admin_user_can_save_results(self):
        """Test admin users cannot save results of a specific project"""

        result = Result()

        assert ensure_authorized_to('create', result)