Skip to content

Commit

Permalink
fix: fix django 4.0 deperecation warnings (#4091)
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq authored Sep 18, 2023
1 parent 00b8622 commit 1436d08
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 32 deletions.
3 changes: 1 addition & 2 deletions course_discovery/apps/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
All API URLs should be versioned, so urlpatterns should only
contain namespaces for the active versions of the API.
"""
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'api'

Expand Down
3 changes: 1 addition & 2 deletions course_discovery/apps/api/v1/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
""" API v1 URLs. """
from django.conf.urls import include
from django.urls import path, re_path
from django.urls import include, path, re_path
from rest_framework import routers

from course_discovery.apps.api.v1.views import search as search_views
Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/course_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'course_discovery.apps.course_metadata.apps.CourseMetadataConfig'
28 changes: 17 additions & 11 deletions course_discovery/apps/course_metadata/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ def get_change_actions(self, request, object_id, form_url):

return actions

@admin.action(
description="view course skills"
)
def course_skills(self, request, obj):
"""
Object tool handler method - redirects to "Course Skills" view
Expand Down Expand Up @@ -207,7 +210,6 @@ def get_urls(self):
return additional_urls + super().get_urls()

course_skills.label = "view course skills"
course_skills.short_description = "view course skills"


@admin.register(CourseEditor)
Expand All @@ -221,11 +223,12 @@ class CourseEditorAdmin(admin.ModelAdmin):
class CourseEntitlementAdmin(SimpleHistoryAdmin):
list_display = ['course', 'get_course_key', 'mode', 'draft']

@admin.display(
description='Course key'
)
def get_course_key(self, obj):
return obj.course.key

get_course_key.short_description = 'Course key'

raw_id_fields = ('course', 'draft_version',)
search_fields = ['course__title', 'course__key']

Expand Down Expand Up @@ -415,11 +418,12 @@ def get_change_actions(self, request, object_id, form_url):

return actions

@admin.display(
description=_('Included course runs')
)
def custom_course_runs_display(self, obj):
return format_html('<br>'.join([str(run) for run in obj.course_runs]))

custom_course_runs_display.short_description = _('Included course runs')

def _redirect_course_run_update_page(self, obj):
""" Returns a response redirect to a page where the user can update the
course runs for the program being edited.
Expand Down Expand Up @@ -698,11 +702,15 @@ class CurriculumCourseMembershipInline(admin.StackedInline):
model = CurriculumCourseMembership
readonly_fields = ("custom_course_runs_display", "course_run_exclusions", "get_edit_link",)

@admin.display(
description=_('Included course runs')
)
def custom_course_runs_display(self, obj):
return format_html('<br>'.join([str(run) for run in obj.course_runs]))

custom_course_runs_display.short_description = _('Included course runs')

@admin.display(
description=_("Edit link")
)
def get_edit_link(self, obj=None):
if obj and obj.pk:
edit_url = reverse(f'admin:{obj._meta.app_label}_{obj._meta.model_name}_change', args=[obj.pk])
Expand All @@ -712,9 +720,6 @@ def get_edit_link(self, obj=None):
text=_("Edit course run exclusions"),
)
return _("(save and continue editing to create a link)")

get_edit_link.short_description = _("Edit link")

extra = 0


Expand Down Expand Up @@ -1021,5 +1026,6 @@ class ProgramSubscriptionPriceAdmin(admin.ModelAdmin):
Admin settings for ProgramSubscriptionPrice
"""
readonly_fields = ('uuid', )
search_fields = ("program_subscription__program__title", "program_subscription__program__uuid",
search_fields = ("program_subscription__program__title",
"program_subscription__program__uuid",
"price", "currency__name")
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 3.2.20 on 2023-09-18 07:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('course_metadata', '0332_alter_migratecourseslugconfiguration_course_type'),
]

operations = [
migrations.AlterModelOptions(
name='additionalmetadata',
options={},
),
migrations.AlterModelOptions(
name='productmeta',
options={},
),
migrations.AlterModelOptions(
name='productvalue',
options={},
),
migrations.AlterModelOptions(
name='taxiform',
options={},
),
migrations.AlterField(
model_name='courserun',
name='has_ofac_restrictions',
field=models.BooleanField(blank=True, choices=[('', '--'), (True, 'Blocked'), (False, 'Unrestricted')], default=None, null=True, verbose_name='Add OFAC restriction text to the FAQ section of the Marketing site'),
),
migrations.AlterField(
model_name='historicalcourserun',
name='has_ofac_restrictions',
field=models.BooleanField(blank=True, choices=[('', '--'), (True, 'Blocked'), (False, 'Unrestricted')], default=None, null=True, verbose_name='Add OFAC restriction text to the FAQ section of the Marketing site'),
),
migrations.AlterField(
model_name='historicalprogram',
name='has_ofac_restrictions',
field=models.BooleanField(blank=True, choices=[('', '--'), (True, 'Blocked'), (False, 'Unrestricted')], default=None, null=True, verbose_name='Add OFAC restriction text to the FAQ section of the Marketing site'),
),
migrations.AlterField(
model_name='program',
name='has_ofac_restrictions',
field=models.BooleanField(blank=True, choices=[('', '--'), (True, 'Blocked'), (False, 'Unrestricted')], default=None, null=True, verbose_name='Add OFAC restriction text to the FAQ section of the Marketing site'),
),
]
8 changes: 4 additions & 4 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2117,12 +2117,12 @@ class CourseRun(ManageHistoryMixin, DraftModelMixin, CachedMixin, TimeStampedMod
help_text=_('Pick a tag from the suggestions. To make a new tag, add a comma after the tag name.'),
)

has_ofac_restrictions = models.NullBooleanField(
has_ofac_restrictions = models.BooleanField(
blank=True,
choices=OFAC_RESTRICTION_CHOICES,
default=None,
verbose_name=_('Add OFAC restriction text to the FAQ section of the Marketing site'),
)
null=True)
ofac_comment = models.TextField(blank=True, help_text='Comment related to OFAC restriction')

# The expected_program_type and expected_program_name are here in support of Publisher and may not reflect the
Expand Down Expand Up @@ -3206,12 +3206,12 @@ class Program(ManageHistoryMixin, PkSearchableMixin, TimeStampedModel):
help_text=_('Pick a tag/label from the suggestions. To make a new tag, add a comma after the tag name.'),
)

has_ofac_restrictions = models.NullBooleanField(
has_ofac_restrictions = models.BooleanField(
blank=True,
choices=OFAC_RESTRICTION_CHOICES,
default=None,
verbose_name=_('Add OFAC restriction text to the FAQ section of the Marketing site'),
)
null=True)
ofac_comment = models.TextField(blank=True, help_text='Comment related to OFAC restriction')
data_modified_timestamp = models.DateTimeField(
default=None, blank=True, null=True, help_text=_('The last time this program was modified.')
Expand Down
3 changes: 1 addition & 2 deletions course_discovery/apps/edx_catalog_extensions/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'api'

Expand Down
3 changes: 1 addition & 2 deletions course_discovery/apps/edx_catalog_extensions/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'catalog_extensions'

Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/ietf_language_tags/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'course_discovery.apps.ietf_language_tags.apps.IETFLanguageTagsConfig'
3 changes: 1 addition & 2 deletions course_discovery/apps/learner_pathway/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
All API URLs should be versioned, so urlpatterns should only
contain namespaces for the active versions of the API.
"""
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'learner_pathway'

Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/publisher/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'course_discovery.apps.publisher.apps.PublisherAppConfig'
3 changes: 1 addition & 2 deletions course_discovery/apps/publisher/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'publisher'

Expand Down
3 changes: 1 addition & 2 deletions course_discovery/apps/taxonomy_support/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import include
from django.urls import path
from django.urls import include, path

app_name = 'taxonomy_support'

Expand Down

0 comments on commit 1436d08

Please sign in to comment.