
from __future__ import absolute_import

from ..views import GeneralView


class SummaryView(GeneralView):

    def get_objects(self, path_to):
        path_dict = path_to.split('/')
        package = path_dict[0]
        version = path_dict[1]

        return dict(package=package,
                    version=version)


from __future__ import absolute_import

from flask import request

from ..views import GeneralView


class SummaryView(GeneralView):

    def get_objects(self, path_to):
        path_dict = path_to.split('/')
        package = path_dict[0]
        version = path_dict[1]

        path = '/'.join(path_dict[2:])

        if version == "latest":  # we search the latest available version
            return self._handle_latest_version(request.endpoint,
                                               package, path)

        versions = self.handle_versions(version, package, path)
        if versions:
            redirect_url_parts = [package, versions[-1]]
            if path:
                redirect_url_parts.append(path)
            redirect_url = '/'.join(redirect_url_parts)
            return self._redirect_to_url(request.endpoint,
                                         redirect_url, redirect_code=302)

        return dict(package=package,
                    version=version)

Add version handling in SummaryView for the patches BP
Add version handling in SummaryView for the patches BP

  
  from __future__ import absolute_import
+ 
+ from flask import request
  
  from ..views import GeneralView
  
  
  class SummaryView(GeneralView):
  
      def get_objects(self, path_to):
          path_dict = path_to.split('/')
          package = path_dict[0]
          version = path_dict[1]
  
+         path = '/'.join(path_dict[2:])
+ 
+         if version == "latest":  # we search the latest available version
+             return self._handle_latest_version(request.endpoint,
+                                                package, path)
+ 
+         versions = self.handle_versions(version, package, path)
+         if versions:
+             redirect_url_parts = [package, versions[-1]]
+             if path:
+                 redirect_url_parts.append(path)
+             redirect_url = '/'.join(redirect_url_parts)
+             return self._redirect_to_url(request.endpoint,
+                                          redirect_url, redirect_code=302)
+ 
          return dict(package=package,
                      version=version)
  
Add version handling in SummaryView for the patches BP
## Code Before:

from __future__ import absolute_import

from ..views import GeneralView


class SummaryView(GeneralView):

    def get_objects(self, path_to):
        path_dict = path_to.split('/')
        package = path_dict[0]
        version = path_dict[1]

        return dict(package=package,
                    version=version)

## Instruction:
Add version handling in SummaryView for the patches BP
## Code After:

from __future__ import absolute_import

from flask import request

from ..views import GeneralView


class SummaryView(GeneralView):

    def get_objects(self, path_to):
        path_dict = path_to.split('/')
        package = path_dict[0]
        version = path_dict[1]

        path = '/'.join(path_dict[2:])

        if version == "latest":  # we search the latest available version
            return self._handle_latest_version(request.endpoint,
                                               package, path)

        versions = self.handle_versions(version, package, path)
        if versions:
            redirect_url_parts = [package, versions[-1]]
            if path:
                redirect_url_parts.append(path)
            redirect_url = '/'.join(redirect_url_parts)
            return self._redirect_to_url(request.endpoint,
                                         redirect_url, redirect_code=302)

        return dict(package=package,
                    version=version)
