-
Notifications
You must be signed in to change notification settings - Fork 1
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: add create external certificate task #76
Conversation
23bb9cf
to
0ac72bf
Compare
0ac72bf
to
9cc81a9
Compare
a85da6d
to
2b62c92
Compare
@johanv26 this is ready for review |
|
||
def get_student_api(): | ||
"""Allow to get the student_api module from | ||
https://github.com/eduNEXT/edunext-platform/blob/ednx-release/mango.master/common/djangoapps/student/models_api.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
student_api is weird because the file name is models_api but there are no classes. May be is my habit to relate models to classes hehehe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you check the certificate code openedx changes the models_api to student_api, so that's why a used the same openedx convention, however I'm not using this anymore, this belongs to a first version, and now I'm getting the user english name from the certificate data. So I will remove this
@@ -63,7 +64,7 @@ def create_course_notifications(course_key, **kwargs): # pylint: disable=unused | |||
create_course_notifications_task.delay(course_id=str(course_key)) | |||
|
|||
|
|||
def certificate_publisher(certificate, **kwargs): # pylint: disable=unused-argument | |||
def certificate_publisher(certificate, metadata, **kwargs): # pylint: disable=unused-argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def certificate_publisher(certificate, metadata, **kwargs): # pylint: disable=unused-argument | |
def certificate_publisher(certificate, metadata, *args, **kwargs): # pylint: disable=unused-argument |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO that is not necessary, since the signal doesn't' send any args
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _user_has_passing_grade(user, course_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this also brings some refactor.
eox-nelp/eox_nelp/signals/utils.py
Lines 52 to 63 in 2b62c92
def _user_has_passing_grade(user, course_id): | |
"""Determines if a user has passed a course based on the grading policies. | |
Args: | |
user<User>: Instace of Django User model. | |
course_id<str>: Unique course identifier. | |
Returns: | |
course_grade.passed<bool>: True if the user has passed the course, otherwise False | |
""" | |
course_grade = CourseGradeFactory().read(user, course_key=CourseKey.from_string(course_id)) | |
return course_grade.passed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, Imoved some common method to an different file in order to use them in multiple places, the name starting with _ could be consider as wrong since that have a private connotation, but I didn't make bigger this pr by adding name changes
certificate_publisher(self.certificate_data, self.metadata) | ||
|
||
generate_data_mock.assert_called_with( | ||
timestamp=self.metadata.time, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the time of the object where is generated, or is auto generated?
eox-nelp/eox_nelp/signals/tests/test_receivers.py
Lines 103 to 106 in 2b62c92
self.metadata = EventsMetadata( | |
event_type="org.openedx.learning.certificate.created.v1", | |
minorversion=0, | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in this case what return Self.metadata.time
That could raise an error?if its optional...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults to current time in UTC.
|
||
@patch("eox_nelp.signals.receivers._generate_external_certificate_data") | ||
@patch("eox_nelp.signals.receivers.create_external_certificate") | ||
def test_create_call(self, mock_task, generate_data_mock): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_create_call(self, mock_task, generate_data_mock): | |
def test_create_call(self, create_external_certificate_mock, generate_data_mock): |
this is not more explicit?
User = get_user_model() | ||
|
||
|
||
def _generate_external_certificate_data(timestamp, certificate_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _generate_external_certificate_data(timestamp, certificate_data): | |
def _generate_futurex_external_certificate_data(timestamp, certificate_data): |
??
Because we have a function like dispatch futurex progress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used futurex
because that is the name of the service. In this case I have no idea how the service name's but probably it's not futurex
since the base url is different
2b62c92
to
2617741
Compare
This reverts commit 65cad739397645fcb1841d58784d3aaa9359141e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in my opinion
Description
https://edunext.atlassian.net/browse/FUTUREX-481
Testing instructions
Before
After