Ejemplo n.º 1
0
 def save_properties(self, device, properties):
     for symbol, value in properties.iteritems():
         p = device.venture_role.roleproperty_set.get(symbol=symbol)
         pv, created = RolePropertyValue.concurrent_get_or_create(
             property=p, device=device)
         pv.value = value
         pv.save()
Ejemplo n.º 2
0
 def save_properties(self, device, properties):
     for symbol, value in properties.iteritems():
         p = device.venture_role.roleproperty_set.get(symbol=symbol)
         pv, created = RolePropertyValue.concurrent_get_or_create(
             property=p,
             device=device,
         )
         pv.value = value
         pv.save(user=self.request.user)
Ejemplo n.º 3
0
 def save_properties(self, device, properties):
     for symbol, value in properties.iteritems():
         try:
             p = device.venture_role.roleproperty_set.get(symbol=symbol)
         except RoleProperty.DoesNotExist:
             p = device.venture.roleproperty_set.get(symbol=symbol)
         pv, created = RolePropertyValue.concurrent_get_or_create(
             property=p,
             device=device,
         )
         if value != p.default:
             pv.value = value
             pv.save(user=self.request.user)
         else:
             pv.delete()
Ejemplo n.º 4
0
 def set_property(self, symbol, value, user):
     from ralph.business.models import RoleProperty, RolePropertyValue
     try:
         p = self.venture_role.roleproperty_set.get(symbol=symbol)
     except RoleProperty.DoesNotExist:
         p = self.venture.roleproperty_set.get(symbol=symbol)
     if value != p.default and not {value, p.default} == {None, ''}:
         pv, created = RolePropertyValue.concurrent_get_or_create(
             property=p,
             device=self,
         )
         pv.value = value
         pv.save(user=user)
     else:
         try:
             pv = RolePropertyValue.objects.get(
                 property=p,
                 device=self,
             )
         except RolePropertyValue.DoesNotExist:
             pass
         else:
             pv.delete()