Esempio n. 1
0
    def onClick(self, controlID):
        if controlID == 10028:  # Save and close dialog
            # pin = self.getControl(10002).getText()
            # # Validate pin length
            # if not self._validate_pin(pin):
            #     return
            import resources.lib.api.api_requests as api
            data = {
                'guid': self.data['profileInfo']['guid'],
                'experience': self.data['experience'],
                'maturity':
                self.rating_levels[self.current_level_index]['value'],
                'token': self.data['token']
            }
            # Send changes to the service
            if not api.set_parental_control_data(data):
                show_error_info('Parental controls',
                                'An error has occurred when saving data',
                                False, True)
            # I make sure that the metadata are removed,
            # otherwise you get inconsistencies with the request of the pin
            # from resources.lib.common.cache_utils import CACHE_METADATA
            # g.CACHE.clear([CACHE_METADATA])

            # The selection of the maturity level affects the lists data as a filter,
            # so you need to clear the lists in the cache in order not to create inconsistencies
            from resources.lib.common.cache_utils import CACHE_COMMON, CACHE_GENRES, CACHE_MYLIST, CACHE_SEARCH
            g.CACHE.clear(
                [CACHE_COMMON, CACHE_GENRES, CACHE_MYLIST, CACHE_SEARCH])
            self.close()
        if controlID in [10029, 100]:  # Close dialog
            self.close()
 def onClick(self, controlID):
     if controlID == 28:  # Save and close dialog
         pin = self.getControl(2).getText()
         # Validate pin length
         if not self._validate_pin(pin):
             return
         import resources.lib.api.shakti as api
         data = {'pin': pin,
                 'maturity_level': self.nf_maturity_levels[self.current_maturity_level]}
         # Send changes to the service
         if not api.set_parental_control_data(data).get('success', False):
             # Only in case of service problem
             show_error_info('Parental control saving', 'Error cannot save settings',
                             False, True)
         # I make sure that the metadata are removed,
         # otherwise you get inconsistencies with the request of the pin
         from resources.lib.cache import CACHE_METADATA
         g.CACHE.invalidate(True, [CACHE_METADATA])
         self.close()
     if controlID in [29, 100]:  # Close dialog
         self.close()