Skip to content

Commit

Permalink
11 - Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codingforentrepreneurs committed Nov 17, 2017
1 parent dd8a626 commit fe47842
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/analytics/templates/analytics/sales.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,24 @@ <h1>Sales Data</h1>
<h3>Today's sales</h3>
<hr/>
<p>Recent Total: ${{ today.recent_data.total__sum }}</p>
<ol>
<ul>
{% for order in today.recent|slice:":5" %}
<li>{{ order.order_id }}
{{ order.total }}
{{ order.updated }}</li>
<li class='my-3'>Order #{{ order.order_id }}<br/>
${{ order.total }}<br/>
{{ order.updated|timesince }} ago</li>
{% endfor %}
</ol>
</ul>

<h3>This week's sales</h3>
<hr/>
<p>Recent Total: ${{ this_week.recent_data.total__sum }}</p>
<ol>
<ul>
{% for order in this_week.recent|slice:":5" %}
<li>{{ order.order_id }}
{{ order.total }}
{{ order.updated }}</li>
<li class='my-3'>Order #{{ order.order_id }}<br/>
${{ order.total }}<br/>
{{ order.updated|timesince }} ago</li>
{% endfor %}
</ol>
</ul>
</div>

<div class='col'>
Expand Down
7 changes: 4 additions & 3 deletions src/analytics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ def dispatch(self, *args, **kwargs):

def get_context_data(self, *args, **kwargs):
context = super(SalesView, self).get_context_data(*args, **kwargs)
#two_weeks_ago = timezone.now() - datetime.timedelta(days=14)
#one_week_ago = timezone.now() - datetime.timedelta(days=7)
qs = Order.objects.all().by_weeks_range(weeks_ago=10, number_of_weeks=10)
context['today'] = qs.by_range(start_date=timezone.now().date()).get_sales_breakdown()
start_date = timezone.now().date() - datetime.timedelta(hours=24)
end_date = timezone.now().date() + datetime.timedelta(hours=12)
today_data = qs.by_range(start_date=start_date, end_date=end_date).get_sales_breakdown()
context['today'] = today_data
context['this_week'] = qs.by_weeks_range(weeks_ago=1, number_of_weeks=1).get_sales_breakdown()
context['last_four_weeks'] = qs.by_weeks_range(weeks_ago=5, number_of_weeks=4).get_sales_breakdown()
return context

0 comments on commit fe47842

Please sign in to comment.