def test_format_new_projects(self):
     """Test format new projects works."""
     p = ProjectFactory.create()
     new_projects_week()
     res = format_new_projects()
     day = datetime.utcnow().strftime('%Y-%m-%d')
     res = res[0]
     assert res['day'].strftime('%Y-%m-%d') == day, res['day']
     assert res['id'] == p.id
     assert res['short_name'] == p.short_name
     assert res['p_name'] == p.name
     assert res['email_addr'] == p.owner.email_addr
     assert res['owner_id'] == p.owner.id
     assert res['u_name'] == p.owner.name
 def test_format_new_projects(self):
     """Test format new projects works."""
     p = ProjectFactory.create()
     new_projects_week()
     res = format_new_projects()
     day = datetime.utcnow().strftime('%Y-%m-%d')
     res = res[0]
     assert res['day'].strftime('%Y-%m-%d') == day, res['day']
     assert res['id'] == p.id
     assert res['short_name'] == p.short_name
     assert res['p_name'] == p.name
     assert res['email_addr'] == p.owner.email_addr
     assert res['owner_id'] == p.owner.id
     assert res['u_name'] == p.owner.name
Example #3
0
def dashboard():
    """Show PyBossa Dashboard."""
    try:
        if request.args.get('refresh') == '1':
            db_jobs = get_dashboard_jobs()
            for j in db_jobs:
                DASHBOARD_QUEUE.enqueue(j['name'])
            msg = gettext('Dashboard jobs enqueued,'
                          ' refresh page in a few minutes')
            flash(msg)
        active_users_last_week = dashb.format_users_week()
        active_anon_last_week = dashb.format_anon_week()
        new_projects_last_week = dashb.format_new_projects()
        update_projects_last_week = dashb.format_update_projects()
        new_tasks_week = dashb.format_new_tasks()
        new_task_runs_week = dashb.format_new_task_runs()
        new_users_week = dashb.format_new_users()
        returning_users_week = dashb.format_returning_users()
        update_feed = get_update_feed()

        return render_template(
            'admin/dashboard.html',
            title=gettext('Dashboard'),
            active_users_last_week=active_users_last_week,
            active_anon_last_week=active_anon_last_week,
            new_projects_last_week=new_projects_last_week,
            update_projects_last_week=update_projects_last_week,
            new_tasks_week=new_tasks_week,
            new_task_runs_week=new_task_runs_week,
            new_users_week=new_users_week,
            returning_users_week=returning_users_week,
            update_feed=update_feed,
            wait=False)
    except ProgrammingError as e:
        return render_template('admin/dashboard.html',
                               title=gettext('Dashboard'),
                               wait=True)
    except Exception as e:  # pragma: no cover
        current_app.logger.error(e)
        return abort(500)
Example #4
0
def dashboard():
    """Show PyBossa Dashboard."""
    try:
        if request.args.get('refresh') == '1':
            db_jobs = get_dashboard_jobs()
            for j in db_jobs:
                DASHBOARD_QUEUE.enqueue(j['name'])
            msg = gettext('Dashboard jobs enqueued,'
                          ' refresh page in a few minutes')
            flash(msg)
        active_users_last_week = dashb.format_users_week()
        active_anon_last_week = dashb.format_anon_week()
        new_projects_last_week = dashb.format_new_projects()
        update_projects_last_week = dashb.format_update_projects()
        new_tasks_week = dashb.format_new_tasks()
        new_task_runs_week = dashb.format_new_task_runs()
        new_users_week = dashb.format_new_users()
        returning_users_week = dashb.format_returning_users()
        update_feed = get_update_feed()

        return render_template('admin/dashboard.html',
                               title=gettext('Dashboard'),
                               active_users_last_week=active_users_last_week,
                               active_anon_last_week=active_anon_last_week,
                               new_projects_last_week=new_projects_last_week,
                               update_projects_last_week=update_projects_last_week,
                               new_tasks_week=new_tasks_week,
                               new_task_runs_week=new_task_runs_week,
                               new_users_week=new_users_week,
                               returning_users_week=returning_users_week,
                               update_feed=update_feed,
                               wait=False)
    except ProgrammingError as e:
        return render_template('admin/dashboard.html',
                               title=gettext('Dashboard'),
                               wait=True)
    except Exception as e:  # pragma: no cover
        current_app.logger.error(e)
        return abort(500)