当前位置: 首页>>代码示例>>Python>>正文


Python Document.save方法代码示例

本文整理汇总了Python中models.Document.save方法的典型用法代码示例。如果您正苦于以下问题:Python Document.save方法的具体用法?Python Document.save怎么用?Python Document.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Document的用法示例。


在下文中一共展示了Document.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cargar_mod

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def cargar_mod(request):

    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(docfile=request.FILES['docfile'])
            newdoc.save()

            #print(newdoc.docfile.name)
            manejo_mods.insmod('/home/pi/SO2TP3PerezFederico/PaginaTP3/media/'+newdoc.docfile.name)

            archivo = open('salida.txt','r')

            lista = []

            for linea in archivo:
                lista.append(linea)


            return render_to_response(
            'list.html',
            {'documents': lista},
            context_instance=RequestContext(request))

            # Redirect to the document list after POST
           # return HttpResponseRedirect(reverse('cargar_mod'))
    else:
        form = DocumentForm()  # A empty, unbound form

    # Render list page with the documents and the form
    return render_to_response(
        'list.html',
        {'form': form},
        context_instance=RequestContext(request)
    )
开发者ID:PerezFederico,项目名称:SO2TP3PerezFederico,代码行数:37,代码来源:views.py

示例2: __process_Document

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def __process_Document(entry, obj, g):
    full_name = __child_value_by_tags(entry, 'FILE')
    name = path.basename(full_name).decode('utf-8').strip()
    known = Document.objects.filter(docfile=name).exists()

    if not known and not gedcom_storage.exists(name):
        return None

    kind = __child_value_by_tags(entry, 'TYPE')
    if known:
        m = Document.objects.filter(docfile=name).first()
    else:
        m = Document(gedcom=g, kind=kind)
        m.docfile.name = name

    if kind == 'PHOTO':
        try:
            make_thumbnail(name, 'w128h128')
            make_thumbnail(name, 'w640h480')
        except Exception as e:
            print e
            print '  Warning: failed to make or find thumbnail: %s' % name
            return None  # Bail on document creation if thumb fails

    m.save()

    if isinstance(obj, Person) and \
            not m.tagged_people.filter(pointer=obj.pointer).exists():
        m.tagged_people.add(obj)
    elif isinstance(obj, Family) and \
            not m.tagged_families.filter(pointer=obj.pointer).exists():
        m.tagged_families.add(obj)

    return m
开发者ID:gthole,项目名称:gedgo,代码行数:36,代码来源:gedcom_update.py

示例3: investing

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def investing(request):
  # Handle file upload
  file_form = FileForm(request.POST)
  form = DocumentForm(request.POST, request.FILES)
  
  
  if request.method == 'POST' and "uploadFile" in request.POST:
    # Upload
    if form.is_valid():
      newdoc = Document(docfile = request.FILES['docfile'])
      newdoc.save()
  
      # Redirect to the document list after POST
      return HttpResponseRedirect(reverse('dataloader.views.investing'))
  elif request.method == 'POST' and "invest" in request.POST:  
    # Make Investments
    if file_form.is_valid():
      file_name = file_form.cleaned_data['file_input']
      print "### FILE FOR INVESTMENTS: " + file_name
      file_path = settings.MEDIA_ROOT + "/" + file_name
      print file_path
      
      cr = csv.reader(open(file_path))    
      # Starting from second row
      
      for row in cr:
        if row[0] == 'fund' or row[0] == 'individual':
          investment_manager.fund(row)
        elif row[0] == 'buy':
          investment_manager.buy(row)
        elif row[0] == 'sell':
          investment_manager.sell(row)
        elif row[0] == 'sellbuy':
          investment_manager.sellbuy(row)
                        
      
      
      return HttpResponseRedirect(reverse('dataloader.views.investing'))

  elif request.method == 'POST' and "clear" in request.POST:   
    # Clear Investments
    print "### This should clear everything"
    Activity.objects.all().delete()
    StakeHold.objects.all().delete()
    Port_Indi.objects.all().delete()
    print "### OK check porfolio page"
    
    
  else:
      form = DocumentForm() # A empty, unbound form
      file_form = FileForm()

  # Load documents for the list page
  documents = Document.objects.all()

  return render_to_response(
       'nav/investing.html',
       {'documents': documents, 'form': form, 'file_form':file_form},
       context_instance=RequestContext(request)
   )
开发者ID:zinglax,项目名称:cmsc424Site,代码行数:62,代码来源:views.py

示例4: post

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
 def post(self, request, format=None):
     my_file = request.FILES['file']
     file_name = str(uuid.uuid1())+'.dcm'
     print(file_name)
     with open(file_name, 'wb+') as temp_file:
         temp_file.write(my_file.read())
     print(file_name)
     ds = dicom.read_file(file_name)
     document = Document()
     document.date_time = datetime.datetime.now()
     document.doc_file = request.FILES['file']
     document.save()
     print(document.doc_id)
     for ke in ds.dir():
         if ke == 'PixelData':
             continue
         prop = DICOMProperty()
         prop.prop_key = ke;
         prop.prop_value = str(getattr(ds, ke, ''))
         prop.doc_id = document
         print(prop)
         prop.save()
     print(Document.objects.all())
     documents = Document.objects.all()
     serializer = DocumentListSerializer(documents)
     print(serializer.data)
     #return Response(status=status.HTTP_200_OK, data=serializer.data)
     return HttpResponseRedirect("/static/header.html")
开发者ID:anilreddykatta,项目名称:dicomlatest,代码行数:30,代码来源:views.py

示例5: executeUpload

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def executeUpload(request):
    # Save the files
    form = DocumentForm(request.POST, request.FILES)
    
    file_new = request.FILES['docfile']
    
    if form.is_valid():
        #Save temporary file
        newdoc = Document(docfile = file_new)
        newdoc.save()
    
        fn = file_new.name
        fn = fn.replace (" ", "_")
    
        #Move the file to the new folder
        src = os.path.join(django_settings.FILE_UPLOAD_TEMP_DIR, 'uploads', fn)
        file_upload = src
        path = os.path.join(request.session['projectPath'],'Uploads')
        target = os.path.join(path, fn)
        if os.path.exists(target):
            os.remove(target)
        shutil.move(src, path)
        
        #Delete the temporary file
        newdoc.delete()
开发者ID:I2PC,项目名称:scipion,代码行数:27,代码来源:views_management.py

示例6: list

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def list(request):
    # Handle file upload
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(pk=1)
            f = request.FILES['docfile']
            newdoc.docfile = f
            newdoc.name = f.name
            newdoc.save()

            # Redirect to the document list after POST
            #return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
    else:
        form = DocumentForm()  # A empty, unbound form

    # Load documents for the list page
    try:
        document = Document.objects.get(pk=1)
    except Document.DoesNotExist:
        document = None

    #update game
    if gameHeart:
        gameHeart.restart()
    # Render list page with the documents and the form
    return render_to_response(
        'list.html',
        {'document': document, 'form': form},
        context_instance=RequestContext(request)
    )
开发者ID:hzyyy,项目名称:py-geon,代码行数:33,代码来源:views.py

示例7: test_model_document

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
 def test_model_document(self):
     """Test Document Model"""
     folder = Folder(name='test')
     folder.save()
     obj = Document(title='test', folder=folder)
     obj.save()
     self.assertEquals(folder, obj.folder)
     self.assertNotEquals(obj.id, None)
     obj.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:11,代码来源:tests.py

示例8: upload_document_with_type

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def upload_document_with_type(request, document_type_id, multiple=True):
    check_permissions(request.user, "documents", [PERMISSION_DOCUMENT_CREATE])

    document_type = get_object_or_404(DocumentType, pk=document_type_id)
    local_form = DocumentForm(prefix="local", initial={"document_type": document_type})
    if USE_STAGING_DIRECTORY:
        staging_form = StagingDocumentForm(prefix="staging", initial={"document_type": document_type})

    if request.method == "POST":
        if "local-submit" in request.POST.keys():
            local_form = DocumentForm(
                request.POST, request.FILES, prefix="local", initial={"document_type": document_type}
            )
            if local_form.is_valid():
                try:
                    if (not UNCOMPRESS_COMPRESSED_LOCAL_FILES) or (
                        UNCOMPRESS_COMPRESSED_LOCAL_FILES
                        and not _handle_zip_file(request, request.FILES["local-file"], document_type)
                    ):
                        instance = local_form.save()
                        _handle_save_document(request, instance, local_form)
                        messages.success(request, _(u"Document uploaded successfully."))
                except Exception, e:
                    messages.error(request, e)

                if multiple:
                    return HttpResponseRedirect(request.get_full_path())
                else:
                    return HttpResponseRedirect(reverse("document_list"))
        elif "staging-submit" in request.POST.keys() and USE_STAGING_DIRECTORY:
            staging_form = StagingDocumentForm(
                request.POST, request.FILES, prefix="staging", initial={"document_type": document_type}
            )
            if staging_form.is_valid():
                try:
                    staging_file = StagingFile.get(staging_form.cleaned_data["staging_file_id"])
                    if (not UNCOMPRESS_COMPRESSED_STAGING_FILES) or (
                        UNCOMPRESS_COMPRESSED_STAGING_FILES
                        and not _handle_zip_file(request, staging_file.upload(), document_type)
                    ):
                        document = Document(file=staging_file.upload(), document_type=document_type)
                        document.save()
                        _handle_save_document(request, document, staging_form)
                        messages.success(
                            request, _(u"Staging file: %s, uploaded successfully.") % staging_file.filename
                        )

                    if DELETE_STAGING_FILE_AFTER_UPLOAD:
                        staging_file.delete()
                        messages.success(request, _(u"Staging file: %s, deleted successfully.") % staging_file.filename)
                except Exception, e:
                    messages.error(request, e)

                if multiple:
                    return HttpResponseRedirect(request.META["HTTP_REFERER"])
                else:
                    return HttpResponseRedirect(reverse("document_list"))
开发者ID:strogo,项目名称:mayan,代码行数:59,代码来源:views.py

示例9: create_document

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def create_document(request):
    now = datetime.datetime.now()

    document = Document()
    document['title'] = 'New document for %s'%now.strftime('%d/%m/%Y at %H:%M')
    document['content'] = 'This is a new document created to test our persistence framework'
    document.save()

    return HttpResponseRedirect('/my-documents/')
开发者ID:avelino,项目名称:votacao_paredao_bbb,代码行数:11,代码来源:views.py

示例10: fileuploader

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def fileuploader(request):
	if request.method == 'POST':
		form = UploadFileForm(request.POST, request.FILES)
		if form.is_valid():
			newdoc = Document(docfile = request.FILES['docfile'])
			newdoc.save()
			return HttpResponseRedirect('/docViewer/confirmation/')
	else:
		form = UploadFileForm()
	return render_to_response('fileuploader.html', {'form':form})
开发者ID:anoncb1754,项目名称:DocDIA,代码行数:12,代码来源:views.py

示例11: new

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def new(request):
    if request.method == 'POST':
        title = request.POST.get('title')
        body = request.POST.get('body')

        document = Document(title=title, body=body)
        document.save()

        return redirect('reading:index')

    return render(request, 'reading_assist/new.html', {})
开发者ID:watheuer,项目名称:language_learning,代码行数:13,代码来源:views.py

示例12: upload_file

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def upload_file(request):
    if not request.user.is_authenticated():
        return HttpResponse('fail unlogin')
    try:
        upload_file = request.FILES['file']
        doc = Document(owner = request.user, public = False, doc_name = upload_file.name, doc_file = upload_file)
        doc.save()
    except:
        return HttpResponse('fail upload fail')
    else:
        return HttpResponseRedirect('/homepage/')
开发者ID:cxhiano,项目名称:docshare,代码行数:13,代码来源:views.py

示例13: suggestions

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def suggestions(request, sample_id=1):
    
    try:
        suggestions_doc = Document.objects.get(title="Feature Suggestions")
    except Document.DoesNotExist:
        suggestions_doc = Document()
        suggestions_doc.title = "Feature Suggestions"
        suggestions_doc.save()

    page_context = { }
    page_context["object"] = suggestions_doc
    return render(request, 'suggestions.html', page_context)
开发者ID:appcubator,项目名称:appcubator-site,代码行数:14,代码来源:views.py

示例14: upload_file

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def upload_file(request):
    documents = Document.objects.all()
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(name = request.POST['name'], label = request.POST['label'], docfile = request.FILES['docfile'])
            newdoc.save()
            return redirect('/docs')
    else:
        form = DocumentForm()

    documents = Document.objects.all()
    return render(request, 'network/docs.html', {'documents': documents, 'form': form})
开发者ID:justvidyadhar,项目名称:shannon,代码行数:15,代码来源:views.py

示例15: add_clue

# 需要导入模块: from models import Document [as 别名]
# 或者: from models.Document import save [as 别名]
def add_clue(request):
    if request.method == 'POST':
        newdoc = Document(docfile=request.FILES.get('file', False))
        if newdoc.docfile:
            newdoc.id = str(request.FILES.get('file').name)
            newdoc.save()
            request.session['file'] = newdoc

        return render_to_response(
            'clue.html',
            {'image': request.session.get('file')},
            context_instance=RequestContext(request)
        )
开发者ID:sumehta,项目名称:gps-estimation,代码行数:15,代码来源:views.py


注:本文中的models.Document.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。