def set_homedir(self, *args, **kw): """Remove quota information when the user is moved to a disk without quotas or where the default quota is larger than his existing explicit quota.""" ret = self.__super.set_homedir(*args, **kw) if kw.get('current_id') and kw.get('disk_id'): disk = Factory.get("Disk")(self._db) disk.find(kw['disk_id']) def_quota = disk.get_default_quota() dq = DiskQuota(self._db) try: info = dq.get_quota(kw['current_id']) except Errors.NotFoundError: pass else: if def_quota is False: # No quota on new disk, so remove the quota information. dq.clear(kw['current_id']) elif def_quota is None: # No default quota, so keep the quota information. pass else: if (info['override_expiration'] and DateTime.now() < info['override_expiration']): old_quota = info['override_quota'] else: old_quota = info['quota'] if old_quota <= def_quota: dq.clear(kw['current_id']) return ret
def set_homedir(self, *args, **kw): """Remove quota information when the user is moved to a disk without quotas or where the default quota is larger than his existing explicit quota.""" ret = self.__super.set_homedir(*args, **kw) if kw.get("current_id") and kw.get("disk_id"): disk = Factory.get("Disk")(self._db) disk.find(kw["disk_id"]) def_quota = disk.get_default_quota() dq = DiskQuota(self._db) try: info = dq.get_quota(kw["current_id"]) except Errors.NotFoundError: pass else: if def_quota is False: # No quota on new disk, so remove the quota information. dq.clear(kw["current_id"]) elif def_quota is None: # No default quota, so keep the quota information. pass else: if info["override_expiration"] and DateTime.now() < info["override_expiration"]: old_quota = info["override_quota"] else: old_quota = info["quota"] if old_quota <= def_quota: dq.clear(kw["current_id"]) return ret
def clear_home(self, spread): """Remove disk quota before clearing home.""" try: homeinfo = self.get_home(spread) except Errors.NotFoundError: pass else: dq = DiskQuota(self._db) dq.clear(homeinfo['homedir_id']) return self.__super.clear_home(spread)
def clear_home(self, spread): """Remove disk quota before clearing home.""" try: homeinfo = self.get_home(spread) except Errors.NotFoundError: pass else: dq = DiskQuota(self._db) dq.clear(homeinfo["homedir_id"]) return self.__super.clear_home(spread)
def _clear_homedir(self, homedir_id): # Since disk_quota has a FK to homedir, we need this override dq = DiskQuota(self._db) dq.clear(homedir_id) return self.__super._clear_homedir(homedir_id)