def get_description(self, request, html=False): self.request = request template_list = [] for klass in inspect.getmro(type(self)): template_basename = camelcase_to_underscore(klass.__name__) template_list.append('api/%s.md' % template_basename) context = self.get_description_context() default_version = int(1) request_version = get_request_version(self.request) if request_version is not None and request_version < default_version: context['deprecated'] = True description = render_to_string(template_list, context) if context.get('deprecated') and context.get('swagger_method') is None: # render deprecation messages at the very top description = '\n'.join([render_to_string('api/_deprecated.md', context), description]) return description
def filter_queryset(self, request, queryset, view): from cyborgbackup.api.versioning import get_request_version if get_request_version(request) == 1: queryset = queryset.filter( credential_type__managed_by_cyborgbackup=True) return queryset
def version(self): """ The request version component of the URL as an integer i.e., 1 or 2 """ return get_request_version(self.context.get('request'))