• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: suggestions

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


示例17: add_clue

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


示例18: upload_file

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


示例19: tag_page

def tag_page(request, tag, page):
    """
    Lists documents with a certain tag.
    """
    # Check if the page is cached
    cache_key = 'tag_page:%s-%s' % (tag, page)
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    # Get the data
    tag = Tag.get_by_key_name(tag)
    if not tag:
        raise Http404
    object_list = Document.all().filter('tags =', tag.key()).filter("is_published =", True)
    paginator = Paginator(object_list, 10)
    # Limit it to thise page
    try:
        page = paginator.page(page)
    except (EmptyPage, InvalidPage):
        raise Http404
    # Create a response and pass it back
    context = {
        'headline': 'Documents tagged ‘%s’' % tag.title,
        'object_list': page.object_list,
        'page_number': page.number,
        'has_next': page.has_next(),
        'next_page_number': page.next_page_number(),
        'next_page_url': '/tag/%s/page/%s/' % (tag.title, page.next_page_number())
    }
    return direct_to_template(request, 'document_list.html', context)
开发者ID:datadesk,项目名称:latimes-document-stacker,代码行数:30,代码来源:views.py


示例20: document_list

def document_list(request, page=1):
    """
    Displays document lists, 10 at a time.
    """
    cache_key = 'document_page:%s' % page
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    else:
        # Pull the documents
        object_list = Document.all().filter(
                "is_published =", True
            ).order("-publication_date")
        # Cut it first 10
        paginator = Paginator(object_list, 10)
        try:
            page = paginator.page(page)
        except (EmptyPage, InvalidPage):
            raise Http404
        # Create the response
        context = {
            'headline': 'Latest Documents',
            'object_list': page.object_list,
            'page_number': page.number,
            'has_next': page.has_next(),
            'next_page_number': page.next_page_number(),
            'next_page_url': '/page/%s/' % (page.next_page_number())
        }
        response = direct_to_template(request, 'document_list.html', context)
        # Add it to the cache
        memcache.add(cache_key, response, 60)
        # Pass it back
        return response
开发者ID:datadesk,项目名称:latimes-document-stacker,代码行数:33,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Email类代码示例发布时间:2022-05-27
下一篇:
Python models.DBSession类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap