Exemple #1
0
    def test_personal_dashboards(self):
        """Just run through it to make sure there aren't obvious explosions."""
        g = Group.objects.create(name='losers')
        u = user(save=True)
        u.groups.add(g)

        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='2')
        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')

        class MockRequest(object):
            user = u

        request = MockRequest()
        dashes = personal_dashboards(request)
        # Sort order of the two DictDashboards is indeterminite at the moment.
        assert dashes in [[
            ReviewDashboard(request),
            DictDashboard(request, '1'),
            DictDashboard(request, '2')
        ],
                          [
                              ReviewDashboard(request),
                              DictDashboard(request, '2'),
                              DictDashboard(request, '1')
                          ]]
Exemple #2
0
def personal_dashboard_tabs(context, active_tab):
    """Render the tabs for the user/group dashboard."""
    c = {'dashboards': personal_dashboards(context['request']),
         'user': context['request'].user,
         'active_tab': active_tab}
    t = env.get_template('dashboards/includes/personal_tabs.html').render(**c)
    return jinja2.Markup(t)
Exemple #3
0
def default_dashboard(request):
    dashboards = personal_dashboards(request)
    if len(dashboards) > 0:
        # Redirect to the first dashboard
        return HttpResponseRedirect(dashboards[0].get_absolute_url())
    else:
        # Redirect to the profile page
        return HttpResponseRedirect(profile_url(request.user))
Exemple #4
0
def default_dashboard(request):
    dashboards = personal_dashboards(request)
    if len(dashboards) > 0:
      # Redirect to the first dashboard
      return HttpResponseRedirect(dashboards[0].get_absolute_url())
    else:
      # Redirect to the profile page
      return HttpResponseRedirect(profile_url(request.user))
Exemple #5
0
def personal_dashboard_tabs(context, active_tab):
    """Render the tabs for the user/group dashboard."""
    c = {
        'dashboards': personal_dashboards(context['request']),
        'user': context['request'].user,
        'active_tab': active_tab
    }
    t = env.get_template('dashboards/includes/personal_tabs.html').render(**c)
    return jinja2.Markup(t)
Exemple #6
0
def personal_dashboard_tabs(context, active_tab):
    """Render the tabs for the user/group dashboard."""
    c = {
        "dashboards": personal_dashboards(context["request"]),
        "user": context["request"].user,
        "active_tab": active_tab,
        "request": context["request"],
    }
    t = env.get_template("dashboards/includes/personal_tabs.html").render(c)
    return jinja2.Markup(t)
Exemple #7
0
    def test_personal_dashboards(self):
        """Just run through it to make sure there aren't obvious explosions."""
        g = group(name='winners', save=True)
        g2 = group(name='losers', save=True)
        u = user(save=True)
        u.groups.add(g)
        u.groups.add(g2)

        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
        GroupDashboard.objects.create(group=g2, dashboard='sea',
                                      parameters='3')

        class MockRequest(object):
            user = u

        request = MockRequest()
        dashes = personal_dashboards(request)
        # Sort order of the two ATestDashboards is by group name.
        eq_(2, len(dashes))
        eq_('3', dashes[0].parameters)
        eq_(g, dashes[1].group)
Exemple #8
0
    def test_personal_dashboards(self):
        """Just run through it to make sure there aren't obvious explosions."""
        g = group(name='winners', save=True)
        g2 = group(name='losers', save=True)
        u = user(save=True)
        u.groups.add(g)
        u.groups.add(g2)

        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
        GroupDashboard.objects.create(group=g2,
                                      dashboard='sea',
                                      parameters='3')

        class MockRequest(object):
            user = u

        request = MockRequest()
        dashes = personal_dashboards(request)
        # Sort order of the two ATestDashboards is by group name.
        eq_(2, len(dashes))
        eq_('3', dashes[0].parameters)
        eq_(g, dashes[1].group)
Exemple #9
0
    def test_personal_dashboards(self):
        """Just run through it to make sure there aren't obvious explosions."""
        g = Group.objects.create(name='losers')
        u = user(save=True)
        u.groups.add(g)

        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='2')
        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')

        class MockRequest(object):
            user = u

        request = MockRequest()
        dashes = personal_dashboards(request)
        # Sort order of the two DictDashboards is indeterminite at the moment.
        assert dashes in [[ReviewDashboard(request),
                           DictDashboard(request, '1'),
                           DictDashboard(request, '2')],
                          [ReviewDashboard(request),
                           DictDashboard(request, '2'),
                           DictDashboard(request, '1')]]