Example #1
0
 def clean(self):
     cleaned_data = super(DeviceCreateForm, self).clean()
     asset = cleaned_data.get('asset')
     if asset:
         # get position from asset
         if all((
                 'chassis_position' in cleaned_data,
                 asset.device_info.position,
         )):
             cleaned_data['chassis_position'] = asset.device_info.position
         if all((
                 'position' in cleaned_data,
                 asset.device_info.orientation,
         )):
             cleaned_data['position'] = Orientation.name_from_id(
                 asset.device_info.orientation, )
     return cleaned_data
Example #2
0
 def clean(self):
     cleaned_data = super(DeviceCreateForm, self).clean()
     asset = cleaned_data.get('asset')
     if asset:
         # get position from asset
         if all((
             'chassis_position' in cleaned_data,
             asset.device_info.position,
         )):
             cleaned_data['chassis_position'] = asset.device_info.position
         if all((
             'position' in cleaned_data,
             asset.device_info.orientation,
         )):
             cleaned_data['position'] = Orientation.name_from_id(
                 asset.device_info.orientation,
             )
     return cleaned_data
Example #3
0
 def orientation(self):
     asset = self.get_asset()
     if not asset:
         return ''
     from ralph_assets.models import Orientation
     return Orientation.name_from_id(asset.device_info.orientation)