def timelikeFormLabbookSave(request): if (TimelikeFormLabbook(request.POST, request.FILES).is_valid()): tempTimelike = Timelike() if (request.POST.get('timelikeFormLinkSource',False)): tempTimelike.linkSource = request.POST['timelikeFormLinkSource'] if (request.FILES.get('timelikeFormLocalSource', False)): tempTimelike.localSource = request.FILES['timelikeFormLocalSource'] tempTimelike.save() tempStructureNode = StructureNode() tempStructureNode.title = request.POST['timelikeFormTitle'] tempStructureNode.author = request.user tempStructureNode.content_type = ContentType.objects.get_for_model(Timelike) tempStructureNode.object_id = tempTimelike.id tempStructureNode.isPublished = False tempStructureNode.position = getPositionForRoots() tempStructureNode.isComment = False tempStructureNode.isLabnote = True tempStructureNode.save() tagList = hashTagParser(request.POST['timelikeFormTag']) restrictedTagListSave(request, tempStructureNode, tagList) print("something is valid") return True else: print("nothing is ever valid") return False
def dataFormLabbookSave(request): if (DataFormLabbook(request.POST).is_valid()): tempDataset = Dataset() tempDataset.data = datasetFormatter(request.POST) tempDataset.save() tempStructureNode = StructureNode() tempStructureNode.title = request.POST['dataFormTitle'] tempStructureNode.author = request.user tempStructureNode.content_type = ContentType.objects.get_for_model(Dataset) tempStructureNode.object_id = tempDataset.id tempStructureNode.isPublished = False tempStructureNode.position = getPositionForRoots() tempStructureNode.isComment = False tempStructureNode.isLabnote = True tempStructureNode.save() tagList = hashTagParser(request.POST['dataFormTag']) restrictedTagListSave(request, tempStructureNode, tagList) print("something is valid") return True else: print("nothing is ever valid data") return False
def textFormLabbookSave(request): if (ParagraphFormLabbook(request.POST).is_valid()): tempParagraph = Paragraph() tempParagraph.text = request.POST['textFormText'] tempParagraph.save() tempStructureNode = StructureNode() tempStructureNode.title = request.POST['textFormTitle'] tempStructureNode.author = request.user tempStructureNode.content_type = ContentType.objects.get_for_model(Paragraph) tempStructureNode.object_id = tempParagraph.id tempStructureNode.isPublished = False tempStructureNode.position = getPositionForRoots() tempStructureNode.isComment = False tempStructureNode.isLabnote = True tempStructureNode.save() tagList = hashTagParser(request.POST['textFormTag']) restrictedTagListSave(request, tempStructureNode, tagList) print("something is valid") return True else: print("nothing is ever valid") return False
def submitComment(request): if (request.method == 'POST'): print(request.POST) publishForm = PublishForm(request.POST) if (publishForm.is_valid()): tagList = hashTagParser(request.POST['publishFormTag']) commentNode = StructureNode() commentNode.title= request.POST['publishFormTitle'] commentNode.parent_id = int(request.POST['sectionParent']) commentNode.author = request.user commentNode.isComment = True commentNode.position = getPositionForComments(request) commentNode.save() restrictedTagListSave(request, commentNode, tagList) for contentNodeIndex in range(0, int(request.POST['numberOfContentSections_'+str(0)])): contentNode = StructureNode() contentNode.title = request.POST['publishFormTitle'] +"_content_"+str(contentNodeIndex) contentNode.parent = commentNode contentNode.author = request.user contentNode.isComment = True contentNode.position = contentNodeIndex +1 if (request.POST['contentType_section_content_'+str(0)+"_"+str(contentNodeIndex)] == "textContent"): tempParagraph = Paragraph() tempParagraph.text = request.POST['text_section_content_'+str(0)+"_"+str(contentNodeIndex)] tempParagraph.save() contentNode.content_type = ContentType.objects.get_for_model(Paragraph) contentNode.object_id = tempParagraph.id contentNode.save() elif (request.POST['contentType_section_content_'+str(0)+"_"+str(contentNodeIndex)] == "imageContent"): contentNode.content_type = ContentType.objects.get_for_model(Image) if (request.POST.get('imageInputLinkSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): tempImage = Image() tempImage.linkSource = request.POST['imageInputLinkSource_section_content_'+str(0)+"_"+str(contentNodeIndex)] tempImage.save() contentNode.object_id = tempImage.id print("first") elif (request.FILES.get('imageInputLocalSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): tempImage = Image() tempImage.localSource = request.FILES['imageInputLocalSource_section_content_'+str(0)+"_"+str(contentNodeIndex)] tempImage.save() contentNode.object_id = tempImage.id print("second") elif (request.POST.get('imageInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): contentNode.object_id = int(request.POST['imageInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex)]) print("third") contentNode.save() elif (request.POST['contentType_section_content_'+str(0)+"_"+str(contentNodeIndex)] == "timelikeContent"): contentNode.content_type = ContentType.objects.get_for_model(Timelike) if (request.POST.get('timelikeInputLinkSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): tempTimelike = Timelike() tempTimelike.linkSource = request.POST['timelikeInputLinkSource_section_content_'+str(0)+"_"+str(contentNodeIndex)] tempTimelike.save() contentNode.object_id = tempTimelike.id print("first") elif (request.FILES.get('timelikeInputLocalSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): tempTimelike = Timelike() tempTimelike.localSource = request.FILES['timelikeInputLocalSource_section_content_'+str(0)+"_"+str(contentNodeIndex)] tempTimelike.save() contentNode.object_id = tempTimelike.id print("second") elif (request.POST.get('timelikeInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): contentNode.object_id = int(request.POST['timelikeInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex)]) print("third") contentNode.save() elif (request.POST['contentType_section_content_'+str(0)+"_"+str(contentNodeIndex)] == "dataContent"): contentNode.content_type = ContentType.objects.get_for_model(Dataset) if (request.POST.get('dataInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex))): contentNode.object_id = int(request.POST['dataInputLabbookSource_section_content_'+str(0)+"_"+str(contentNodeIndex)]) contentNode.save() restrictedTagListSave(request, contentNode, tagList) return HttpResponseRedirect(request.POST['prevPage'])