def map_subproject_slug(view_func):
 @wraps(view_func)
 def inner_view(request, subproject=None, subproject_slug=None, *args, **kwargs):
  if ((subproject is None) and subproject_slug):
   try:
    subproject = Project.objects.get(slug=subproject_slug)
   except Project.DoesNotExist:
    try:
     rel = ProjectRelationship.objects.get(parent=kwargs['project'], alias=subproject_slug)
     subproject = rel.child
    except (ProjectRelationship.DoesNotExist, KeyError):
     raise Http404
  return view_func(request, subproject=subproject, *args, **kwargs)
 return inner_view

def map_subproject_slug ( view_func ) : @ wraps ( view_func ) def inner_view ( request , subproject = None , subproject_slug = None , * args , ** kwargs ) : if ( ( subproject is None ) and subproject_slug ) : try : subproject = Project . objects . get ( slug = subproject_slug ) except Project . DoesNotExist : try : rel = ProjectRelationship . objects . get ( parent = kwargs [ 'project' ] , alias = subproject_slug ) subproject = rel . child except ( ProjectRelationship . DoesNotExist , KeyError ) : raise Http404 return view_func ( request , subproject = subproject , * args , ** kwargs ) return inner_view
a decorator that maps a subproject_slug url param into a project .