Skip to content

Commit

Permalink
Merge 371b746 into d0da586
Browse files Browse the repository at this point in the history
  • Loading branch information
xor-xor committed Oct 30, 2014
2 parents d0da586 + 371b746 commit 06b65dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ralph/ui/forms/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def clean_asset(self):
raise forms.ValidationError(msg)
if 'ralph_assets' in settings.INSTALLED_APPS:
from ralph_assets.api_ralph import is_asset_assigned
if is_asset_assigned(asset_id=asset.id):
if asset and is_asset_assigned(asset_id=asset.id):
raise forms.ValidationError(
"This asset is already linked to some other device. "
"To resolve this conflict, please click the link above."
Expand Down
4 changes: 3 additions & 1 deletion src/ralph/ui/views/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ def form_valid(self, form):
'asset' in form.cleaned_data.keys(),
)):
from ralph_assets.api_ralph import assign_asset
assign_asset(dev.id, form.cleaned_data['asset'].id)
asset = form.cleaned_data['asset']
if asset:
assign_asset(dev.id, asset.id)
messages.success(self.request, "Device created.")
return HttpResponseRedirect(self.request.path + '../info/%d' % dev.id)

Expand Down

0 comments on commit 06b65dd

Please sign in to comment.