def pre_save(cls, sender, instance, **kwds): if instance.old_canceled != instance.canceled and instance.old_canceled is False: assignments = AssignmentDao.assignments_for_job(instance.id) emails = set() for assignment in assignments: emails.add(assignment.member.email) instance.slots = 0 if len(emails) > 0: send_job_canceled(emails, instance) if instance.old_time != instance.time: assignments = AssignmentDao.assignments_for_job(instance.id) emails = set() for assignment in assignments: emails.add(assignment.member.email) if len(emails) > 0: send_job_time_changed(emails, instance)
def handle_job_canceled(sender, instance, **kwargs): assignments = AssignmentDao.assignments_for_job(instance.id) emails = set() for assignment in assignments: emails.add(assignment.member.email) assignment.delete() instance.slots = 0 if len(emails) > 0: membernotification.job_canceled(emails, instance)
def transform_job_type(self, queryset): for inst in queryset.all(): i = 0 for rj in JobDao.recurings_by_type(inst.id): oj = OneTimeJob() attribute_copy(inst, oj) attribute_copy(rj, oj) oj.name += str(i) i += 1 oj.save() for b in AssignmentDao.assignments_for_job(rj.id): b.job = oj b.save() rj.delete() inst.delete()
def handle(self, *args, **options): now = timezone.now() end = now + datetime.timedelta(days=2) for job in JobDao.jobs_to_remind(now, end): participants = [] emails = [] for assignment in AssignmentDao.assignments_for_job(job.id): if assignment.member is not None: participants.append(str(assignment.member)) emails.append(assignment.member.email) send_job_reminder(emails, job, ', '.join(participants)) job.reminder_sent = True job.save() print(('reminder sent for job ' + str(job.id)))
def transform_job(self, queryset): for inst in queryset.all(): t = JobType() rj = RecuringJob() attribute_copy(inst, t) attribute_copy(inst, rj) name = t.name t.name = "something temporal which possibly is never used" t.save() rj.type = t rj.save() for b in AssignmentDao.assignments_for_job(inst.id): b.job = rj b.save() inst.delete() t.name = name t.save()
def get_status_percentage(self): assignments = AssignmentDao.assignments_for_job(self.id) if self.slots < 1: return get_status_image(100) return get_status_image(assignments.count() * 100 / self.slots)
def post_init(cls, sender, instance, **kwds): instance.old_time = instance.time instance.old_canceled = instance.canceled if instance.canceled: assignments = AssignmentDao.assignments_for_job(instance.id) assignments.delete()
def handle_job_time_changed(sender, instance, **kwargs): assignments = AssignmentDao.assignments_for_job(instance.id) emails = set([assignment.member.email for assignment in assignments]) if len(emails) > 0: membernotification.job_time_changed(emails, instance)