Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7518ded
Tweak CSV report to generate start and stop dates
mrchrisadams Aug 31, 2016
dc07bec
Move huge dashboard date code stanza into helper function.
mrchrisadams Sep 1, 2016
efe54a2
Show the date of your skipped collection on dashboard
mrchrisadams Sep 1, 2016
61cd232
Only show weeks as skipped until the Wednesday
mrchrisadams Sep 1, 2016
20acc23
Update dashboard to bring in line with patternlab
mrchrisadams Sep 1, 2016
264cab9
Tweak font size and salutation
mrchrisadams Sep 1, 2016
28f0c4f
Add check to show message about not being able to change order
mrchrisadams Sep 1, 2016
a995b86
only show link to instructions when they exist
mrchrisadams Sep 1, 2016
1833a14
WIP Starting over
mrchrisadams Sep 2, 2016
0a54e46
Build collections list in the view now
mrchrisadams Sep 2, 2016
232bd1c
Pushing WIP to talk through on the PR
mrchrisadams Sep 2, 2016
8a25c31
First pass at leaflet handling for map
mrchrisadams Sep 6, 2016
2a6e881
Remove overly precise, but innacurate dates for changing order in ord…
mrchrisadams Sep 6, 2016
0eb656b
Fix the python def'ing gotcha for billing week
mrchrisadams Sep 8, 2016
f099815
Add leaflet map instead of basic google iframe
mrchrisadams Sep 8, 2016
5bab15a
Add pick up list as a GET request like old blue world
mrchrisadams Sep 8, 2016
a0a72f5
Update the dashboard to show absolute dates
mrchrisadams Sep 8, 2016
f6dc6a3
Update dashboard look some more
mrchrisadams Sep 8, 2016
1dfd852
Add copy and style changes on other main pages
mrchrisadams Sep 8, 2016
e96dde5
Last few copy fixes, and tweaks to spacing
mrchrisadams Sep 8, 2016
953841a
Change around the helper copy on the your bags menu
mrchrisadams Sep 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions billing_week.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,39 @@ def parse_billing_week(billing_week_string):
week,
)

def next_n_billing_weeks(n, bw, billing_weeks=None):
"""
Takes a number of billing weeks and a starting billing week, and returns
a list of billing weeks
"""
if billing_weeks is None:
billing_weeks = []
if n > len(billing_weeks):
billing_weeks.append(bw.next())
return next_n_billing_weeks(n, bw.next(), billing_weeks)
else:
return billing_weeks

def prev_n_billing_weeks(n, bw, billing_weeks=None):
if billing_weeks is None:
billing_weeks = []
if n > len(billing_weeks):
billing_weeks.append(bw.prev())
return prev_n_billing_weeks(n, bw.prev(), billing_weeks)
else:
return billing_weeks


def next_valid_billing_week(bw, billing_week_strings):
"""
Takes a billing week, and a set of skipped billing weeks, and steps forward
until it finds a week that isni't in the skipped set
"""
if str(bw) in billing_week_strings:
return next_valid_billing_week(bw.next(), billing_week_strings)
else:
return bw


if __name__ == '__main__':

Expand Down Expand Up @@ -539,4 +572,26 @@ def test_billing_weeks_left_in_month(self):
self.assertEqual(len(
billing_weeks_left_in_the_month("2016-06 1")), 4)

def test_next_n_billing_weeks_returns_right_no_of_billing_weeks(self):
utc = pytz.timezone("UTC")
s = utc.localize(datetime.datetime(2016, 9, 2, 0))
last_bw_in_aug = get_billing_week(s)
self.assertEqual(
len(next_n_billing_weeks(5, last_bw_in_aug)), 5)

def test_prev_n_billing_weeks_returns_next_billing_week(self):
utc = pytz.timezone("UTC")
s = utc.localize(datetime.datetime(2016, 9, 2, 0))
last_bw_in_aug = get_billing_week(s)
self.assertNotIn(
last_bw_in_aug,
prev_n_billing_weeks(5, last_bw_in_aug))

def test_prev_n_billing_weeks_returns_right_no_of_billing_weeks(self):
utc = pytz.timezone("UTC")
s = utc.localize(datetime.datetime(2016, 9, 2, 0))
last_bw_in_aug = get_billing_week(s)
self.assertEqual(
len(prev_n_billing_weeks(5, last_bw_in_aug)), 5)

unittest.main()
2 changes: 2 additions & 0 deletions blueworld/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.humanize',
'django.contrib.staticfiles',
# The Django sites framework is required for allauth
'django.contrib.sites',
Expand All @@ -71,6 +72,7 @@

if DEBUG:
INSTALLED_APPS.append('django_extensions')
INSTALLED_APPS.append('debug_toolbar')


RQ_QUEUES = {
Expand Down
10 changes: 10 additions & 0 deletions blueworld/static/blueworld/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18995,3 +18995,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

// Trigger foundation to add the effects we want
$(document).foundation();


$(document).ready(function() {
$('.collection-point-info .instructions').hide()
$('.collection-point-info a').click(function(event) {

$(this).parent().find('.instructions').slideToggle("fast");

});
});
62 changes: 62 additions & 0 deletions blueworld/static/blueworld/collection-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
jQuery(document).ready(function($) {
var mymap = L.map('collection-map').setView([51.557853, -0.073096], 13);
var popup = L.popup();

L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoibXJjaHJpc2FkYW1zIiwiYSI6InFobnRZRzQifQ.jLPeG4HV4RiCL8RVNPBTwg', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
}).addTo(mymap);

function showLocation(e) {
// update popup to show name
var p = this.popup, loc = this.loc, mymap = this.leafletmap;
p.setContent("<p><strong>" + loc.name + "</strong></p><p><small>" + loc.location + "</small></p>");
p.setLatLng(e.latlng);
p.openOn(mymap);
}

// accepts a set of coordinates and returns a leaflet marker if they're
// usable
function createMarker(loc) {

// check for None's coming through from django
if (loc.longitude === "None" || loc.latitude == "None"){
return false
}
// if we have both coords, we can create a marker
if (loc.longitude && loc.latitude) {
return L.marker([loc.latitude, loc.longitude])
}
// otherwise assume we didn't have the required attributes
return false
}

GC.markers = {}
GC.activeMarker = "";

$.each(GC.locations, function(k, loc) {
// only try to place a marker if we have coords to place with
newMarker = createMarker(loc)
if (newMarker) {
newMarker
.addTo(mymap)
.bindPopup("<p><strong>" + loc.name + "</strong></p><p><small>" + loc.location + "</small></p>");
GC.markers[k] = { id: k, marker: newMarker};
}

// add listener on the inputs
$('.collection-points ul li').on('mouseover', function(event) {
var marker = $(this).find('input').attr('id');

if (marker !== GC.activeMarker){
GC.activeMarker = marker;
GC.markers[marker].marker.fire('click');
}
})
})


// add listener to find marker with the `id_collection_point_0` id,
// so it is highlighted when selected.

});
53 changes: 46 additions & 7 deletions blueworld/static/blueworld/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@ select {
display: block;
margin-right: 0; } }

.errorlist,
.callout {
margin: 0 0 1rem 0;
padding: 1rem;
Expand Down Expand Up @@ -3519,7 +3520,7 @@ table.hover tr:nth-of-type(even):hover {

h1, h2, h3, .font-display {
font-family: "GC Display", "Impact", "Arial", sans-serif;
}
text-transform: uppercase; }

.font-text {
font-family: "Domaine Text Regular", "Times New Roman", Georgia, serif;
Expand All @@ -3543,6 +3544,9 @@ a {
.global-nav {
margin-bottom: 1rem; }

#billing-dates li.past p {
color: #e6e6e6; }

.tagline {
display: inline; }

Expand All @@ -3554,13 +3558,14 @@ a {
text-align: center; }
.header .logo {
max-width: 75px;
margin-right: 30px;
margin-left: 20px;
margin-top: 20px; }
margin-right: 1rem;
margin-left: 1rem;
margin-top: 1rem;
margin-bottom: 1rem; }
.header h2 {
text-transform: uppercase;
display: inline-block;
font-size: 200%;
font-size: 3rem;
margin-top: 0.5em; }
.header nav .menu {
background-color: #ccc; }
Expand All @@ -3573,6 +3578,15 @@ a {
h3.font-text {
max-width: 30em; }

.current-choice,
.this_week {
background: #EEE;
padding: 1rem;
margin-bottom: 1rem; }

.next_week {
padding: 1rem; }

fieldset.collection-points label {
font-size: 120%;
font-weight: bold; }
Expand All @@ -3595,6 +3609,26 @@ fieldset.collection-points ul > li.columns:last-child:not(:first-child) {
padding: 0.5rem;
margin-left: 0; }

.this_week p,
.this_week h4{
font-size: 1.5rem;
}
.this_week .instructions p{
font-size: 1rem;
}

.this_week ul li {
font-size: 1.5rem; }

.instructions {
padding: 1rem;
font-size: 1rem;
max-width: 40rem;
border-top: 1px solid #cacaca;
background-color: #e6e6e6; }
.instructions p {
max-width: 40em; }

.callout {
background-color: #e6e6e6; }

Expand All @@ -3607,6 +3641,11 @@ fieldset.collection-points ul > li.columns:last-child:not(:first-child) {
margin-right: auto; }


#billing-dates li.past p{
color:grey;
div.skipped h5,
div.skipped li{
color: #999;
}

.greeting{
font-size:2em;
}
57 changes: 57 additions & 0 deletions blueworld/templates/admin/join/customer/change_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% extends "admin/change_list.html" %}
{% load i18n admin_urls admin_static admin_list %}

{% block content %}

{% include "partials/dashboard_stats.html" %}


<div id="content-main">
{% block object-tools %}
{% if has_add_permission %}
<ul class="object-tools">
{% block object-tools-items %}
<li>
{% url cl.opts|admin_urlname:'add' as add_url %}
<a href="{% add_preserved_filters add_url is_popup to_field %}" class="addlink">
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
</a>
</li>
{% endblock %}
</ul>
{% endif %}
{% endblock %}
{% if cl.formset.errors %}
<p class="errornote">
{% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
</p>
{{ cl.formset.non_form_errors }}
{% endif %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}{% search_form cl %}{% endblock %}
{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

{% block filters %}
{% if cl.has_filters %}
<div id="changelist-filter">
<h2>{% trans 'Filter' %}</h2>
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
</div>
{% endif %}
{% endblock %}

<form id="changelist-form" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
{% if cl.formset %}
<div>{{ cl.formset.management_form }}</div>
{% endif %}

{% block result_list %}
{% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
{% result_list cl %}
{% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
{% endblock %}
{% block pagination %}{% pagination cl %}{% endblock %}
</form>
</div>
</div>
{% endblock %}
7 changes: 5 additions & 2 deletions blueworld/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@

</div>
</div>
{% include "partials/footer.html" %}
<script src="{% static 'blueworld/application.js' %}" charset="utf-8"></script>

{% include "partials/footer.html" %}

{% block extra_scripts %}
{% endblock %}

</body>
</html>
17 changes: 15 additions & 2 deletions blueworld/templates/collection_point.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base_join.html" %}

{% load staticfiles %}
{% block head_title %}Join{% endblock %}
{% block extra_head %}
<script>
Expand All @@ -14,7 +14,13 @@
<div class="row">
<h3 class="font-text">Where do you want to collect your bag from?</h3>

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d39696.91748585319!2d-0.09553839804747107!3d51.548847512570475!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x48761cefef8e8c05%3A0xc5b1fb59d8196f2c!2sLondon+Borough+of+Hackney%2C+Greater+London!5e0!3m2!1sen!2suk!4v1465560067568" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.0-rc.3/dist/leaflet.css" />

<script src="https://unpkg.com/leaflet@1.0.0-rc.3/dist/leaflet.js"></script>

<div id="collection-map" style="height:450px;width:600px;">

</div>

{% if form.non_form_errors or form.errors %}
<div id="errors" class="callout alert errors">
Expand All @@ -25,6 +31,9 @@ <h3 class="font-text">Where do you want to collect your bag from?</h3>






<form action="{% url 'join_collection_point' %}" method="post">
{% csrf_token %}
<fieldset class="columns collection-points">
Expand Down Expand Up @@ -53,3 +62,7 @@ <h3 class="font-text">Where do you want to collect your bag from?</h3>
{% endblock %}
{% block extra_body %}
{% endblock %}

{% block extra_scripts %}
<script src="{% static 'blueworld/collection-map.js' %}" charset="utf-8"></script>
{% endblock %}
Loading