Esempio n. 1
0
    def process_response(self, __, response):
        """
        If request is from mobile native app, then add version related info to response headers.

        Returns:
            Http response: with additional headers;
                1. EDX-APP-LATEST-VERSION; if user app version < latest available version
                2. EDX-APP-VERSION-LAST-SUPPORTED-DATE; if user app version < min supported version and
                   timestamp < expiry of that version
        """
        request_cache_dict = get_cache(self.REQUEST_CACHE_NAME)
        if request_cache_dict:
            last_supported_date = request_cache_dict[
                self.LAST_SUPPORTED_DATE_HEADER]
            if last_supported_date != self.NO_LAST_SUPPORTED_DATE:
                response[
                    self.
                    LAST_SUPPORTED_DATE_HEADER] = last_supported_date.isoformat(
                    )
            latest_version = request_cache_dict[self.LATEST_VERSION_HEADER]
            user_app_version = request_cache_dict[self.USER_APP_VERSION]
            if (latest_version != self.NO_LATEST_VERSION
                    and parsed_version(user_app_version) <
                    parsed_version(latest_version)):
                response[self.LATEST_VERSION_HEADER] = latest_version
        return response
Esempio n. 2
0
 def last_supported_date(cls, platform, version):
     """ Returns date when app version will get expired for a platform """
     parsed_version = utils.parsed_version(version)
     active_configs = cls.objects.filter(platform=platform, enabled=True, expire_at__isnull=False).reverse()
     for config in active_configs:
         if utils.parsed_version(config.version) >= parsed_version:
             return config.expire_at
Esempio n. 3
0
 def last_supported_date(cls, platform, version):
     """ Returns date when app version will get expired for a platform """
     parsed_version = utils.parsed_version(version)
     active_configs = cls.objects.filter(platform=platform,
                                         enabled=True,
                                         expire_at__isnull=False).reverse()
     for config in active_configs:
         if utils.parsed_version(config.version) >= parsed_version:
             return config.expire_at
Esempio n. 4
0
    def process_response(self, __, response):
        """
        If request is from mobile native app, then add version related info to response headers.

        Returns:
            Http response: with additional headers;
                1. EDX-APP-LATEST-VERSION; if user app version < latest available version
                2. EDX-APP-VERSION-LAST-SUPPORTED-DATE; if user app version < min supported version and
                   timestamp < expiry of that version
        """
        request_cache_dict = request_cache.get_cache(self.REQUEST_CACHE_NAME)
        if request_cache_dict:
            last_supported_date = request_cache_dict[self.LAST_SUPPORTED_DATE_HEADER]
            if last_supported_date != self.NO_LAST_SUPPORTED_DATE:
                response[self.LAST_SUPPORTED_DATE_HEADER] = last_supported_date.isoformat()
            latest_version = request_cache_dict[self.LATEST_VERSION_HEADER]
            user_app_version = request_cache_dict[self.USER_APP_VERSION]
            if (latest_version != self.NO_LATEST_VERSION and
                    parsed_version(user_app_version) < parsed_version(latest_version)):
                response[self.LATEST_VERSION_HEADER] = latest_version
        return response
Esempio n. 5
0
 def save(self, *args, **kwargs):
     """ parses version into major, minor and patch versions before saving """
     self.major_version, self.minor_version, self.patch_version = utils.parsed_version(
         self.version)
     super(AppVersionConfig, self).save(*args, **kwargs)
Esempio n. 6
0
 def save(self, *args, **kwargs):
     """ parses version into major, minor and patch versions before saving """
     self.major_version, self.minor_version, self.patch_version = utils.parsed_version(self.version)
     super(AppVersionConfig, self).save(*args, **kwargs)