def setUp(self): #initial information into temperory database self.user = User() self.user.username = "******" self.user.password = "******" self.user.email = "email" self.user.is_confirmed = True self.user.save() self.project = project() self.project.project_name = "project" self.project.creator = self.user self.project.save() self.chain1 = chain() self.chain1.name = "chain1" self.chain1.id = 1 self.chain1.sequence = "1_2_3" self.chain1.project = self.project self.chain1.save() self.chain2 = chain() self.chain2.id = 2 self.chain2.name = "chain2" self.chain2.sequence = "" self.chain2.project = self.project self.chain2.save() self.partObj1 = parts() self.partObj1.part_id = 1 self.partObj1.part_name = "part1" self.partObj1.part_type = "type1" self.partObj1.save() self.partObj2 = parts() self.partObj2.part_id = 2 self.partObj2.part_name = "part2" self.partObj2.part_type = "type2" self.partObj2.save() self.partObj3 = parts() self.partObj3.part_id = 3 self.partObj3.part_name = "part3" self.partObj3.part_type = "type3" self.partObj3.save()
def setUp(self): self.client = Client() #initial information into temperory database self.user = User() self.user.username = "******" self.user.password = "******" self.user.email = "email" self.user.is_confirmed = True self.user.save() self.project = project() self.project.project_name = "project" self.project.creator = self.user self.project.save() self.chain1 = chain() self.chain1.name = "chain1" self.chain1.id = 1 self.chain1.sequence = "1_2_3_4_5" self.chain1.project = self.project self.chain1.save() self.chain2 = chain() self.chain2.name = "chain2" self.chain2.id = 2 self.chain2.sequence = "" self.chain2.project = self.project self.chain2.save() self.chain3 = chain() self.chain3.name = "chain3" self.chain3.id = 3 self.chain3.sequence = "1" self.chain3.project = self.project self.chain3.save() self.chain4 = chain() self.chain4.name = "chain4" self.chain4.id = 4 self.chain4.sequence = "1__5" self.chain4.project = self.project self.chain4.save()
def setUp(self): #initial information into temperory database self.user = User() self.user.username = "******" self.user.password = "******" self.user.email = "email" self.user.is_confirmed = True self.user.save() self.project = project() self.project.project_name = "project" self.project.creator = self.user self.project.save() self.chain1 = chain() self.chain1.name = "chain1" self.chain1.project = self.project self.chain1.save() self.chain2 = chain() self.chain2.name = "chain2" self.chain2.project = self.project self.chain2.save()
def createNewDevice(request): result = { 'isSuccessful': False, } if not isLoggedIn(request): return HttpResponse(json.dumps(result), content_type="application/json") name = request.POST.get('name', '') projectId = request.POST.get('id', '') newChain = chain(name=name, project_id=int(projectId)) try: newChain.save() result['isSuccessful'] = True result['name'] = name result['id'] = projectId except: pass return HttpResponse(json.dumps(result), content_type="application/json")
def createNewDevice(request): result = { 'isSuccessful': False, } if not isLoggedIn(request): return HttpResponse(json.dumps(result), content_type="application/json") received_json_data = json.loads(request.body) name = received_json_data['name'] projectId = received_json_data['id'] newChain = chain(name=name, project_id=int(projectId)) try: newChain.save() result['isSuccessful'] = True result['name'] = name result['id'] = projectId except: pass return HttpResponse(json.dumps(result), content_type="application/json")