Skip to content

Commit

Permalink
Merge branch 'bootstrap3'
Browse files Browse the repository at this point in the history
  • Loading branch information
jekil committed Aug 24, 2015
2 parents 8ec04fa + 5055409 commit 8edcd27
Show file tree
Hide file tree
Showing 93 changed files with 8,537 additions and 13,152 deletions.
15 changes: 15 additions & 0 deletions analyses/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ghiro - Copyright (C) 2013-2015 Ghiro Developers.
# This file is part of Ghiro.
# See the file 'docs/LICENSE.txt' for license terms.

from analyses.models import Case, Analysis

def dashboard_data(request):
"""Populate dashboard data showed on top of each page."""
open_cases_count = Case.objects.filter(state="O").count()
analyses_complete_count = Analysis.objects.filter(state="C").count()
analyses_wait_count = Analysis.objects.filter(state="W").count()

return {"open_cases_count": open_cases_count,
"analyses_complete_count": analyses_complete_count,
"analyses_wait_count": analyses_wait_count}
6 changes: 0 additions & 6 deletions analyses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,23 +705,17 @@ def dashboard(request):
request.session["sidebar_active"] = "side-dashboard"

users_count = Profile.objects.count()
open_cases_count = Case.objects.filter(state="O").count()
analyses_complete_count = Analysis.objects.filter(state="C").count()
last_cases = Case.objects.filter(state="O").filter(users=request.user).order_by("-created_at")[:5]
last_analyses = Analysis.objects.filter(state="C").filter(case__users=request.user).order_by("-created_at")[:5]
analyses_wait_count = Analysis.objects.filter(state="W").count()
completed_graph = Analysis.objects.filter(state="C").order_by("-created_at").extra({"created_at": "date(created_at)"}).values("created_at").annotate(counter=Count("pk"))[:30]
waiting_graph = Analysis.objects.filter(state="W").order_by("-created_at").extra({"created_at": "date(created_at)"}).values("created_at").annotate(counter=Count("pk"))[:30]
failed_graph = Analysis.objects.filter(state="F").order_by("-created_at").extra({"created_at": "date(created_at)"}).values("created_at").annotate(counter=Count("pk"))[:30]

return render_to_response("users/dashboard.html",
{
"users_count": users_count,
"open_cases_count": open_cases_count,
"analyses_complete_count": analyses_complete_count,
"last_cases": last_cases,
"last_analyses": last_analyses,
"analyses_wait_count": analyses_wait_count,
"completed_graph": completed_graph,
"waiting_graph": waiting_graph,
"failed_graph": failed_graph
Expand Down
3 changes: 3 additions & 0 deletions ghiro/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
LOGOUT_URL = "/users/logout/"
LOGIN_REDIRECT_URL = "/"

# Custom context processors.
TEMPLATE_CONTEXT_PROCESSORS += ("analyses.context_processors.dashboard_data", )

# Create log directory.
if not os.path.exists(LOG_DIR):
try:
Expand Down
9 changes: 0 additions & 9 deletions static/css/bootstrap-responsive.min.css

This file was deleted.

Loading

0 comments on commit 8edcd27

Please sign in to comment.