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


Python models.Document类代码示例

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


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

示例1: list

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,代码行数:31,代码来源:views.py

示例2: cargar_mod

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,代码行数:35,代码来源:views.py

示例3: investing

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,代码行数:60,代码来源:views.py

示例4: test_add_doc

 def test_add_doc(self):
     # Add a document to the repo
     doc = Document.objects.create(docid='mydoc', repo=self.repo)
     # Query repo
     qds = self.repo.docs.filter(docid='mydoc')
     # Remove document from repo
     Document.delete(qds.first())
开发者ID:HazyResearch,项目名称:elementary,代码行数:7,代码来源:tests.py

示例5: __process_Document

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,代码行数:34,代码来源:gedcom_update.py

示例6: document_add_typed

def document_add_typed(request, folder_id=None, response_format='html'):
    "Document add to preselected folder"

    folder = None
    if folder_id:
        folder = get_object_or_404(Folder, pk=folder_id)
        if not request.user.profile.has_permission(folder, mode='x'):
            folder = None

    document = Document()
    if request.POST:
        if 'cancel' not in request.POST:
            form = DocumentForm(
                request.user.profile, folder_id, request.POST, instance=document)
            if form.is_valid():
                document = form.save()
                document.set_user_from_request(request)
                return HttpResponseRedirect(reverse('documents_document_view', args=[document.id]))
        else:
            return HttpResponseRedirect(reverse('document_index'))
    else:
        form = DocumentForm(request.user.profile, folder_id)

    context = _get_default_context(request)
    context.update({'form': form,
                    'folder': folder})

    return render_to_response('documents/document_add_typed', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:30,代码来源:views.py

示例7: executeUpload

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,代码行数:25,代码来源:views_management.py

示例8: post

 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,代码行数:28,代码来源:views.py

示例9: test_model_document

 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,代码行数:9,代码来源:tests.py

示例10: create_document

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,代码行数:9,代码来源:views.py

示例11: upload_document_with_type

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,代码行数:57,代码来源:views.py

示例12: fileuploader

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,代码行数:10,代码来源:views.py

示例13: new

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,代码行数:11,代码来源:views.py

示例14: testdoc

def testdoc():
    #Check username against cache
    my_new_user = Document()
    my_new_user.barcode = '123'
    my_new_user.image = '/static/images/demo.png'
    my_new_user.doc_type = 1
    db_session.add(my_new_user)
    db_session.commit()
    # Check permissions
    flash('new document added')
    return render_template('index.html')
开发者ID:michaelgugino,项目名称:web_keyer,代码行数:11,代码来源:views.py

示例15: upload_file

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,代码行数:11,代码来源:views.py


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