Skip to content

Commit

Permalink
Merge branch 'master' into pythonupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 authored Apr 1, 2024
2 parents 03defd6 + 1b89b8c commit cf4c2b2
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 143 deletions.
20 changes: 4 additions & 16 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,6 @@ def update_attempt_status(attempt_id, to_status,
}
)
email = create_proctoring_attempt_status_email(
user_id,
exam_attempt_obj,
course_name,
exam['course_id']
Expand Down Expand Up @@ -1730,15 +1729,14 @@ def update_attempt_status(attempt_id, to_status,
return attempt['id']


def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_name, course_id):
def create_proctoring_attempt_status_email(exam_attempt_obj, course_name, course_id):
"""
Creates an email about change in proctoring attempt status.
"""
# Don't send an email unless this is a non-practice proctored exam
if not exam_attempt_obj.taking_as_proctored or exam_attempt_obj.is_sample_attempt:
return None

user = USER_MODEL.objects.get(id=user_id)
email_subject = (
_('Proctoring Results For {course_name} {exam_name}').format(
course_name=course_name,
Expand All @@ -1748,16 +1746,13 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
status = exam_attempt_obj.status
if status == ProctoredExamStudentAttemptStatus.submitted:
template_name = 'proctoring_attempt_submitted_email.html'
email_subject = (
_('Proctoring Review In Progress For {course_name} {exam_name}').format(
course_name=course_name,
exam_name=exam_attempt_obj.proctored_exam.exam_name
)
)
email_subject = 'Proctoring attempt submitted'
elif status == ProctoredExamStudentAttemptStatus.verified:
template_name = 'proctoring_attempt_satisfactory_email.html'
email_subject = 'Proctoring attempt verified'
elif status == ProctoredExamStudentAttemptStatus.rejected:
template_name = 'proctoring_attempt_unsatisfactory_email.html'
email_subject = 'Proctoring attempt rejected'
else:
# Don't send an email for any other attempt status codes
return None
Expand All @@ -1767,11 +1762,6 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
course_home_url = get_course_home_url(exam_attempt_obj.proctored_exam.course_id)

exam_name = exam_attempt_obj.proctored_exam.exam_name
support_email_subject = _('Proctored exam {exam_name} in {course_name} for user {username}').format(
exam_name=exam_name,
course_name=course_name,
username=user.username,
)

scheme = 'https' if getattr(settings, 'HTTPS', 'on') == 'on' else 'http'
default_contact_url = f'{scheme}://{constants.SITE_NAME}/support/contact_us'
Expand All @@ -1788,13 +1778,11 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
contact_url_text = contact_url

body = email_template.render({
'username': user.username,
'course_url': course_home_url,
'course_name': course_name,
'exam_name': exam_name,
'status': status,
'platform': constants.PLATFORM_NAME,
'support_email_subject': support_email_subject,
'contact_url': contact_url,
'contact_url_text': contact_url_text,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
{% block introduction %}
{% blocktrans %}
Hello {{ username }},
Hello,
{% endblocktrans %}
{% endblock %}
</p>
Expand Down
12 changes: 5 additions & 7 deletions edx_proctoring/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ def tearDown(self):
@ddt.data(
[
ProctoredExamStudentAttemptStatus.submitted,
'Proctoring Review In Progress',
'Proctoring attempt submitted',
'was submitted successfully',
],
[
ProctoredExamStudentAttemptStatus.verified,
'Proctoring Results',
'Proctoring attempt verified',
'was reviewed and you met all proctoring requirements',
],
[
ProctoredExamStudentAttemptStatus.rejected,
'Proctoring Results',
'Proctoring attempt rejected',
'the course team has identified one or more violations',
]
)
Expand All @@ -84,11 +84,10 @@ def test_send_email(self, status, expected_subject, expected_message_string):
# Verify the subject
actual_subject = self._normalize_whitespace(mail.outbox[0].subject)
self.assertIn(expected_subject, actual_subject)
self.assertIn(self.exam_name, actual_subject)

# Verify the body
actual_body = self._normalize_whitespace(mail.outbox[0].body)
self.assertIn('Hello tester,', actual_body)
self.assertIn('Hello,', actual_body)
self.assertIn('Your proctored exam "Test Exam"', actual_body)
self.assertIn(credit_state['course_name'], actual_body)
self.assertIn(expected_message_string, actual_body)
Expand Down Expand Up @@ -223,8 +222,7 @@ def test_send_email_unicode(self):

# Verify the subject
actual_subject = self._normalize_whitespace(mail.outbox[0].subject)
self.assertIn('Proctoring Review In Progress', actual_subject)
self.assertIn(course_name, actual_subject)
self.assertIn('Proctoring attempt submitted', actual_subject)

# Verify the body
actual_body = self._normalize_whitespace(mail.outbox[0].body)
Expand Down
67 changes: 46 additions & 21 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ amqp==5.2.0
# via kombu
appdirs==1.4.4
# via fs
asgiref==3.7.2
asgiref==3.8.1
# via django
backports-zoneinfo[tzdata]==0.2.1; python_version < '3.9'
# via
# celery
# django
# djangorestframework
# kombu
billiard==4.2.0
# via celery
Expand All @@ -35,16 +37,19 @@ click==8.1.7
# click-didyoumean
# click-plugins
# click-repl
# code-annotations
# edx-django-utils
click-didyoumean==0.3.0
click-didyoumean==0.3.1
# via celery
click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
cryptography==42.0.2
code-annotations==1.7.0
# via edx-toggles
cryptography==42.0.5
# via pyjwt
django==3.2.24
django==4.2.11
# via
# -c requirements/common_constraints.txt
# -r requirements/base.in
Expand All @@ -55,16 +60,19 @@ django==3.2.24
# drf-jwt
# edx-django-utils
# edx-drf-extensions
# edx-toggles
# edx-when
# event-tracking
# jsonfield
# openedx-events
django-crum==0.7.9
# via
# -r requirements/base.in
# edx-django-utils
# edx-toggles
django-ipware==6.0.4
# via -r requirements/base.in
django-model-utils==4.3.1
django-model-utils==4.4.0
# via
# -r requirements/base.in
# edx-when
Expand All @@ -77,42 +85,52 @@ django-waffle==4.1.0
# -r requirements/base.in
# edx-django-utils
# edx-drf-extensions
# edx-toggles
django-webpack-loader==0.7.0
# via
# -c requirements/constraints.txt
# -r requirements/base.in
djangorestframework==3.14.0
djangorestframework==3.15.1
# via
# -r requirements/base.in
# drf-jwt
# edx-drf-extensions
drf-jwt==1.19.2
# via edx-drf-extensions
edx-django-utils==5.10.1
edx-django-utils==5.11.0
# via
# edx-drf-extensions
# edx-rest-api-client
# edx-toggles
# edx-when
# event-tracking
# openedx-events
edx-drf-extensions==10.2.0
# via
# -r requirements/base.in
# edx-when
edx-opaque-keys==2.5.1
edx-opaque-keys[django]==2.5.1
# via
# -r requirements/base.in
# edx-drf-extensions
# edx-when
# openedx-events
edx-rest-api-client==5.6.1
# via -r requirements/base.in
edx-toggles==5.1.1
# via event-tracking
edx-when==2.4.0
# via -r requirements/base.in
event-tracking==2.2.0
event-tracking==2.3.1
# via -r requirements/base.in
fastavro==1.9.4
# via openedx-events
fs==2.4.16
# via xblock
idna==3.6
# via requests
jinja2==3.1.3
# via code-annotations
jsonfield==3.1.0
# via -r requirements/base.in
kombu==5.3.5
Expand All @@ -123,10 +141,13 @@ mako==1.3.2
# via xblock
markupsafe==2.1.5
# via
# jinja2
# mako
# xblock
newrelic==9.6.0
newrelic==9.7.1
# via edx-django-utils
openedx-events==9.5.2
# via event-tracking
pbr==6.0.0
# via stevedore
prompt-toolkit==3.0.43
Expand All @@ -143,29 +164,30 @@ pyjwt[crypto]==2.8.0
# drf-jwt
# edx-drf-extensions
# edx-rest-api-client
# pyjwt
pymongo==3.13.0
# via
# edx-opaque-keys
# event-tracking
pynacl==1.5.0
# via edx-django-utils
python-dateutil==2.8.2
python-dateutil==2.9.0.post0
# via
# -r requirements/base.in
# celery
# xblock
python-ipware==2.0.1
python-ipware==2.0.2
# via django-ipware
python-slugify==8.0.4
# via code-annotations
pytz==2024.1
# via
# -r requirements/base.in
# django
# djangorestframework
# event-tracking
# xblock
pyyaml==6.0.1
# via xblock
# via
# code-annotations
# xblock
requests==2.31.0
# via
# edx-drf-extensions
Expand All @@ -186,20 +208,23 @@ slumber==0.7.1
# via edx-rest-api-client
sqlparse==0.4.4
# via django
stevedore==5.1.0
stevedore==5.2.0
# via
# code-annotations
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.9.0
text-unidecode==1.3
# via python-slugify
typing-extensions==4.10.0
# via
# asgiref
# edx-opaque-keys
# kombu
tzdata==2023.4
tzdata==2024.1
# via
# backports-zoneinfo
# celery
urllib3==2.2.0
urllib3==2.2.1
# via requests
vine==5.1.0
# via
Expand All @@ -212,7 +237,7 @@ web-fragments==2.1.0
# via xblock
webob==1.8.7
# via xblock
xblock==1.10.0
xblock==3.0.0
# via edx-when

# The following packages are considered to be unsafe in a requirements file:
Expand Down
2 changes: 1 addition & 1 deletion requirements/celery50.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ amqp==5.2.0
billiard==4.2.0
celery==5.3.6
click==8.1.7
click-didyoumean==0.3.0
click-didyoumean==0.3.1
click-repl==0.3.0
kombu==5.3.5
prompt-toolkit==3.0.43
Expand Down
12 changes: 6 additions & 6 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#
# make upgrade
#
cachetools==5.3.2
cachetools==5.3.3
# via tox
chardet==5.2.0
# via tox
colorama==0.4.6
# via tox
coverage==7.4.1
coverage==7.4.4
# via -r requirements/ci.in
distlib==0.3.8
# via virtualenv
filelock==3.13.1
filelock==3.13.3
# via
# tox
# virtualenv
packaging==23.2
packaging==24.0
# via
# pyproject-api
# tox
Expand All @@ -34,7 +34,7 @@ tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.12.1
tox==4.14.2
# via -r requirements/ci.in
virtualenv==20.25.0
virtualenv==20.25.1
# via tox
Loading

0 comments on commit cf4c2b2

Please sign in to comment.