Преглед изворни кода

Add chart view when not auth'd

Colin Powell пре 2 година
родитељ
комит
d79159670e
2 измењених фајлова са 9 додато и 7 уклоњено
  1. 4 2
      vrobbler/apps/scrobbles/views.py
  2. 5 5
      vrobbler/templates/scrobbles/scrobble_list.html

+ 4 - 2
vrobbler/apps/scrobbles/views.py

@@ -117,9 +117,11 @@ class RecentScrobbleList(ListView):
                 "year": list(live_charts(**track, chart_period="year")),
                 "all": list(live_charts(**track)),
             }
+            data["counts"] = scrobble_counts(user)
+        else:
+            data["weekly_data"] = week_of_scrobbles()
+            data["counts"] = scrobble_counts()
 
-        # data["weekly_data"] = week_of_scrobbles(user=user)
-        data["counts"] = scrobble_counts(user)
         data["imdb_form"] = ScrobbleForm
         data["export_form"] = ExportScrobbleForm
         return data

+ 5 - 5
vrobbler/templates/scrobbles/scrobble_list.html

@@ -78,8 +78,9 @@
         </div>
     </div>
 
-    {% if show_chart %}
-    <canvas class="my-4 w-100" id="myChart" width="900" height="150"></canvas>
+    {% if not user.is_authenticated %}
+    <p>Today <b>{{counts.today}}</b> | This Week <b>{{counts.week}}</b> | This Month <b>{{counts.month}}</b> | This Year <b>{{counts.year}}</b> | All Time <b>{{counts.alltime}}</b></p>
+    <canvas class="my-4 w-100" id="myChart" width="900" height="300"></canvas>
     {% endif %}
 
     <div class="container">
@@ -434,8 +435,7 @@
 
         <div class="row">
         <h2>Last Scrobbles</h2>
-        <p>Today <b>{{counts.today}}</b> | This Week <b>{{counts.week}}</b> | This Month <b>{{counts.month}}</b> |
-            This Year <b>{{counts.year}}</b> | All Time <b>{{counts.alltime}}</b></p>
+        <p>Today <b>{{counts.today}}</b> | This Week <b>{{counts.week}}</b> | This Month <b>{{counts.month}}</b> | This Year <b>{{counts.year}}</b> | All Time <b>{{counts.alltime}}</b></p>
         </div>
         <div class="row">
             <ul class="nav nav-tabs" id="myTab" role="tablist">
@@ -670,7 +670,7 @@
             scales: {
                 yAxes: [{
                 ticks: {
-                    beginAtZero: false
+                    beginAtZero: true
                 }
                 }]
             },