prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Pages: Separate page and translation attributes in page form
  At the moment, it is not clear which attributes of the page form refer to the `Page` object and which only handle `PageTranslation` objects (from a user's point of view). Probably, we should separate these two sections from each other.
  
  This is part of #98.
  
  </issue>
  <code>
  [start of backend/cms/models/region.py]
  1 """
  2 Database model representing an autonomous authority
  3 """
  4 from django.contrib.postgres.fields import ArrayField
  5 from django.db import models
  6 from django.http import Http404
  7 from django.utils import timezone
  8 from django.utils.translation import ugettext_lazy as _
  9 
  10 
  11 class Region(models.Model):
  12     """
  13     Class to generate region database objects
  14     """
  15     ACTIVE = 'acti'
  16     HIDDEN = 'hidd'
  17     ARCHIVED = 'arch'
  18 
  19     STATUS = (
  20         (ACTIVE, _('Active')),
  21         (HIDDEN, _('Hidden')),
  22         (ARCHIVED, _('Archived')),
  23     )
  24 
  25     name = models.CharField(max_length=200)
  26     slug = models.SlugField(max_length=200, unique=True, blank=True)
  27     status = models.CharField(max_length=4, choices=STATUS)
  28 
  29     events_enabled = models.BooleanField(default=True)
  30     push_notifications_enabled = models.BooleanField(default=True)
  31     push_notification_channels = ArrayField(models.CharField(max_length=60), blank=True)
  32 
  33     latitude = models.FloatField(null=True)
  34     longitude = models.FloatField(null=True)
  35     postal_code = models.CharField(max_length=10)
  36 
  37     admin_mail = models.EmailField()
  38 
  39     created_date = models.DateTimeField(default=timezone.now)
  40     last_updated = models.DateTimeField(auto_now=True)
  41 
  42     statistics_enabled = models.BooleanField(default=False)
  43     matomo_url = models.CharField(max_length=150, blank=True, default='')
  44     matomo_token = models.CharField(max_length=150, blank=True, default='')
  45     matomo_ssl_verify = models.BooleanField(default=True)
  46 
  47     @property
  48     def languages(self):
  49         language_tree_nodes = self.language_tree_nodes.select_related('language').all()
  50         return [language_tree_node.language for language_tree_node in language_tree_nodes]
  51 
  52     @property
  53     def default_language(self):
  54         tree_root = self.language_tree_nodes.filter(level=0).first()
  55         return tree_root.language if tree_root else None
  56 
  57     @classmethod
  58     def get_current_region(cls, request):
  59         if not hasattr(request, 'resolver_match'):
  60             return None
  61         region_slug = request.resolver_match.kwargs.get('region_slug')
  62         if not region_slug:
  63             return None
  64         region = cls.objects.filter(slug=region_slug)
  65         if not region.exists():
  66             raise Http404
  67         return region.first()
  68 
  69     def __str__(self):
  70         """Function that provides a string representation of this object
  71 
  72         Returns: String
  73         """
  74         return self.name
  75 
  76     class Meta:
  77         default_permissions = ()
  78         permissions = (
  79             ('manage_regions', 'Can manage regions'),
  80         )
  81
  [end of backend/cms/models/region.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/backend/cms/models/region.py b/backend/cms/models/region.py
  --- a/backend/cms/models/region.py
  +++ b/backend/cms/models/region.py
  @@ -56,7 +56,8 @@
   
       @classmethod
       def get_current_region(cls, request):
  -        if not hasattr(request, 'resolver_match'):
  +        # if rendered url is edit_region, the region slug originates from the region form.
  +        if not hasattr(request, 'resolver_match') or request.resolver_match.url_name == 'edit_region':
               return None
           region_slug = request.resolver_match.kwargs.get('region_slug')
           if not region_slug:
  
verification_info: {"golden_diff": "diff --git a/backend/cms/models/region.py b/backend/cms/models/region.py\n--- a/backend/cms/models/region.py\n+++ b/backend/cms/models/region.py\n@@ -56,7 +56,8 @@\n \n     @classmethod\n     def get_current_region(cls, request):\n-        if not hasattr(request, 'resolver_match'):\n+        # if rendered url is edit_region, the region slug originates from the region form.\n+        if not hasattr(request, 'resolver_match') or request.resolver_match.url_name == 'edit_region':\n             return None\n         region_slug = request.resolver_match.kwargs.get('region_slug')\n         if not region_slug:\n", "issue": "Pages: Separate page and translation attributes in page form\nAt the moment, it is not clear which attributes of the page form refer to the `Page` object and which only handle `PageTranslation` objects (from a user's point of view). Probably, we should separate these two sections from each other.\r\n\r\nThis is part of #98.\n", "before_files": [{"content": "\"\"\"\nDatabase model representing an autonomous authority\n\"\"\"\nfrom django.contrib.postgres.fields import ArrayField\nfrom django.db import models\nfrom django.http import Http404\nfrom django.utils import timezone\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass Region(models.Model):\n    \"\"\"\n    Class to generate region database objects\n    \"\"\"\n    ACTIVE = 'acti'\n    HIDDEN = 'hidd'\n    ARCHIVED = 'arch'\n\n    STATUS = (\n        (ACTIVE, _('Active')),\n        (HIDDEN, _('Hidden')),\n        (ARCHIVED, _('Archived')),\n    )\n\n    name = models.CharField(max_length=200)\n    slug = models.SlugField(max_length=200, unique=True, blank=True)\n    status = models.CharField(max_length=4, choices=STATUS)\n\n    events_enabled = models.BooleanField(default=True)\n    push_notifications_enabled = models.BooleanField(default=True)\n    push_notification_channels = ArrayField(models.CharField(max_length=60), blank=True)\n\n    latitude = models.FloatField(null=True)\n    longitude = models.FloatField(null=True)\n    postal_code = models.CharField(max_length=10)\n\n    admin_mail = models.EmailField()\n\n    created_date = models.DateTimeField(default=timezone.now)\n    last_updated = models.DateTimeField(auto_now=True)\n\n    statistics_enabled = models.BooleanField(default=False)\n    matomo_url = models.CharField(max_length=150, blank=True, default='')\n    matomo_token = models.CharField(max_length=150, blank=True, default='')\n    matomo_ssl_verify = models.BooleanField(default=True)\n\n    @property\n    def languages(self):\n        language_tree_nodes = self.language_tree_nodes.select_related('language').all()\n        return [language_tree_node.language for language_tree_node in language_tree_nodes]\n\n    @property\n    def default_language(self):\n        tree_root = self.language_tree_nodes.filter(level=0).first()\n        return tree_root.language if tree_root else None\n\n    @classmethod\n    def get_current_region(cls, request):\n        if not hasattr(request, 'resolver_match'):\n            return None\n        region_slug = request.resolver_match.kwargs.get('region_slug')\n        if not region_slug:\n            return None\n        region = cls.objects.filter(slug=region_slug)\n        if not region.exists():\n            raise Http404\n        return region.first()\n\n    def __str__(self):\n        \"\"\"Function that provides a string representation of this object\n\n        Returns: String\n        \"\"\"\n        return self.name\n\n    class Meta:\n        default_permissions = ()\n        permissions = (\n            ('manage_regions', 'Can manage regions'),\n        )\n", "path": "backend/cms/models/region.py"}]}