Skip to content

Commit 9f99604

Browse files
committed
revert enforced controller revert
1 parent 53ebd0c commit 9f99604

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

ninja_extra/controllers/base.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,9 @@ def __call__(self, cls: ControllerClassType) -> ControllerClassType:
501501
self.tags = [class_name]
502502

503503
self._controller_class = cls
504-
if not self.urls_namespace:
505-
# if urls_namespace is not provided, use the class name as the namespace
506-
self.urls_namespace = class_name
507-
504+
# if not self.urls_namespace:
505+
# # if urls_namespace is not provided, use the class name as the namespace
506+
# self.urls_namespace = class_name
508507
if issubclass(cls, ModelControllerBase):
509508
if cls.model_config:
510509
assert cls.service_type is not None, (
@@ -563,7 +562,6 @@ def add_controller_route_function(self, route_function: RouteFunction) -> None:
563562

564563
def urls_paths(self, prefix: str) -> Iterator[Union[URLPattern, URLResolver]]:
565564
namespaced_patterns: List[URLPattern] = []
566-
assert self.urls_namespace, "urls_namespace is required"
567565

568566
for path, path_view in self.path_operations.items():
569567
path = path.replace("{", "<").replace("}", ">")
@@ -575,14 +573,14 @@ def urls_paths(self, prefix: str) -> Iterator[Union[URLPattern, URLResolver]]:
575573
for op in path_view.operations:
576574
op = cast(Operation, op)
577575
view = path_view.get_view()
578-
if op.url_name:
579-
pattern = django_path(route, view, name=op.url_name)
580-
else:
581-
pattern = django_path(route, view)
576+
pattern = django_path(route, view, name=op.url_name)
582577

583-
namespaced_patterns.append(pattern)
578+
if self.urls_namespace:
579+
namespaced_patterns.append(pattern)
580+
else:
581+
yield pattern
584582

585-
if namespaced_patterns:
583+
if namespaced_patterns and self.urls_namespace:
586584
yield django_path(
587585
"",
588586
include(

0 commit comments

Comments
 (0)