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


Python Item.description方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
    def post(self):

        form = AddItemForm()
        item = Item()

        if form.validate_on_submit():
            ar_title = Titles()
            fr_title = Titles()
            en_title = Titles()

            ar_title.title = form.ar_title.data.strip()
            ar_title.lang = 'ar'

            fr_title.title = form.fr_title.data.strip()
            fr_title.lang = 'fr'

            en_title.title = form.en_title.data.strip()
            en_title.lang = 'en'

            item.titles.append(ar_title)
            item.titles.append(fr_title)
            item.titles.append(en_title)

            item.description = form.description.data

            item.submitter = User.objects.get(id=current_user.id)

        else:
            flash('upload unsuccessful', 'error')
            return render_template('items/add_item.html', form=form)

        uploaded_files = request.files.getlist("files")
        thumbnail = request.files['thumbnail']

        thumbnail_name = secure_filename(thumbnail.filename)

        if thumbnail and allowed_thumbnails(thumbnail_name):
            ext = thumbnail.mimetype.split('/')[-1]
            # use the 'thumbnail' name for all thumbnails
            filename = '.'.join(["thumbnail", ext])
            item.thumbnail.put(thumbnail.stream,
                               content_type=thumbnail.mimetype,
                               filename=filename)

        for file in uploaded_files:
            # Make the filename safe, remove unsupported chars
            filename = secure_filename(file.filename)
            # Check if the file is one of the allowed types/extensions
            if file and allowed_file(filename):
                # put the file in the ListField.
                # see https://gist.github.com/tfausak/1299339
                file_ = GridFSProxy()
                file_.put(file.stream,
                          content_type=file.mimetype,
                          filename=filename)
                item.files.append(file_)
        # Save the thing
        item.save()
        flash('upload successful')
        return render_template('items/add_item.html', form=form)
开发者ID:g13013,项目名称:dzlibs,代码行数:62,代码来源:views.py

示例2: commit_item_changes

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
 def commit_item_changes(self,item=None):
     creation=not(item)
     if not item: item=Item(parent=self.current_user.key())
     item_name=self.request.get('name')
     item_price=self.request.get('price')
     item_description=rich_text.from_style_runs(self.request.get('description'))
     item_picture=self.request.get('picture_512')
     errors=[]
     if item_name=="": errors.append("The item name must not be blank.")
     if item_description=="": errors.append("The item description must not be blank.")
     try:
         item_price=float(item_price)
     except ValueError:
         errors.append("The price must be a number.")
     if item_price <=0: errors.append("The price must be greater than zero.")
     if len(errors):
         self.render_template('items/form.html',title="Add an Item",item_picture_data=item_picture,item_picture=("data:image/png;base64,%s"%item_picture if item_picture or creation else item.url(named=False,action="picture")),errors=errors,item_expiry=datetime.now()+Item.EXPIRATION_DELTA,item_name=item_name,item_description=item_description,item_price=item_price)
     else:
         item.name=item_name
         item.price=item_price
         item.description=item_description
         if item_picture: item.picture=base64.b64decode(item_picture)
         item.put()
         self.log("item %s"%("created" if creation else "edited"))
         self.flash("'%s' was %s!"%(item_name,"created" if creation else "edited"))
         self.redirect(self.current_user.url())
开发者ID:maz,项目名称:saviors-of-middle-earth,代码行数:28,代码来源:items_controller.py

示例3: add_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def add_item(request):
    if request.POST:
        item = Item()
        item.name = request.POST['item_name']
        item.description = request.POST['description']
        item.seller = request.user
        item.save()
      #  url = reverse('add_auction', kwargs={ 'item_id': item.id })

        return HttpResponseRedirect(reverse('auction:add_auction', args=(item.id,)))
    return render(request, 'add_item.html', {})
开发者ID:kielejocain,项目名称:AM_2015_06_15,代码行数:13,代码来源:views.py

示例4: add_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def add_item(listid):
    new_item = Item()
    dit = parse_amz(request.form['link'])
    print dit
    new_item.name = request.form['name']
    new_item.image_url = dit['image_url']
    new_item.amazon_link = request.form['link']
    new_item.note = request.form['notes']
    new_item.description = dit['description']
    s_list = mongo.db.lists.find_one({'_id': listid})
    item_count = s_list['item_count']
    new_item.id = item_count
    if item_count == 0:
        mongo.db.lists.update({'_id': listid}, {'$set': {'default_image': new_item.image_url}})
    item_count += 1
    mongo.db.lists.update({'_id': listid}, {'$push': {'items': new_item.__dict__}})
    mongo.db.lists.update({'_id': listid}, {'$set': {'item_count': item_count}})
    return redirect(url_for('get_list', listid=listid))
开发者ID:J-Katzen,项目名称:LV_Hack_List,代码行数:20,代码来源:visilist.py

示例5: newitem

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def newitem(req):
    if req.method == "POST":
        ni = ItemForm(req.POST)
        if ni.is_valid():
            # 获取表单信息
            name = ni.cleaned_data['name']
            description = ni.cleaned_data['description']
            # 写入数据库
            item = Item()
            uid = req.session['user_id']
            item.name = name
            item.description = description
            item.uid = uid
            item.save()
            return HttpResponseRedirect('/online/index/')
    else:
        ni = ItemForm()
        return render_to_response('home.html', {'ni': ni}, context_instance=RequestContext(req))
开发者ID:sweetlipa,项目名称:album,代码行数:20,代码来源:views.py

示例6: add_inventory_item_html

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def add_inventory_item_html(form):
    name = form.name.data.strip()
    description = form.description.data.strip()
    quantity = form.quantity.data
    price = form.price.data

    item = Item.query.filter_by(name=name).first()
    if item is None:
        item = Item(name=name, description=description, quantity=quantity,
                    price=price)
        db.session.add(item)
    else:
        item.name = name
        item.quantity = quantity
        item.price = price
        if description != "":
            item.description = description
    db.session.commit()
    return True
开发者ID:deveshj4,项目名称:tol,代码行数:21,代码来源:inventory_helper.py

示例7: add_inventory_item_json

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def add_inventory_item_json(data):
    name = data['name']
    description = data['description']
    quantity = int(data['quantity'])
    price = int(data['price'])

    item = Item.query.filter_by(name=name).first()
    if item is None:
        item = Item(name=name, description=description, quantity=quantity,
                    price=price)
        db.session.add(item)
    else:
        item.name = name
        item.quantity = quantity
        item.price = price
        if description != "":
            item.description = description
    db.session.commit()
    return jsonify(status="success")
开发者ID:deveshj4,项目名称:tol,代码行数:21,代码来源:inventory_helper.py

示例8: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
  def post(self):
    checklist = Checklist.get(self.request.get('checklist'))
    if not helpers.checkPermissionAndRespond(self, cl=checklist): return
    if not self.addable(checklist):
      helpers.createResponse(self, 'message_can_not_create_item.html')
      return
    
    item = Item(
        title=self.request.get('title'),
        difficulty=int(self.request.get('difficulty')),
        progress=0,
        checklist=checklist,
        deleted=False)

    if self.request.get('description') != '':
        item.description=self.request.get('description')
         
    item.put()
    self.redirect("/cl/" + str(checklist.key().id()))
开发者ID:yoooyle,项目名称:checklist,代码行数:21,代码来源:create.py

示例9: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
	def post(self):
		#Getting Inputs
		itemname=self.request.get("item_name")
		itemtype=self.request.get("item_type")
		itemdescription=self.request.get("item_description")
		itemprice=self.request.get("item_price")
		itemstock=self.request.get("item_stock")
		
		
		#Placing data in model
		item=Item()
		item.name=itemname
		item.type=itemtype
		item.description=itemdescription
		item.price=itemprice
		item.stock=itemstock
		item.owner=users.get_current_user().email()
		
		item.put()
		self.redirect('success')
开发者ID:Joshdsommers,项目名称:TeamZero,代码行数:22,代码来源:item_input.py

示例10: api_item

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def api_item(request, item_pk=None):
    created = False
    if item_pk:
        item = Item.objects.get(pk=item_pk)
        if not item.created_by == request.user:
            import pdb
            pdb.set_trace()
            return HttpResponse(status=403)
    else:
        item = Item()
        item.created_by = request.user
        created = True

    if request.POST.get('delete'):
        item.delete()
    else:
        expense = Expense.objects.get(pk=request.POST.get('expense'))
        if not expense.created_by == request.user:
            return HttpResponse(status=403)
        item.expense = expense

        item.description = request.POST.get('description')
        item.amount = request.POST.get('amount')
        item.save()

        user_pks = request.POST.getlist('users')
        item.users.clear()
        for pk in user_pks:
            user = User.objects.get(pk=pk)
            item.users.add(user)

    if request.is_ajax():
        return HttpResponse(json.dumps({
            'type': 'item',
            'item_pk': item.pk,
            'item_created': created,
            'item_form': render_to_response('item_form.html', {'expense':item.expense, 'item':item}, context_instance = RequestContext(request)).content,
            'empty_form': render_to_response('item_form.html', {'expense':item.expense}, context_instance = RequestContext(request)).content
        }))
    return HttpResponseRedirect("/%s" % item.expense_id)
开发者ID:kirberich,项目名称:Debthing,代码行数:42,代码来源:views.py

示例11: item_post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
def item_post(id=None):
    db.session.rollback() # See comment in create_transaction()
    if id:
        itm = Item.query.get_or_404(id)
    else:
        id = make_url_safe(request.form.get('name'))
        itm = Item(id=id)
        db.session.add(itm)
        
    itm.name = request.form.get('name')
    itm.description = request.form.get('description')
    itm.count = int(request.form.get('count')) if request.form.get('count') else 1

    itm.tax_base_int = request_or_none('tax_base_int')
    itm.tax_base_edu = request_or_none('tax_base_edu')
    itm.tax_base_ext = request_or_none('tax_base_ext')
    itm.tax_int = request_or_none('tax_int')
    itm.tax_edu = request_or_none('tax_edu')
    itm.tax_ext = request_or_none('tax_ext')


    itm.related = []
    for iid in request.form.get('related').split(', '):
        if iid == '':
            continue
        i = Item.query.get(iid)
        if i is None:
            flash(u'Artikel "%s" ist nicht bekannt!' % ii )
            continue
        itm.related.append(i)

    itm.tax_period = request.form.get('tax_period')

    itm.price_buy = request_or_none('price_buy')

    itm.category = request.form.get('category')

    db.session.commit()

    # Update image if necessary
    file = request.files['image']
    if file:
        import os
        from PIL import Image as i
        filename = secure_filename(id).lower() + '.jpg'

        image = i.open(file)
        if image.mode != "RGB":
            image = image.convert("RGB")

        image.save(os.path.join(app.config['UPLOAD_FOLDER'], 'full', filename), "jpeg")

        w  = image.size[0]
        h = image.size[1]

        aspect = w / float(h)
        ideal_aspect = 1.0

        if aspect > ideal_aspect:  # Then crop the left and right edges:
            w_ = int(ideal_aspect * h)
            offset = (w - w_)/2
            resize = (offset, 0, w - offset, h)
        else:  # ... crop the top and bottom:
            h_ = int(w/ideal_aspect)
            offset = (h - h_)/2
            resize = (0, offset, w, h - offset)

        image = image.crop(resize).resize((140, 140), i.ANTIALIAS)
        image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename), "jpeg")

    return redirect( url_for('item', id=id) )
开发者ID:Hobbyhobbit,项目名称:Stock,代码行数:73,代码来源:views.py

示例12: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
    def post(self):

        form = AddItemForm()
        item = Item()

        if form.validate_on_submit():
            ar_meta = Meta()
            fr_meta = Meta()
            en_meta = Meta()

            ar_meta.title = form.ar_title.data.strip()
            ar_meta.short_description = form.ar_short_description.data
            ar_meta.lang = 'ar'

            fr_meta.title = form.fr_title.data.strip()
            fr_meta.short_description = form.fr_short_description.data
            fr_meta.lang = 'fr'

            en_meta.title = form.en_title.data.strip()
            en_meta.short_description = form.en_short_description.data
            en_meta.lang = 'en'

            item.meta_info.append(ar_meta)
            item.meta_info.append(fr_meta)
            item.meta_info.append(en_meta)

            item.description = form.description.data

            item.submitter = User.objects.get(id=current_user.id)

        else:
            flash('upload unsuccesful', 'error')
            return render_template('items/add_item.html', form=form)

        uploaded_files = request.files.getlist("files")
        thumbnail = request.files['thumbnail']
        thumbnail_name = secure_filename(thumbnail.filename)

        path = os.path.join(app.config['UPLOAD_FOLDER'], str(item.item_id))
        make_dir(path)

        if thumbnail and allowed_file(thumbnail.filename):
            thumbnail.save(os.path.join(path, thumbnail_name))

        filenames = []
        for file in uploaded_files:
            # Check if the file is one of the allowed types/extensions
            if file and allowed_file(file.filename):
                # Make the filename safe, remove unsupported chars
                filename = secure_filename(file.filename)
                # Move the file form the temporal folder to the upload
                # folder we setup
                file.save(os.path.join(path, filename))
                # Save the filename into a list, we'll use it later
                # filenames.append(filename)
                item.item_data.append(filename)
                # Redirect the user to the uploaded_file route, which
                # will basicaly show on the browser the uploaded file
        # Load an html page with a link to each uploaded file
        # item.item_data.append(filenames)
        item.save()
        flash('upload succesful')
        return render_template('items/add_item.html', form=form)
开发者ID:zendyani,项目名称:dzlibs,代码行数:65,代码来源:views.py

示例13: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import description [as 别名]
    def post(self):

        form = AddItemForm()
        item = Item()

        categories = Category.objects.all()
        licenses = License.objects.all()
        form.set_categories(categories, g.lang)
        form.set_licenses(licenses)

        if form.validate_on_submit():
            # first, the user has to share something !
            if not form.github.data and not form.files.data:
                flash('Neither a repo URL nor files has been shared, come on!',
                      category='alert')
                return render_template('items/add_item.html', form=form)

            # give that something at least one title
            if not form.ar_title.data and not form.fr_title.data and \
               not form.en_title.data:

                flash('You need to give this item at least one title, \
                       just pick one language and name it!',
                      category='alert')
                return render_template('items/add_item.html', form=form)

            # now we can proceed
            ar_title = Title()
            fr_title = Title()
            en_title = Title()

            ar_title.title = form.ar_title.data.strip()
            ar_title.lang = 'ar'

            fr_title.title = form.fr_title.data.strip()
            fr_title.lang = 'fr'

            en_title.title = form.en_title.data.strip()
            en_title.lang = 'en'

            item.titles.append(ar_title)
            item.titles.append(fr_title)
            item.titles.append(en_title)

            item.description = form.description.data
            item.tags = form.tags.data.strip().split(',')
            item.category = Category.objects.get(category_id=
                                                 int(form.category.data))

            item.submitter = User.objects.get(id=current_user.id)

            thumbnail = request.files['thumbnail']
            thumbnail_name = secure_filename(thumbnail.filename)

            if thumbnail and allowed_thumbnails(thumbnail_name):
                ext = thumbnail.mimetype.split('/')[-1]
                # use the 'thumbnail' name for all thumbnails
                filename = '.'.join(["thumbnail", ext])
                item.thumbnail.put(thumbnail.stream,
                                   content_type=thumbnail.mimetype,
                                   filename=filename)

            if form.github.data:
                item.github = form.github.data
                item.save()
                # no need to process any uploaded files
                flash('Item submitted successfully', category='success')
                return redirect(url_for('items.detail', item_id=item.item_id))
            else:
                item.license = License.objects.get(license_id=
                                                   int(form.license.data))

        else:
            flash('upload unsuccessful', category='error')
            return render_template('items/add_item.html', form=form)

        uploaded_files = request.files.getlist("files")
        for file in uploaded_files:
            # Make the filename safe, remove unsupported chars
            filename = secure_filename(file.filename)
            # Check if the file is one of the allowed types/extensions
            if file and allowed_file(filename):
                # put the file in the ListField.
                # see https://gist.github.com/tfausak/1299339
                file_ = GridFSProxy()
                file_.put(file.stream,
                          content_type=file.mimetype,
                          filename=filename)
                item.files.append(file_)
        # Save the thing
        item.save()
        flash('Item uploaded successfully', category='success')
        return redirect(url_for('items.detail', item_id=item.item_id))
开发者ID:mohamed-io,项目名称:dzlibs,代码行数:95,代码来源:views.py


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