Skip to content

Commit

Permalink
Added route checking before add to route to prevent duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinluvian committed May 2, 2017
1 parent dd7e393 commit 0c98204
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rest_framework_extensions/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,27 @@ def get_routes(self, viewset):
if self.is_dynamic_route(route):
# Dynamic routes (@list_route or @detail_route decorator)
if self.is_list_dynamic_route(route):
ret += self.get_dynamic_routes_instances(
temporary_route_list = self.get_dynamic_routes_instances(
viewset,
route,
self._filter_by_list_dynamic_routes(dynamic_routes)
)
for temporary_route in temporary_route_list:
if temporary_route not in ret:
ret.append(temporary_route)
else:
ret += self.get_dynamic_routes_instances(
temporary_route_list = self.get_dynamic_routes_instances(
viewset,
route,
self._filter_by_detail_dynamic_routes(dynamic_routes)
)
for temporary_route in temporary_route_list:
if temporary_route not in ret:
ret.append(temporary_route)
else:
# Standard route
ret.append(route)
if route not in ret:
ret.append(route)

return ret

Expand Down

0 comments on commit 0c98204

Please sign in to comment.