prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add default icon for TableBlock
  As per https://github.com/torchbox/wagtail/pull/1705#issuecomment-216053655. Best to do this after #2417 is merged, to avoid conflicts.
  
  
  </issue>
  <code>
  [start of wagtail/contrib/table_block/fields.py]
  1 from __future__ import absolute_import, unicode_literals
  2 
  3 import json
  4 
  5 from django import forms
  6 from django.template.loader import render_to_string
  7 from django.utils import translation
  8 from django.utils.functional import cached_property
  9 
  10 from wagtail.utils.widgets import WidgetWithScript
  11 from wagtail.wagtailcore.blocks import FieldBlock
  12 
  13 
  14 class TableInput(WidgetWithScript, forms.HiddenInput):
  15 
  16     def __init__(self, table_options=None, attrs=None):
  17         self.table_options = table_options
  18         super(TableInput, self).__init__(attrs=attrs)
  19 
  20     def render(self, name, value, attrs=None):
  21         original_field_html = super(TableInput, self).render(name, value, attrs)
  22         return render_to_string("table_block/widgets/table.html", {
  23             'original_field_html': original_field_html,
  24             'attrs': attrs,
  25             'value': value,
  26         })
  27 
  28     def render_js_init(self, id_, name, value):
  29         return "initTable({0}, {1});".format(json.dumps(id_), json.dumps(self.table_options))
  30 
  31 
  32 
  33 class TableBlock(FieldBlock):
  34     def __init__(self, required=True, help_text=None, table_options=None, **kwargs):
  35         # CharField's 'label' and 'initial' parameters are not exposed, as Block handles that functionality
  36         # natively (via 'label' and 'default')
  37         # CharField's 'max_length' and 'min_length' parameters are not exposed as table data needs to
  38         # have arbitrary length
  39         # table_options can contain any valid handsontable options: http://docs.handsontable.com/0.18.0/Options.html
  40         self.field_options = {'required': required, 'help_text': help_text}
  41 
  42         language = translation.get_language()
  43         if language is not None and len(language) > 2:
  44             language = language[:2]
  45 
  46         default_table_options = {
  47             'minSpareRows': 0,
  48             'startRows': 3,
  49             'startCols': 3,
  50             'colHeaders': False,
  51             'rowHeaders': False,
  52             'contextMenu': True,
  53             'editor': 'text',
  54             'stretchH': 'all',
  55             'height': 108,
  56             'language': language,
  57             'renderer': 'text',
  58             'autoColumnSize': False,
  59         }
  60         if table_options is not None:
  61             default_table_options.update(table_options)
  62         self.table_options = default_table_options
  63         super(TableBlock, self).__init__(**kwargs)
  64 
  65     @cached_property
  66     def field(self):
  67         return forms.CharField(widget=TableInput(table_options=self.table_options), **self.field_options)
  68 
  69     def value_from_form(self, value):
  70         return json.loads(value)
  71 
  72     def value_for_form(self, value):
  73         return json.dumps(value)
  74 
  75     def is_html_renderer(self):
  76         return self.table_options['renderer'] == 'html'
  77 
  78     def render(self, value):
  79         template = getattr(self.meta, 'template', None)
  80         if template and value:
  81             table_header = value['data'][0] if value.get('data', None) and len(value['data']) > 0 and value.get('first_row_is_table_header', False) else None
  82             first_col_is_header = value.get('first_col_is_header', False)
  83             context = {
  84                 'self': value,
  85                 self.TEMPLATE_VAR: value,
  86                 'table_header': table_header,
  87                 'first_col_is_header': first_col_is_header,
  88                 'html_renderer': self.is_html_renderer(),
  89                 'data': value['data'][1:] if table_header else value.get('data', [])
  90             }
  91             return render_to_string(template, context)
  92         else:
  93             return self.render_basic(value)
  94 
  95     @property
  96     def media(self):
  97         return forms.Media(
  98             css={'all': ['table_block/css/vendor/handsontable-0.24.2.full.min.css']},
  99             js=['table_block/js/vendor/handsontable-0.24.2.full.min.js', 'table_block/js/table.js']
  100         )
  101 
  102     class Meta:
  103         default = None
  104         template = 'table_block/blocks/table.html'
  105
  [end of wagtail/contrib/table_block/fields.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/wagtail/contrib/table_block/fields.py b/wagtail/contrib/table_block/fields.py
  --- a/wagtail/contrib/table_block/fields.py
  +++ b/wagtail/contrib/table_block/fields.py
  @@ -29,7 +29,6 @@
           return "initTable({0}, {1});".format(json.dumps(id_), json.dumps(self.table_options))
   
   
  -
   class TableBlock(FieldBlock):
       def __init__(self, required=True, help_text=None, table_options=None, **kwargs):
           # CharField's 'label' and 'initial' parameters are not exposed, as Block handles that functionality
  @@ -102,3 +101,4 @@
       class Meta:
           default = None
           template = 'table_block/blocks/table.html'
  +        icon = "table"
  
verification_info: {"golden_diff": "diff --git a/wagtail/contrib/table_block/fields.py b/wagtail/contrib/table_block/fields.py\n--- a/wagtail/contrib/table_block/fields.py\n+++ b/wagtail/contrib/table_block/fields.py\n@@ -29,7 +29,6 @@\n         return \"initTable({0}, {1});\".format(json.dumps(id_), json.dumps(self.table_options))\n \n \n-\n class TableBlock(FieldBlock):\n     def __init__(self, required=True, help_text=None, table_options=None, **kwargs):\n         # CharField's 'label' and 'initial' parameters are not exposed, as Block handles that functionality\n@@ -102,3 +101,4 @@\n     class Meta:\n         default = None\n         template = 'table_block/blocks/table.html'\n+        icon = \"table\"\n", "issue": "Add default icon for TableBlock\nAs per https://github.com/torchbox/wagtail/pull/1705#issuecomment-216053655. Best to do this after #2417 is merged, to avoid conflicts.\n\n", "before_files": [{"content": "from __future__ import absolute_import, unicode_literals\n\nimport json\n\nfrom django import forms\nfrom django.template.loader import render_to_string\nfrom django.utils import translation\nfrom django.utils.functional import cached_property\n\nfrom wagtail.utils.widgets import WidgetWithScript\nfrom wagtail.wagtailcore.blocks import FieldBlock\n\n\nclass TableInput(WidgetWithScript, forms.HiddenInput):\n\n    def __init__(self, table_options=None, attrs=None):\n        self.table_options = table_options\n        super(TableInput, self).__init__(attrs=attrs)\n\n    def render(self, name, value, attrs=None):\n        original_field_html = super(TableInput, self).render(name, value, attrs)\n        return render_to_string(\"table_block/widgets/table.html\", {\n            'original_field_html': original_field_html,\n            'attrs': attrs,\n            'value': value,\n        })\n\n    def render_js_init(self, id_, name, value):\n        return \"initTable({0}, {1});\".format(json.dumps(id_), json.dumps(self.table_options))\n\n\n\nclass TableBlock(FieldBlock):\n    def __init__(self, required=True, help_text=None, table_options=None, **kwargs):\n        # CharField's 'label' and 'initial' parameters are not exposed, as Block handles that functionality\n        # natively (via 'label' and 'default')\n        # CharField's 'max_length' and 'min_length' parameters are not exposed as table data needs to\n        # have arbitrary length\n        # table_options can contain any valid handsontable options: http://docs.handsontable.com/0.18.0/Options.html\n        self.field_options = {'required': required, 'help_text': help_text}\n\n        language = translation.get_language()\n        if language is not None and len(language) > 2:\n            language = language[:2]\n\n        default_table_options = {\n            'minSpareRows': 0,\n            'startRows': 3,\n            'startCols': 3,\n            'colHeaders': False,\n            'rowHeaders': False,\n            'contextMenu': True,\n            'editor': 'text',\n            'stretchH': 'all',\n            'height': 108,\n            'language': language,\n            'renderer': 'text',\n            'autoColumnSize': False,\n        }\n        if table_options is not None:\n            default_table_options.update(table_options)\n        self.table_options = default_table_options\n        super(TableBlock, self).__init__(**kwargs)\n\n    @cached_property\n    def field(self):\n        return forms.CharField(widget=TableInput(table_options=self.table_options), **self.field_options)\n\n    def value_from_form(self, value):\n        return json.loads(value)\n\n    def value_for_form(self, value):\n        return json.dumps(value)\n\n    def is_html_renderer(self):\n        return self.table_options['renderer'] == 'html'\n\n    def render(self, value):\n        template = getattr(self.meta, 'template', None)\n        if template and value:\n            table_header = value['data'][0] if value.get('data', None) and len(value['data']) > 0 and value.get('first_row_is_table_header', False) else None\n            first_col_is_header = value.get('first_col_is_header', False)\n            context = {\n                'self': value,\n                self.TEMPLATE_VAR: value,\n                'table_header': table_header,\n                'first_col_is_header': first_col_is_header,\n                'html_renderer': self.is_html_renderer(),\n                'data': value['data'][1:] if table_header else value.get('data', [])\n            }\n            return render_to_string(template, context)\n        else:\n            return self.render_basic(value)\n\n    @property\n    def media(self):\n        return forms.Media(\n            css={'all': ['table_block/css/vendor/handsontable-0.24.2.full.min.css']},\n            js=['table_block/js/vendor/handsontable-0.24.2.full.min.js', 'table_block/js/table.js']\n        )\n\n    class Meta:\n        default = None\n        template = 'table_block/blocks/table.html'\n", "path": "wagtail/contrib/table_block/fields.py"}]}