예제 #1
0
 def canceled_by_system(self, reason):
     if self.status == self.STATUS_TYPES.WAITING or self.status == self.STATUS_TYPES.BOOKED:
         self.status = self.STATUS_TYPES.CANCELED_BY_SYSTEM
         self.cancelation_reason = reason
         super(self.__class__, self).save()
         rooms.delete(roomid=self.scribblar_id)
         
         from apps.profile.models import UserCreditMovement
         student = self.student
         student_profile = student.profile
         student_profile.credit += self.credit_fee
         student_profile.save()
         tutor = self.tutor
         tutor_profile = tutor.profile
         student.movements.create(type=UserCreditMovement.MOVEMENTS_TYPES.CANCELED_BY_SYSTEM, credits=self.credit_fee, related_class=self)
         student_profile.send_notification(student_profile.NOTIFICATIONS_TYPES.CANCELED_BY_SYSTEM, {
             'class': self,
             'student': student,
             'tutor': tutor,
         })
         tutor_profile.send_notification(tutor_profile.NOTIFICATIONS_TYPES.CANCELED_BY_SYSTEM, {
             'class': self,
             'student': student,
             'tutor': tutor,
         })
예제 #2
0
 def delete(self):
     if self.scribblar_id:
         try:
             rooms.delete(roomid=self.scribblar_id)
         except:
             pass
     super(self.__class__, self).delete()
예제 #3
0
    def stop_class(self):
        if self.status == self.STATUS_TYPES.BOOKED:
            self.status = self.STATUS_TYPES.STOPPED_BY_STUDENT
            super(self.__class__, self).save()
            rooms.delete(roomid=self.scribblar_id)

            from apps.profile.models import UserCreditMovement
            student = self.student
            student_profile = student.profile
            student_profile.credit += self.credit_fee
            student_profile.save()
            student.movements.create(type=UserCreditMovement.MOVEMENTS_TYPES.STOPPED_BY_STUDENT, credits=self.credit_fee, related_class=self)