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

Shadinaif/fix short resource #8

Closed
wants to merge 12 commits into from
Closed
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: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [py38-django32, py38-django42, quality]
python-version:
- '3.8'
- '3.11'
toxenv: [django42, quality]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.11

- name: Install pip
run: pip install -r requirements/pip.txt
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/upgrade-python-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
# optional parameters below; fill in if you'd like github or email notifications
# user_reviewers: ""
# team_reviewers: ""
email_address: "cosmonauts-requirements-update@2u-internal.opsgenie.net"
send_success_notification: true
secrets:
requirements_bot_github_token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }}
requirements_bot_github_email: ${{ secrets.REQUIREMENTS_BOT_GITHUB_EMAIL }}
Expand Down
9 changes: 0 additions & 9 deletions .tx/config

This file was deleted.

32 changes: 32 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@ Please See the `releases tab <https://github.com/openedx/xblock-lti-consumer/rel

Unreleased
~~~~~~~~~~


9.12.0 - 2024-07-16
-------------------
* Fix Data too long for column 'resource_id'. Increase column size to 255.

9.11.3 - 2024-05-30
-------------------
* Remove utf-8 encoding for user full name

9.11.2 - 2024-05-30
-------------------
* Update python version for pypi publish workflow

9.11.1 - 2024-05-30
-------------------
* Add utf-8 encoding for user full name

9.11.0 - 2024-04-24
-------------------
* Remove lxml pin

9.10.0 - 2024-02-29
------------------
* Remove Transifex calls and bundled translation files for the OEP-58 proposal.
* BREAKING CHANGE: This version breaks translations with Quince and earlier releases.
* Adding python 3.11 support. Dropping django32 support.

9.9.0 - 2024-01-24
---------------------------
* XBlockI18NService js translations support

9.8.3 - 2024-01-23
------------------
* Additional NewRelic traces to functions suspected of causing performance issues.
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with
pip-compile --upgrade -o requirements/tox.txt requirements/tox.in
pip-compile --upgrade -o requirements/ci.txt requirements/ci.in
pip-compile --upgrade -o requirements/quality.txt requirements/quality.in
# Let tox control the Django version version for tests
grep -e "^django==" requirements/test.txt > requirements/django.txt
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt


## Localization targets
Expand Down
11 changes: 0 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,6 @@ This list is what is used to resolve dependencies when an upstream project is co
this XBlock package. requirements.txt is used to install the same dependencies when running
the tests for this package.

Downloading translations from Transifex
---------------------------------------

If you want to download translations from Transifex install
`transifex client <https://docs.transifex.com/client/installing-the-client/>`_ and run this command while
inside project root directory:

.. code:: bash

$ tx pull -f --mode=reviewed

Further Development Info
------------------------

Expand Down
2 changes: 1 addition & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ metadata:
spec:
type: XBlock
lifecycle: production
owner: masters-devs-cosmonauts
owner: ~
subcomponentOf: LTI
2 changes: 1 addition & 1 deletion lti_consumer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .apps import LTIConsumerApp
from .lti_xblock import LtiConsumerXBlock

__version__ = '9.8.3'
__version__ = '9.12.0'
11 changes: 0 additions & 11 deletions lti_consumer/conf/locale/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

locales:
- en # English - Source Language
- ar # Arabic
- es_419 # Spanish (Latin America)
- fr # French
- he # Hebrew
- hi # Hindi
- ja_JP # Japanese (Japan)
- ko_KR # Korean (Korea)
- pt_BR # Portuguese (Brazil)
- pt_PT # Portuguese (Portugal)
- ru # Russian
- zh_CN # Chinese (China)

# Directories we don't search for strings.
ignore_dirs:
Expand Down
35 changes: 15 additions & 20 deletions lti_consumer/lti_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@
import urllib.parse
from collections import namedtuple
from importlib import import_module
import pkg_resources

import bleach
from django.conf import settings
from django.utils import timezone, translation
from django.utils import timezone
from web_fragments.fragment import Fragment

from webob import Response
Expand Down Expand Up @@ -257,6 +256,7 @@ class LtiConsumerXBlock(StudioEditableXBlockMixin, XBlock):
"""

block_settings_key = 'lti_consumer'
i18n_js_namespace = 'XBlockLtiConsumerI18N'

display_name = String(
display_name=_("Display Name"),
Expand Down Expand Up @@ -662,20 +662,15 @@ def workbench_scenarios():
]
return scenarios

@staticmethod
def _get_statici18n_js_url(loader): # pragma: no cover
"""
Returns the Javascript translation file for the currently selected language, if any found by
`pkg_resources`
"""
lang_code = translation.get_language()
if not lang_code:
return None
text_js = 'public/js/translations/{lang_code}/text.js'
country_code = lang_code.split('-')[0]
for code in (translation.to_locale(lang_code), lang_code, country_code):
if pkg_resources.resource_exists(loader.module_name, text_js.format(lang_code=code)):
return text_js.format(lang_code=code)
def _get_statici18n_js_url(self):
"""
Return the JavaScript translation file provided by the XBlockI18NService.
"""
if i18n_service := self.runtime.service(self, 'i18n'):
if url_getter_func := getattr(i18n_service, 'get_javascript_i18n_catalog_url', None):
if javascript_url := url_getter_func(self):
return javascript_url

return None

def validate_field_data(self, validation, data):
Expand Down Expand Up @@ -1197,9 +1192,9 @@ def author_view(self, context):
)
fragment.add_css(loader.load_unicode('static/css/student.css'))
fragment.add_javascript(loader.load_unicode('static/js/xblock_lti_consumer.js'))
statici18n_js_url = self._get_statici18n_js_url(loader)
statici18n_js_url = self._get_statici18n_js_url()
if statici18n_js_url:
fragment.add_javascript_url(self.runtime.local_resource_url(self, statici18n_js_url))
fragment.add_javascript_url(statici18n_js_url)
fragment.initialize_js('LtiConsumerXBlock')
return fragment

Expand All @@ -1224,9 +1219,9 @@ def student_view(self, context):
fragment.add_content(loader.render_mako_template('/templates/html/student.html', context))
fragment.add_css(loader.load_unicode('static/css/student.css'))
fragment.add_javascript(loader.load_unicode('static/js/xblock_lti_consumer.js'))
statici18n_js_url = self._get_statici18n_js_url(loader)
statici18n_js_url = self._get_statici18n_js_url()
if statici18n_js_url:
fragment.add_javascript_url(self.runtime.local_resource_url(self, statici18n_js_url))
fragment.add_javascript_url(statici18n_js_url)
fragment.initialize_js('LtiConsumerXBlock')
return fragment

Expand Down
18 changes: 18 additions & 0 deletions lti_consumer/migrations/0018_increase_length_of_resource_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.23 on 2023-12-25 10:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('lti_consumer', '0017_lticonfiguration_lti_1p3_redirect_uris'),
]

operations = [
migrations.AlterField(
model_name='ltiagslineitem',
name='resource_id',
field=models.CharField(blank=True, max_length=255),
),
]
2 changes: 1 addition & 1 deletion lti_consumer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ class LtiAgsLineItem(models.Model):
)

# Tool resource identifier, not used by the LMS.
resource_id = models.CharField(max_length=100, blank=True)
resource_id = models.CharField(max_length=255, blank=True)

# LMS Resource link
# Must be the same as the one sent in the tool's LTI launch.
Expand Down
7 changes: 4 additions & 3 deletions lti_consumer/tests/unit/test_lti_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@ def setUp(self):
fake_user_email = 'abc@example.com'
fake_user.emails = [fake_user_email]

full_name_mock = PropertyMock(return_value='fake_full_name')
fake_name = 'fáke fǔll ñamë'
full_name_mock = PropertyMock(return_value=fake_name)
type(fake_user).full_name = full_name_mock

fake_username = 'fake'
Expand Down Expand Up @@ -1077,7 +1078,7 @@ def test_lti_launch_pii_sharing(

set_user_data_kwargs['person_sourcedid'] = 'fake' if pii_sharing_enabled and ask_to_send_username else None
set_user_data_kwargs['person_name_full'] = (
'fake_full_name' if pii_sharing_enabled and ask_to_send_full_name else None
'fáke fǔll ñamë' if pii_sharing_enabled and ask_to_send_full_name else None
)
set_user_data_kwargs['person_contact_email_primary'] = (
'abc@example.com' if pii_sharing_enabled and ask_to_send_email else None
Expand Down Expand Up @@ -1814,7 +1815,7 @@ def test_get_lti_1p3_launch_data(
fake_user_email = 'fake_email@example.com'
fake_username = 'fake_username'

fake_name = 'fake_full_name'
fake_name = 'fáke fǔll ñamë'
full_name_mock = PropertyMock(return_value=fake_name)
type(fake_user).full_name = full_name_mock

Expand Down
Loading
Loading