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

feat: Added blackboard channel integration #19

Merged
merged 1 commit into from
Feb 24, 2025
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
5 changes: 5 additions & 0 deletions channel_integrations/blackboard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
The Blackboard Integrated Channel package.
"""

__version__ = "0.0.1"

Check warning on line 5 in channel_integrations/blackboard/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/__init__.py#L5

Added line #L5 was not covered by tests
146 changes: 146 additions & 0 deletions channel_integrations/blackboard/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
"""
Admin integration for configuring Blackboard app to communicate with Blackboard systems.
"""
from config_models.admin import ConfigurationModelAdmin
from django_object_actions import DjangoObjectActions

Check warning on line 5 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L4-L5

Added lines #L4 - L5 were not covered by tests

from django.contrib import admin, messages
from django.core.exceptions import ValidationError
from django.http import HttpResponseRedirect
from django.utils.html import format_html

Check warning on line 10 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L7-L10

Added lines #L7 - L10 were not covered by tests

from channel_integrations.blackboard.models import (

Check warning on line 12 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L12

Added line #L12 was not covered by tests
BlackboardEnterpriseCustomerConfiguration,
BlackboardGlobalConfiguration,
BlackboardLearnerDataTransmissionAudit,
)
from channel_integrations.integrated_channel.admin import BaseLearnerDataTransmissionAuditAdmin

Check warning on line 17 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L17

Added line #L17 was not covered by tests


@admin.register(BlackboardGlobalConfiguration)
class BlackboardGlobalConfigurationAdmin(ConfigurationModelAdmin):

Check warning on line 21 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L20-L21

Added lines #L20 - L21 were not covered by tests
"""
Django admin model for BlackboardGlobalConfiguration.
"""
list_display = (

Check warning on line 25 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L25

Added line #L25 was not covered by tests
"app_key",
"app_secret",
)

class Meta:
model = BlackboardGlobalConfiguration

Check warning on line 31 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L30-L31

Added lines #L30 - L31 were not covered by tests


@admin.register(BlackboardEnterpriseCustomerConfiguration)
class BlackboardEnterpriseCustomerConfigurationAdmin(DjangoObjectActions, admin.ModelAdmin):

Check warning on line 35 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L34-L35

Added lines #L34 - L35 were not covered by tests
"""
Django admin model for BlackEnterpriseCustomerConfiguration.
"""
list_display = (

Check warning on line 39 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L39

Added line #L39 was not covered by tests
"enterprise_customer_name",
"blackboard_base_url",
)

readonly_fields = (

Check warning on line 44 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L44

Added line #L44 was not covered by tests
"enterprise_customer_name",
"refresh_token",
"customer_oauth_authorization_url",
"uuid",
"transmission_chunk_size",
)

raw_id_fields = (

Check warning on line 52 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L52

Added line #L52 was not covered by tests
"enterprise_customer",
)

search_fields = ("enterprise_customer_name",)
change_actions = ("force_content_metadata_transmission",)

Check warning on line 57 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L56-L57

Added lines #L56 - L57 were not covered by tests

class Meta:
model = BlackboardEnterpriseCustomerConfiguration

Check warning on line 60 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L59-L60

Added lines #L59 - L60 were not covered by tests

def enterprise_customer_name(self, obj):

Check warning on line 62 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L62

Added line #L62 was not covered by tests
"""
Returns: the name for the attached EnterpriseCustomer.

Args:
obj: The instance of BlackboardEnterpriseCustomerConfiguration
being rendered with this admin form.
"""
return obj.enterprise_customer.name

Check warning on line 70 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L70

Added line #L70 was not covered by tests

def customer_oauth_authorization_url(self, obj):

Check warning on line 72 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L72

Added line #L72 was not covered by tests
"""
Returns: an html formatted oauth authorization link when the blackboard_base_url and client_id are available.

Args:
obj: The instance of BlackboardEnterpriseCustomerConfiguration
being rendered with this admin form.
"""
if obj.oauth_authorization_url:
return format_html((f'<a href="{obj.oauth_authorization_url}">Authorize Link</a>'))

Check warning on line 81 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L81

Added line #L81 was not covered by tests
else:
return None

Check warning on line 83 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L83

Added line #L83 was not covered by tests

@admin.action(

Check warning on line 85 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L85

Added line #L85 was not covered by tests
description="Force content metadata transmission for this Enterprise Customer"
)
def force_content_metadata_transmission(self, request, obj):

Check warning on line 88 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L88

Added line #L88 was not covered by tests
"""
Updates the modified time of the customer record to retransmit courses metadata
and redirects to configuration view with success or error message.
"""
try:
obj.enterprise_customer.save()
messages.success(

Check warning on line 95 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L93-L95

Added lines #L93 - L95 were not covered by tests
request,
f'''The blackboard enterprise customer content metadata
“<BlackboardEnterpriseCustomerConfiguration for Enterprise
{obj.enterprise_customer.name}>” was updated successfully.''',
)
except ValidationError:
messages.error(

Check warning on line 102 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L101-L102

Added lines #L101 - L102 were not covered by tests
request,
f'''The blackboard enterprise customer content metadata
“<BlackboardEnterpriseCustomerConfiguration for Enterprise
{obj.enterprise_customer.name}>” was not updated successfully.''',
)
return HttpResponseRedirect(

Check warning on line 108 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L108

Added line #L108 was not covered by tests
"/admin/blackboard/blackboardenterprisecustomerconfiguration"
)
force_content_metadata_transmission.label = "Force content metadata transmission"

Check warning on line 111 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L111

Added line #L111 was not covered by tests


@admin.register(BlackboardLearnerDataTransmissionAudit)
class BlackboardLearnerDataTransmissionAuditAdmin(BaseLearnerDataTransmissionAuditAdmin):

Check warning on line 115 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L114-L115

Added lines #L114 - L115 were not covered by tests
"""
Django admin model for BlackboardLearnerDataTransmissionAudit.
"""
list_display = (

Check warning on line 119 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L119

Added line #L119 was not covered by tests
"enterprise_course_enrollment_id",
"course_id",
"status",
"modified",
)

readonly_fields = (

Check warning on line 126 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L126

Added line #L126 was not covered by tests
"blackboard_user_email",
"progress_status",
"content_title",
"enterprise_customer_name",
"friendly_status_message",
"api_record",
)

search_fields = (

Check warning on line 135 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L135

Added line #L135 was not covered by tests
"blackboard_user_email",
"enterprise_course_enrollment_id",
"course_id",
"content_title",
"friendly_status_message"
)

list_per_page = 1000

Check warning on line 143 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L143

Added line #L143 was not covered by tests

class Meta:
model = BlackboardLearnerDataTransmissionAudit

Check warning on line 146 in channel_integrations/blackboard/admin/__init__.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/admin/__init__.py#L145-L146

Added lines #L145 - L146 were not covered by tests
20 changes: 20 additions & 0 deletions channel_integrations/blackboard/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Enterprise Integrated Channel Blackboard Django application initialization.
"""

from django.apps import AppConfig

Check warning on line 5 in channel_integrations/blackboard/apps.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/apps.py#L5

Added line #L5 was not covered by tests

CHANNEL_NAME = 'channel_integrations.blackboard'
VERBOSE_NAME = 'Enterprise Blackboard Integration'
BRIEF_CHANNEL_NAME = 'blackboard'

Check warning on line 9 in channel_integrations/blackboard/apps.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/apps.py#L7-L9

Added lines #L7 - L9 were not covered by tests


class BlackboardConfig(AppConfig):

Check warning on line 12 in channel_integrations/blackboard/apps.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/apps.py#L12

Added line #L12 was not covered by tests
"""
Configuration for the Enterprise Integrated Channel Blackboard Django application.
"""
name = CHANNEL_NAME
verbose_name = VERBOSE_NAME
oauth_token_auth_path = "learn/api/public/v1/oauth2/token"
brief_channel_name = BRIEF_CHANNEL_NAME
label = 'blackboard_channel'

Check warning on line 20 in channel_integrations/blackboard/apps.py

View check run for this annotation

Codecov / codecov/patch

channel_integrations/blackboard/apps.py#L16-L20

Added lines #L16 - L20 were not covered by tests
Loading
Loading