Ejemplo n.º 1
0
 def set_manual_quota(self, ap_quotas):            
     logger.info('Setting quota %s (%s) on %s', self.quota_type, ap_quotas,
                  self)
     if self.quota_type != 'manual':
         logger.error('Quota type %s is invalid', self.quota_type)
         raise NameError(_(u'Tipul de cotă este invalid'))
     
     for k, v in ap_quotas.items():
         a = apartment_by_pk(k)
         Quota.set_quota(self.account, a.account, v)
Ejemplo n.º 2
0
 def set_quota(self):
     logger.info('Setting quota %s on %s', self.quota_type, self)
     found = False
     for qt in Billable.QUOTA_TYPES:
         if qt[0] == self.quota_type:
             found = True
     if self.quota_type in ['manual', 'noquota'] or not found:
         logger.error('Quota type %s is invalid', self.quota_type)
         raise NameError(_(u'Tipul de cotă este invalid'))
     
     apartments = self.billed.apartments()
     total = reduce(lambda t, a: t + a.weight(self.quota_type), apartments,
                    0)
     for a in apartments:
         Quota.set_quota(self.account, a.account,
                     Decimal(a.weight(self.quota_type)) / Decimal(total))
Ejemplo n.º 3
0
 def drop_quota(self):
     logger.info('Pruning all quotas on %s', self)
     Quota.del_quota(self.account)
Ejemplo n.º 4
0
 def delete(self):
     if not self.can_delete():
         raise ValueError(_(u'Acest serviciu nu se poate șterge'))
     Quota.del_quota(self.account)
     self.account.delete()
     super(Billable, self).delete()