Пример #1
0
 def _get_object(self, *args, **kwargs):
     proxy_sorting_id = self.kwargs['proxy_sorting_id']
     try:
         proxy_sorting = api.bw_get_sort_method(self.request, proxy_sorting_id)
         return proxy_sorting
     except Exception:
         redirect = self.success_url
         msg = _('Unable to retrieve sorted method details.')
         exceptions.handle(self.request, msg, redirect=redirect)
Пример #2
0
 def update_cell(self, request, datum, id, cell_name, new_cell_value):
     try:
         # updating changed value by new value
         response = api.bw_get_sort_method(request, id)
         data = json.loads(response.text)
         data[cell_name] = new_cell_value
         api.bw_update_sort_method(request, id, data)
     except Conflict:
         # Returning a nice error message about name conflict. The message
         # from exception is not that clear for the user
         message = _("Cant change value")
         raise ValidationError(message)
     except Exception:
         exceptions.handle(request, ignore=True)
         return False
     return True
Пример #3
0
    def get_data(self, request, id):
        response = api.bw_get_sort_method(request, id)
        data = json.loads(response.text)

        proxy_sorting = ProxySorting(data['id'], data['name'], data['criterion'])
        return proxy_sorting