Skip to content

Commit

Permalink
asset name check
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBluth committed Mar 11, 2016
1 parent 37e2708 commit 80d1fb6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scenarioEditor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,13 @@ def component_set_service(request, component_set_id=None):
in_data = json.loads(request.body)
comp_set_form = ComponentSetForm(data=in_data)
if comp_set_form.is_valid():

if component_set_id is None:
same_name_obj_count = ComponentSet.objects.filter(name=comp_set_form.cleaned_data["name"], setType=comp_set_form.cleaned_data["setType"]).count()

if(same_name_obj_count != 0):
return HttpResponse("Component set with name " + comp_set_form.cleaned_data["name"] + " already exists", status=400)

comp_set = ComponentSet()
else:
try:
Expand Down Expand Up @@ -513,6 +519,11 @@ def item_service(request, item_id=None):
item_form = ItemForm(data=in_data)
if item_form.is_valid():
if item_id is None:
same_name_obj_count = ItemDefinition.objects.filter(name=item_form.cleaned_data["name"]).count()

if(same_name_obj_count != 0):
return HttpResponse("Item with name " + item_form.cleaned_data["name"] + " already exists", status=400)

item = ItemDefinition()
else:
try:
Expand Down

0 comments on commit 80d1fb6

Please sign in to comment.