Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ticket:75 fix problem with cycle in resourse and fix js for map #50

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  p2psafety_django/events/api/resources/http.py
@@ -66,7 +66,7 @@ class Meta:
latest_update = fields.ForeignKey('events.api.resources.EventUpdateResource',
'latest_update',
full=True, null=True, readonly=True)
- supported = fields.ManyToManyField('events.api.resources.EventResource', 'supported', full=True, readonly=True)
+ supported = fields.ManyToManyField('events.api.resources.EventResource', 'supported', full=False, readonly=True)
@api_method(r'/(?P<pk>\d+)/support', name='api_events_support')
def support(self):
View
10 p2psafety_django/events/tests/test_api/test_resources_http.py
@@ -66,6 +66,16 @@ def test_get_list_eventupdates(self):
self.login_as_granted_user()
self.assertHttpOK(self.api_client.get(url, format='json'))
+ def test_event_suported(self):
+ self.login_as_granted_user()
+ event = EventFactory()
+ event2 = EventFactory()
+ event.supported.add(event2)
+ event2.supported.add(event)
+ url = self.events_list_url
+ resp = self.api_client.get(url)
+ self.assertEqual(resp.status_code, 200)
+
class EventTestCase(ModelsMixin, UsersMixin, ResourceTestCase):
View
14 p2psafety_django/static/js/map.js
@@ -70,16 +70,18 @@ mapApp.controller('EventListCtrl', function($scope, $http, $interval, urls, mapS
for (i in $scope.events) {
var event_support = $scope.events[i];
if(event_support.type=="support"){
- for (i in event_support.supported){
- var supported = event_support.supported[i];
- if(supported.id == event.id){
- $scope.selectedEventsupport[event_support.id] = event_support;
- }
+ for (var i = 0; i<event_support.supported.length; i++){
+ var supported_id = parseFloat(event_support.supported[i].split('/')[4]);
+ var supported = $scope.events[supported_id];
+ if(supported.id == event.id){
+ $scope.selectedEventsupport[event_support.id] = event_support;
+ }
}
}
}
for (var i = 0; i<event.supported.length; i++) {
- var supported = event.supported[i];
+ var supported_id = parseFloat(event.supported[i].split('/')[4]);
+ var supported = $scope.events[supported_id];
$scope.selectedEventsupported[supported.id] = supported;
}
};
Something went wrong with that request. Please try again.