Пример #1
0
 def transfer_credit(self, logged, user_ext, credit):
     from obelisk.resources import sse
     if not (credit > 0.0 and logged.credit >= credit):
         return
     user = self.get_user_for_credit(user_ext)
     if not user:
         return
     logged.credit -= Decimal(credit)
     user.credit += Decimal(credit)
     self.model.session.commit()
     self.update_user_context(user)
     self.update_user_context(logged)
     charges.add_charge(user.voip_id, credit,
                        'transferencia de ' + logged.voip_id)
     charges.add_charge(logged.voip_id, -credit,
                        'transferencia a ' + user.voip_id)
     sse.resource.notify(
         {
             'credit': float(user.credit),
             'user': user.voip_id
         }, "credit", user)
     sse.resource.notify(
         {
             'credit': float(logged.credit),
             'user': logged.voip_id
         }, "credit", logged)
Пример #2
0
	def add_credit(self, user_ext, credit, reason=""):
		from obelisk.resources import sse
		user = self.get_user_for_credit(user_ext)
		if not user:
			return
		user.credit += Decimal(credit)
		self.model.session.commit()
		self.update_user_context(user)
		charges.add_charge(user.voip_id, credit, reason)
		sse.resource.notify({'credit':float(user.credit), 'user':user.voip_id}, "credit", user)
		return user.voip_id
Пример #3
0
 def add_credit(self, user_ext, credit, reason=""):
     from obelisk.resources import sse
     user = self.get_user_for_credit(user_ext)
     if not user:
         return
     user.credit += Decimal(credit)
     self.model.session.commit()
     self.update_user_context(user)
     charges.add_charge(user.voip_id, credit, reason)
     sse.resource.notify(
         {
             'credit': float(user.credit),
             'user': user.voip_id
         }, "credit", user)
     return user.voip_id
Пример #4
0
	def transfer_credit(self, logged, user_ext, credit):
		from obelisk.resources import sse
		if not (credit > 0.0 and logged.credit >= credit):
			return
		user = self.get_user_for_credit(user_ext)
		if not user:
			return
		logged.credit -= Decimal(credit)
		user.credit += Decimal(credit)
		self.model.session.commit()
		self.update_user_context(user)
		self.update_user_context(logged)
		charges.add_charge(user.voip_id, credit, 'transferencia de ' + logged.voip_id)
		charges.add_charge(logged.voip_id, -credit, 'transferencia a ' + user.voip_id)
		sse.resource.notify({'credit': float(user.credit), 'user': user.voip_id}, "credit", user)
		sse.resource.notify({'credit': float(logged.credit), 'user': logged.voip_id}, "credit", logged)