Skip to content

Commit

Permalink
fix: mismatched migrations.
Browse files Browse the repository at this point in the history
update: regesterd CourseLocator with register_adapter
  • Loading branch information
qasimgulzar authored and qasimgulzar committed Nov 22, 2024
1 parent 61b0250 commit 5b3c21c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Migration(migrations.Migration):
('state', models.TextField(null=True, blank=True)),
('grade', models.FloatField(null=True, blank=True)),
('max_grade', models.FloatField(null=True, blank=True)),
('id', models.BigAutoField(primary_key=True)),
('id', models.BigAutoField(primary_key=True, serialize=False)),
('student_module', models.ForeignKey(to='courseware.StudentModule', on_delete=django.db.models.deletion.DO_NOTHING, db_constraint=False)),
],
options={
Expand Down
16 changes: 16 additions & 0 deletions openedx/core/djangoapps/common_initialization/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


from django.apps import AppConfig
from django.db import connection


class CommonInitializationConfig(AppConfig): # lint-amnesty, pylint: disable=missing-class-docstring
Expand All @@ -14,6 +15,7 @@ def ready(self):
# Common settings validations for the LMS and CMS.
from . import checks # lint-amnesty, pylint: disable=unused-import
self._add_mimetypes()
self._add_required_adapters()

@staticmethod
def _add_mimetypes():
Expand All @@ -26,3 +28,17 @@ def _add_mimetypes():
mimetypes.add_type('application/x-font-opentype', '.otf')
mimetypes.add_type('application/x-font-ttf', '.ttf')
mimetypes.add_type('application/font-woff', '.woff')

@staticmethod
def _add_required_adapters():
if 'postgresql' in connection.vendor.lower():
from opaque_keys.edx.locator import CourseLocator
from psycopg2.extensions import register_adapter, QuotedString


def adapt_course_locator(course_locator):
return QuotedString(course_locator._to_string())


# Register the adapter
register_adapter(CourseLocator, adapt_course_locator)

0 comments on commit 5b3c21c

Please sign in to comment.