Example #1
0
    def save(self, *args, **kwargs):
        created = self.pk is None

        # save the object
        super(Institute, self).save(*args, **kwargs)

        if created:
            log.add(self, 'Created')
        for field in self._tracker.changed():
            log.change(self, 'Changed %s to %s'
                       % (field, getattr(self, field)))

        # update the datastore
        from karaage.datastores import machine_category_save_institute
        machine_category_save_institute(self)

        # has group changed?
        if self._tracker.has_changed("group_id"):
            old_group_pk = self._tracker.previous("group_id")
            new_group = self.group
            if old_group_pk is not None:
                old_group = Group.objects.get(pk=old_group_pk)
                from karaage.datastores import remove_accounts_from_institute
                query = Account.objects.filter(person__groups=old_group)
                remove_accounts_from_institute(query, self)
            if new_group is not None:
                from karaage.datastores import add_accounts_to_institute
                query = Account.objects.filter(person__groups=new_group)
                add_accounts_to_institute(query, self)
Example #2
0
    def save(self, *args, **kwargs):
        created = self.pk is None

        # save the object
        super(Institute, self).save(*args, **kwargs)

        if created:
            log.add(self, 'Created')
        for field in self._tracker.changed():
            log.change(self,
                       'Changed %s to %s' % (field, getattr(self, field)))

        # update the datastore
        from karaage.datastores import machine_category_save_institute
        machine_category_save_institute(self)

        # has group changed?
        if self._tracker.has_changed("group_id"):
            old_group_pk = self._tracker.previous("group_id")
            new_group = self.group
            if old_group_pk is not None:
                old_group = Group.objects.get(pk=old_group_pk)
                from karaage.datastores import remove_accounts_from_institute
                query = Account.objects.filter(person__groups=old_group)
                remove_accounts_from_institute(query, self)
            if new_group is not None:
                from karaage.datastores import add_accounts_to_institute
                query = Account.objects.filter(person__groups=new_group)
                add_accounts_to_institute(query, self)
Example #3
0
    def save(self, *args, **kwargs):
        created = self.pk is None

        super(InstituteQuota, self).save(*args, **kwargs)

        if created:
            log.add(self.institute,
                    'Quota %s: Created' % self.machine_category)
        for field in self._tracker.changed():
            log.change(
                self.institute, 'Quota %s: Changed %s to %s' %
                (self.machine_category, field, getattr(self, field)))

        from karaage.datastores import machine_category_save_institute
        machine_category_save_institute(self.institute)

        if created:
            from karaage.datastores import add_accounts_to_institute
            query = Account.objects.filter(person__groups=self.institute.group)
            add_accounts_to_institute(query, self.institute)
Example #4
0
    def save(self, *args, **kwargs):
        created = self.pk is None

        super(InstituteQuota, self).save(*args, **kwargs)

        if created:
            log.add(
                self.institute,
                'Quota %s: Created' % self.machine_category)
        for field in self._tracker.changed():
            log.change(
                self.institute,
                'Quota %s: Changed %s to %s' %
                (self.machine_category, field, getattr(self, field)))

        from karaage.datastores import machine_category_save_institute
        machine_category_save_institute(self.institute)

        if created:
            from karaage.datastores import add_accounts_to_institute
            query = Account.objects.filter(person__groups=self.institute.group)
            add_accounts_to_institute(query, self.institute)