prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Explorations should not auto-save
  New Explorations are currently persistent, any change made immediately saves the exploration. This behaviour is not preferred since we'd like the user to be able to run and discard queries.
  
  [Mail thread containing related discussion](https://groups.google.com/a/mathesar.org/g/mathesar-developers/c/RQJSiDQu1Tg/m/uLHj30yFAgAJ).
  
  New behaviour proposed:
  
  * New Exploration: Auto-save is not preferred
    - User opens Data Explorer
    - User joins tables, does any number of operations
    - This should not get saved automatically
    - It should get saved when user manually clicks Save button
  
  * Editing existing Exploration: ~~Auto-save is preferred~~ Auto save is not preferred (Refer https://github.com/centerofci/mathesar/issues/1590#issuecomment-1238204655)
    - Users edits an existing exploration in the Data Explorer
    - User makes changes to it
    - ~~The changes are auto-saved~~ User has to click the Save button or Ctrl+s to save the changes
    - We have undo-redo to improve the user's editing experience
  Implement Exploration Page functionality
  This is a placeholder issue to implement a page to view a single exploration.
  
  </issue>
  <code>
  [start of mathesar/views.py]
  1 from django.shortcuts import render, redirect, get_object_or_404
  2 
  3 from mathesar.models.base import Database, Schema, Table
  4 from mathesar.api.serializers.databases import DatabaseSerializer, TypeSerializer
  5 from mathesar.api.serializers.schemas import SchemaSerializer
  6 from mathesar.api.serializers.tables import TableSerializer
  7 from mathesar.api.serializers.queries import QuerySerializer
  8 from mathesar.database.types import UIType
  9 from mathesar.models.query import UIQuery
  10 
  11 
  12 def get_schema_list(request, database):
  13     schema_serializer = SchemaSerializer(
  14         Schema.objects.filter(database=database),
  15         many=True,
  16         context={'request': request}
  17     )
  18     return schema_serializer.data
  19 
  20 
  21 def get_database_list(request):
  22     database_serializer = DatabaseSerializer(
  23         Database.objects.all(),
  24         many=True,
  25         context={'request': request}
  26     )
  27     return database_serializer.data
  28 
  29 
  30 def get_table_list(request, schema):
  31     if schema is None:
  32         return []
  33     table_serializer = TableSerializer(
  34         Table.objects.filter(schema=schema),
  35         many=True,
  36         context={'request': request}
  37     )
  38     return table_serializer.data
  39 
  40 
  41 def get_queries_list(request, schema):
  42     if schema is None:
  43         return []
  44     query_serializer = QuerySerializer(
  45         UIQuery.objects.all(),
  46         many=True,
  47         context={'request': request}
  48     )
  49     return query_serializer.data
  50 
  51 
  52 def get_ui_type_list(request, database):
  53     if database is None:
  54         return []
  55     type_serializer = TypeSerializer(
  56         UIType,
  57         many=True,
  58         context={'request': request}
  59     )
  60     return type_serializer.data
  61 
  62 
  63 def get_common_data(request, database, schema=None):
  64     return {
  65         'current_db': database.name if database else None,
  66         'current_schema': schema.id if schema else None,
  67         'schemas': get_schema_list(request, database),
  68         'databases': get_database_list(request),
  69         'tables': get_table_list(request, schema),
  70         'queries': get_queries_list(request, schema),
  71         'abstract_types': get_ui_type_list(request, database)
  72     }
  73 
  74 
  75 def get_current_database(request, db_name):
  76     # if there's a DB name passed in, try to retrieve the database, or return a 404 error.
  77     if db_name is not None:
  78         return get_object_or_404(Database, name=db_name)
  79     else:
  80         try:
  81             # Try to get the first database available
  82             return Database.objects.order_by('id').first()
  83         except Database.DoesNotExist:
  84             return None
  85 
  86 
  87 def get_current_schema(request, schema_id, database):
  88     # if there's a schema ID passed in, try to retrieve the schema, or return a 404 error.
  89     if schema_id is not None:
  90         return get_object_or_404(Schema, id=schema_id)
  91     else:
  92         try:
  93             # Try to get the first schema in the DB
  94             return Schema.objects.filter(database=database).order_by('id').first()
  95         except Schema.DoesNotExist:
  96             return None
  97 
  98 
  99 def render_schema(request, database, schema):
  100     # if there's no schema available, redirect to the schemas page.
  101     if not schema:
  102         return redirect('schemas', db_name=database.name)
  103     else:
  104         # We are redirecting so that the correct URL is passed to the frontend.
  105         return redirect('schema_home', db_name=database.name, schema_id=schema.id)
  106 
  107 
  108 def home(request):
  109     database = get_current_database(request, None)
  110     return redirect('schemas', db_name=database.name)
  111 
  112 
  113 def schema_home(request, db_name, schema_id, **kwargs):
  114     database = get_current_database(request, db_name)
  115     schema = get_current_schema(request, schema_id, database)
  116     return render(request, 'mathesar/index.html', {
  117         'common_data': get_common_data(request, database, schema)
  118     })
  119 
  120 
  121 def schemas(request, db_name):
  122     database = get_current_database(request, db_name)
  123     return render(request, 'mathesar/index.html', {
  124         'common_data': get_common_data(request, database, None)
  125     })
  126
  [end of mathesar/views.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/mathesar/views.py b/mathesar/views.py
  --- a/mathesar/views.py
  +++ b/mathesar/views.py
  @@ -42,7 +42,7 @@
       if schema is None:
           return []
       query_serializer = QuerySerializer(
  -        UIQuery.objects.all(),
  +        UIQuery.objects.filter(base_table__schema=schema),
           many=True,
           context={'request': request}
       )
  
verification_info: {"golden_diff": "diff --git a/mathesar/views.py b/mathesar/views.py\n--- a/mathesar/views.py\n+++ b/mathesar/views.py\n@@ -42,7 +42,7 @@\n     if schema is None:\n         return []\n     query_serializer = QuerySerializer(\n-        UIQuery.objects.all(),\n+        UIQuery.objects.filter(base_table__schema=schema),\n         many=True,\n         context={'request': request}\n     )\n", "issue": "Explorations should not auto-save\nNew Explorations are currently persistent, any change made immediately saves the exploration. This behaviour is not preferred since we'd like the user to be able to run and discard queries.\r\n\r\n[Mail thread containing related discussion](https://groups.google.com/a/mathesar.org/g/mathesar-developers/c/RQJSiDQu1Tg/m/uLHj30yFAgAJ).\r\n\r\nNew behaviour proposed:\r\n\r\n* New Exploration: Auto-save is not preferred\r\n  - User opens Data Explorer\r\n  - User joins tables, does any number of operations\r\n  - This should not get saved automatically\r\n  - It should get saved when user manually clicks Save button\r\n\r\n* Editing existing Exploration: ~~Auto-save is preferred~~ Auto save is not preferred (Refer https://github.com/centerofci/mathesar/issues/1590#issuecomment-1238204655)\r\n  - Users edits an existing exploration in the Data Explorer\r\n  - User makes changes to it\r\n  - ~~The changes are auto-saved~~ User has to click the Save button or Ctrl+s to save the changes\r\n  - We have undo-redo to improve the user's editing experience\nImplement Exploration Page functionality\nThis is a placeholder issue to implement a page to view a single exploration.\n", "before_files": [{"content": "from django.shortcuts import render, redirect, get_object_or_404\n\nfrom mathesar.models.base import Database, Schema, Table\nfrom mathesar.api.serializers.databases import DatabaseSerializer, TypeSerializer\nfrom mathesar.api.serializers.schemas import SchemaSerializer\nfrom mathesar.api.serializers.tables import TableSerializer\nfrom mathesar.api.serializers.queries import QuerySerializer\nfrom mathesar.database.types import UIType\nfrom mathesar.models.query import UIQuery\n\n\ndef get_schema_list(request, database):\n    schema_serializer = SchemaSerializer(\n        Schema.objects.filter(database=database),\n        many=True,\n        context={'request': request}\n    )\n    return schema_serializer.data\n\n\ndef get_database_list(request):\n    database_serializer = DatabaseSerializer(\n        Database.objects.all(),\n        many=True,\n        context={'request': request}\n    )\n    return database_serializer.data\n\n\ndef get_table_list(request, schema):\n    if schema is None:\n        return []\n    table_serializer = TableSerializer(\n        Table.objects.filter(schema=schema),\n        many=True,\n        context={'request': request}\n    )\n    return table_serializer.data\n\n\ndef get_queries_list(request, schema):\n    if schema is None:\n        return []\n    query_serializer = QuerySerializer(\n        UIQuery.objects.all(),\n        many=True,\n        context={'request': request}\n    )\n    return query_serializer.data\n\n\ndef get_ui_type_list(request, database):\n    if database is None:\n        return []\n    type_serializer = TypeSerializer(\n        UIType,\n        many=True,\n        context={'request': request}\n    )\n    return type_serializer.data\n\n\ndef get_common_data(request, database, schema=None):\n    return {\n        'current_db': database.name if database else None,\n        'current_schema': schema.id if schema else None,\n        'schemas': get_schema_list(request, database),\n        'databases': get_database_list(request),\n        'tables': get_table_list(request, schema),\n        'queries': get_queries_list(request, schema),\n        'abstract_types': get_ui_type_list(request, database)\n    }\n\n\ndef get_current_database(request, db_name):\n    # if there's a DB name passed in, try to retrieve the database, or return a 404 error.\n    if db_name is not None:\n        return get_object_or_404(Database, name=db_name)\n    else:\n        try:\n            # Try to get the first database available\n            return Database.objects.order_by('id').first()\n        except Database.DoesNotExist:\n            return None\n\n\ndef get_current_schema(request, schema_id, database):\n    # if there's a schema ID passed in, try to retrieve the schema, or return a 404 error.\n    if schema_id is not None:\n        return get_object_or_404(Schema, id=schema_id)\n    else:\n        try:\n            # Try to get the first schema in the DB\n            return Schema.objects.filter(database=database).order_by('id').first()\n        except Schema.DoesNotExist:\n            return None\n\n\ndef render_schema(request, database, schema):\n    # if there's no schema available, redirect to the schemas page.\n    if not schema:\n        return redirect('schemas', db_name=database.name)\n    else:\n        # We are redirecting so that the correct URL is passed to the frontend.\n        return redirect('schema_home', db_name=database.name, schema_id=schema.id)\n\n\ndef home(request):\n    database = get_current_database(request, None)\n    return redirect('schemas', db_name=database.name)\n\n\ndef schema_home(request, db_name, schema_id, **kwargs):\n    database = get_current_database(request, db_name)\n    schema = get_current_schema(request, schema_id, database)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, schema)\n    })\n\n\ndef schemas(request, db_name):\n    database = get_current_database(request, db_name)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, None)\n    })\n", "path": "mathesar/views.py"}]}