Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Django 4.2 #1829

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.8']
toxenv: [quality, docs, django32-celery50, django32-pii-annotations]
toxenv: [quality, docs, django32-celery53, django42-celery53, django32-pii-annotations]
env:
RUNJSHINT: true
steps:
Expand All @@ -37,13 +37,13 @@ jobs:
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: Run code coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django32'
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: true
- name: Run jshint
if: matrix.toxenv=='django32-celery50' # Only run this once as part of tests
if: matrix.toxenv=='django42-celery53' # Only run this once as part of tests
run: |
npm ci
make jshint
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Change Log

Unreleased
----------
[4.1.8]
--------
Added support for Django 4.2

[4.1.7]
-------
fix: enterprise api credentials endpoint cleanup.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ upgrade: requirements check_pins ## update the requirements/*.txt files with the
# This section removes django from test.txt to
# let tox control the Django version for tests
grep -e "^django==" requirements/test.txt > requirements/django.txt
grep -e "^amqp==\|^anyjson==\|^billiard==\|^celery==\|^kombu==\|^click-didyoumean==\|^click-repl==\|^click==\|^prompt-toolkit==\|^vine==" requirements/dev.txt > requirements/celery50.txt
grep -e "^amqp==\|^anyjson==\|^billiard==\|^celery==\|^kombu==\|^click-didyoumean==\|^click-repl==\|^click==\|^prompt-toolkit==\|^vine==" requirements/dev.txt > requirements/celery53.txt
sed -i.tmp '/^[d|D]jango==/d' requirements/test.txt
sed -i.tmp '/^amqp==/d' requirements/test.txt
sed -i.tmp '/^anyjson==/d' requirements/test.txt
Expand Down
2 changes: 0 additions & 2 deletions consent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
"""

__version__ = "0.1.0"

default_app_config = "consent.apps.ConsentConfig"
16 changes: 10 additions & 6 deletions consent/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,30 @@ def preview(self, consent_page, course_id='', program_uuid=''):
url = reverse('grant_data_sharing_permissions') + '?{}'.format(urlencode(params))
return HttpResponseRedirect(url)

@admin.action(
description=_(
"Preview the data sharing consent page rendered in the context of a course enrollment."
)
)
def preview_as_course(self, request, consent_page):
"""
Renders data sharing consent page in course context
"""
return self.preview(consent_page, course_id='course-v1:edX+TestX+Test_Course')

@admin.action(
description=_(
"Preview the data sharing consent page rendered in the context of a program enrollment."
)
)
def preview_as_program(self, request, consent_page):
"""
Renders data sharing consent page in program context
"""
return self.preview(consent_page, program_uuid='25c10a26-0b00-0000-bd06-7813546c29eb')

preview_as_course.label = _("Preview (course)")
preview_as_course.short_description = _(
"Preview the data sharing consent page rendered in the context of a course enrollment."
)
preview_as_program.label = _("Preview (program)")
preview_as_program.short_description = _(
"Preview the data sharing consent page rendered in the context of a program enrollment."
)

class Meta:
"""
Expand Down
4 changes: 1 addition & 3 deletions enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
Your project description goes here.
"""

__version__ = "4.1.7"

default_app_config = "enterprise.apps.EnterpriseConfig"
__version__ = "4.1.8"
81 changes: 52 additions & 29 deletions enterprise/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,15 @@ class PendingEnterpriseCustomerAdminUserInline(admin.TabularInline):
'get_admin_registration_url',
)

@admin.display(
description='Admin Registration Link'
)
def get_admin_registration_url(self, obj):
"""
Formats the ``admin_registration_url`` model property as an HTML link.
"""
return format_html('<a href="{0}">{0}</a>'.format(obj.admin_registration_url))

get_admin_registration_url.short_description = 'Admin Registration Link'


@admin.register(EnterpriseCustomerType)
class EnterpriseCustomerTypeAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -288,6 +289,10 @@ def get_form(self, request, obj=None, change=False, **kwargs):
form.user = request.user
return form

@admin.display(
description='Enable DSC',
boolean=True,
)
def enable_dsc(self, instance):
"""
Return True if data sharing consent is enabled for EnterpriseCustomer.
Expand All @@ -297,9 +302,10 @@ def enable_dsc(self, instance):
"""
return instance.enable_data_sharing_consent

enable_dsc.boolean = True
enable_dsc.short_description = 'Enable DSC'

@admin.display(
description='Logo',
boolean=True,
)
def has_logo(self, instance):
"""
Return True if EnterpriseCustomer has a logo.
Expand All @@ -313,9 +319,10 @@ def has_logo(self, instance):

return has_logo

has_logo.boolean = True
has_logo.short_description = 'Logo'

@admin.display(
description='Identity provider',
boolean=True,
)
def has_identity_provider(self, instance):
"""
Return True if EnterpriseCustomer has related identity provider.
Expand All @@ -325,9 +332,9 @@ def has_identity_provider(self, instance):
"""
return instance.has_identity_providers

has_identity_provider.boolean = True
has_identity_provider.short_description = 'Identity provider'

@admin.action(
description="Clear Data Sharing Consent for a Learner."
)
def manage_learners_data_sharing_consent(self, request, obj):
"""
Object tool handler method - redirects to "Clear Learners Data Sharing Consent" view
Expand All @@ -336,8 +343,10 @@ def manage_learners_data_sharing_consent(self, request, obj):
return HttpResponseRedirect(reverse("admin:" + UrlNames.MANAGE_LEARNERS_DSC, args=(obj.uuid,)))

manage_learners_data_sharing_consent.label = "Clear Data Sharing Consent"
manage_learners_data_sharing_consent.short_description = "Clear Data Sharing Consent for a Learner."

@admin.action(
description="Allows managing learners for this Enterprise Customer"
)
def manage_learners(self, request, obj):
"""
Object tool handler method - redirects to "Manage Learners" view
Expand All @@ -347,8 +356,10 @@ def manage_learners(self, request, obj):
return HttpResponseRedirect(manage_learners_url)

manage_learners.label = "Manage Learners"
manage_learners.short_description = "Allows managing learners for this Enterprise Customer"

@admin.action(
description='Transmit courses metadata for this Enterprise Customer'
)
def transmit_courses_metadata(self, request, obj):
"""
Object tool handler method - redirects to `Transmit Courses Metadata` view.
Expand All @@ -358,7 +369,6 @@ def transmit_courses_metadata(self, request, obj):
return HttpResponseRedirect(transmit_courses_metadata_url)

transmit_courses_metadata.label = 'Transmit Courses Metadata'
transmit_courses_metadata.short_description = 'Transmit courses metadata for this Enterprise Customer'

def get_urls(self):
"""
Expand Down Expand Up @@ -419,12 +429,14 @@ class Meta:
list_display = ('username', 'user_email', 'get_enterprise_customer')
search_fields = ('user_id',)

@admin.display(
description='Enterprise Customer'
)
def get_enterprise_customer(self, obj):
"""
Returns the name of enterprise customer linked with the enterprise customer user.
"""
return obj.enterprise_customer.name
get_enterprise_customer.short_description = 'Enterprise Customer'

def get_search_results(self, request, queryset, search_term):
search_term = search_term.strip()
Expand Down Expand Up @@ -577,22 +589,24 @@ class Meta:
'enterprise_customer__name',
)

@admin.display(
description='Enterprise Customer'
)
def get_enterprise_customer(self, obj):
"""
Returns the name of the associated EnterpriseCustomer.
"""
return obj.enterprise_customer.name

get_enterprise_customer.short_description = 'Enterprise Customer'

@admin.display(
description='Admin Registration Link'
)
def get_admin_registration_url(self, obj):
"""
Formats the ``admin_registration_url`` model property as an HTML link.
"""
return format_html('<a href="{0}">{0}</a>'.format(obj.admin_registration_url))

get_admin_registration_url.short_description = 'Admin Registration Link'


@admin.register(EnrollmentNotificationEmailTemplate)
class EnrollmentNotificationEmailTemplateAdmin(DjangoObjectActions, admin.ModelAdmin):
Expand Down Expand Up @@ -625,27 +639,31 @@ def preview(self, obj, preview_type):
preview_url = reverse("admin:" + UrlNames.PREVIEW_EMAIL_TEMPLATE, args=(obj.pk, preview_type))
return HttpResponseRedirect(preview_url)

@admin.action(
description=_(
"Preview the HTML template rendered in the context of a course enrollment."
)
)
def preview_as_course(self, request, obj):
"""
Redirect to preview the HTML template in the context of a course.
"""
return self.preview(obj, 'course')

preview_as_course.label = _("Preview (course)")
preview_as_course.short_description = _(
"Preview the HTML template rendered in the context of a course enrollment."
)

@admin.action(
description=_(
"Preview the HTML template rendered in the context of a program enrollment."
)
)
def preview_as_program(self, request, obj):
"""
Redirect to preview the HTML template in the context of a program.
"""
return self.preview(obj, 'program')

preview_as_program.label = _("Preview (program)")
preview_as_program.short_description = _(
"Preview the HTML template rendered in the context of a program enrollment."
)


@admin.register(EnterpriseCourseEnrollment)
Expand Down Expand Up @@ -780,6 +798,9 @@ def get_urls(self):
'include_exec_ed_2u_courses',
)

@admin.display(
description='Preview Catalog Courses'
)
def discovery_query_url(self, obj):
"""
Return discovery url for preview.
Expand All @@ -794,8 +815,6 @@ def has_delete_permission(self, request, obj=None):
return False

readonly_fields = ('discovery_query_url', 'uuid')
discovery_query_url.allow_tags = True
discovery_query_url.short_description = 'Preview Catalog Courses'


@admin.register(EnterpriseCustomerCatalog)
Expand Down Expand Up @@ -835,6 +854,9 @@ class Media:
'publish_audit_enrollment_urls',
)

@admin.display(
description='Preview Catalog Courses'
)
def preview_catalog_url(self, obj):
"""
Return enterprise catalog url for preview.
Expand All @@ -847,14 +869,15 @@ def preview_catalog_url(self, obj):
)

readonly_fields = ('preview_catalog_url',)
preview_catalog_url.short_description = 'Preview Catalog Courses'

@admin.display(
description='UUID'
)
def uuid_nowrap(self, obj):
"""
Inject html for disabling wrap for uuid
"""
return format_html('<span style="white-space: nowrap;">{uuid}</span>'.format(uuid=obj.uuid))
uuid_nowrap.short_description = 'UUID'

def get_form(self, request, obj=None, change=False, **kwargs):
form = super().get_form(request, obj, change, **kwargs)
Expand Down
Loading
Loading