def save(self, *args, **kwargs): # pylint: disable=signature-differs """ After the base save() method finishes, fire the COURSE_CERT_CHANGED signal. If the learner is currently passing the course we also fire the COURSE_CERT_AWARDED signal. The COURSE_CERT_CHANGED signal helps determine if a Course Certificate can be awarded to a learner in the Credentials IDA. The COURSE_CERT_AWARDED signal helps determine if a Program Certificate can be awarded to a learner in the Credentials IDA. """ super().save(*args, **kwargs) COURSE_CERT_CHANGED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, ) if CertificateStatuses.is_passing_status(self.status): COURSE_CERT_AWARDED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, )
def send_course_cert_changed_signal(self): COURSE_CERT_CHANGED.send_robust( sender=self.__class__, user=self.generated_certificate.user, course_key=self.generated_certificate.course_id, mode=self.generated_certificate.mode, status=self.generated_certificate.status, )
def test_signal_received(self, mock_is_learner_issuance_enabled, mock_task): # pylint: disable=unused-argument """ Ensures the receiver function is invoked when COURSE_CERT_CHANGED is sent. Suboptimal: because we cannot mock the receiver function itself (due to the way django signals work), we mock a configuration call that is known to take place inside the function. """ COURSE_CERT_CHANGED.send(**self.signal_kwargs) self.assertEqual(mock_is_learner_issuance_enabled.call_count, 2)
def save(self, *args, **kwargs): """ After the base save() method finishes, fire the COURSE_CERT_AWARDED signal iff we are saving a record of a learner passing the course. As well as the COURSE_CERT_CHANGED for any save event. """ super(GeneratedCertificate, self).save(*args, **kwargs) COURSE_CERT_CHANGED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, ) if CertificateStatuses.is_passing_status(self.status): COURSE_CERT_AWARDED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, )
def save(self, *args, **kwargs): # pylint: disable=signature-differs """ After the base save() method finishes, fire the COURSE_CERT_CHANGED signal. If the learner is currently passing the course we also fire the COURSE_CERT_AWARDED signal. The COURSE_CERT_CHANGED signal helps determine if a Course Certificate can be awarded to a learner in the Credentials IDA. The COURSE_CERT_AWARDED signal helps determine if a Program Certificate can be awarded to a learner in the Credentials IDA. """ super().save(*args, **kwargs) COURSE_CERT_CHANGED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, ) # .. event_implemented_name: CERTIFICATE_CHANGED CERTIFICATE_CHANGED.send_event(certificate=CertificateData( user=UserData( pii=UserPersonalData( username=self.user.username, email=self.user.email, name=self.user.profile.name, ), id=self.user.id, is_active=self.user.is_active, ), course=CourseData(course_key=self.course_id, ), mode=self.mode, grade=self.grade, current_status=self.status, download_url=self.download_url, name=self.name, )) if CertificateStatuses.is_passing_status(self.status): COURSE_CERT_AWARDED.send_robust( sender=self.__class__, user=self.user, course_key=self.course_id, mode=self.mode, status=self.status, ) # .. event_implemented_name: CERTIFICATE_CREATED CERTIFICATE_CREATED.send_event(certificate=CertificateData( user=UserData( pii=UserPersonalData( username=self.user.username, email=self.user.email, name=self.user.profile.name, ), id=self.user.id, is_active=self.user.is_active, ), course=CourseData(course_key=self.course_id, ), mode=self.mode, grade=self.grade, current_status=self.status, download_url=self.download_url, name=self.name, ))