Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 22ef953

Browse files
committed
Merge pull request #273 from ialja/master
using get_or_create when testing for group membership
2 parents 694ebf5 + 2752f4f commit 22ef953

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

static/js/events.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ var Codeweek = window.Codeweek || {};
6666
map = new google.maps.Map(document.getElementById('view-event-map'), mapOptions);
6767
}
6868

69-
function updateAddress(new_position) {
69+
function updateCountrySelection(country) {
70+
var choice = document.getElementById('id_country');
71+
selectItemByValue(choice, country);
72+
}
73+
74+
function updateAddress(new_latLng) {
7075
geocoder = new google.maps.Geocoder();
71-
geocoder.geocode({'latLng': new_position}, function (results, status) {
76+
geocoder.geocode({'latLng': new_latLng}, function (results, status) {
7277
if (status === google.maps.GeocoderStatus.OK) {
7378
document.getElementById("autocomplete").value = results[0].formatted_address;
79+
// the last item in the geocoder for latLng results array is the country
80+
var country = results[results.length - 1].address_components[0].short_name
81+
updateCountrySelection(country);
7482
}
7583
});
7684
}
@@ -107,30 +115,22 @@ var Codeweek = window.Codeweek || {};
107115
}
108116
}
109117

110-
function fillInAddress() {
111-
var i,
112-
component,
113-
choice,
114-
place = autocomplete.getPlace(),
115-
components = place.address_components,
116-
country = null,
117-
output = autocomplete.getPlace().geometry.location,
118-
outputLat = output.lat(),
119-
outputLng = output.lng(),
120-
locLatlng = new google.maps.LatLng(outputLat, outputLng);
121-
122-
document.getElementById("id_geoposition_0").value = outputLat;
123-
document.getElementById("id_geoposition_1").value = outputLng;
124-
125-
createMarker(locLatlng);
126-
for (i = 0; component = components[i]; i = i + 1) {
127-
if (component.types[0] === 'country') {
128-
country = component.short_name;
129-
choice = document.getElementById('id_country');
130-
selectItemByValue(choice, country);
118+
function listenForPastedAddress() {
119+
var address_field = document.getElementById('autocomplete');
120+
address_field.addEventListener('focusout',function () {
121+
var address_value = address_field.value;
122+
if (address_value) {
123+
getAddress(address_value);
131124
}
132-
}
125+
}, true);
126+
}
133127

128+
function fillInAddress() {
129+
// geoLatLng contains the Google Maps geocoded latitude, longitude
130+
var geoLatLng = autocomplete.getPlace().geometry.location;
131+
132+
createMarker(geoLatLng);
133+
updateAddress(geoLatLng);
134134
}
135135

136136
function auto_complete() {
@@ -155,6 +155,7 @@ var Codeweek = window.Codeweek || {};
155155
var updated_location = results[0].geometry.location;
156156
createMarker(updated_location);
157157
updateLatLng(updated_location.lat(), updated_location.lng());
158+
updateAddress(updated_location);
158159
}
159160
});
160161
}
@@ -165,7 +166,7 @@ var Codeweek = window.Codeweek || {};
165166
createMap(initialCenter, 4);
166167
auto_complete();
167168
getAddress(address);
168-
169+
listenForPastedAddress();
169170
}
170171

171172
var add = function (address) {

web/tests/test_user_processors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ def setUp(self):
3030
pub_date=datetime.datetime.now(),
3131
tags=["tag1", "tag2"])
3232

33-
@pytest.mark.xfail
3433
def test_get_ambassadors_for_country(self):
3534
self.up1.country = "SI"
3635
self.up1.save()
3736

38-
group = Group.objects.get(name="ambassadors")
37+
# temporary workaround because South migrations don't work yet
38+
# fix me in the future
39+
group, created = Group.objects.get_or_create(name="ambassadors")
40+
if created:
41+
group.save()
3942

4043
group.user_set.add(self.u1)
4144

0 commit comments

Comments
 (0)