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

Python models.Item类代码示例

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

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



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

示例1: post

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


示例2: test_update

    def test_update(self):
        order = Order(name="Dummy Order")
        order.save()

        for i in range(2):
            item = Item(name="Item %i" % i, sku=str(i) * 13, price=D("9.99"), order=order, status=0)
            item.save()

        tag = Tag(name="Test", content_object=order)
        tag.save()

        res = self.client.get("/inlines/1/")

        self.assertEqual(res.status_code, 200)
        order = Order.objects.get(id=1)

        self.assertEquals(2, order.item_set.count())
        self.assertEquals("Item 0", order.item_set.all()[0].name)

        data = {
            "name": u"Dummy Order",
            "item_set-TOTAL_FORMS": u"4",
            "item_set-INITIAL_FORMS": u"2",
            "item_set-MAX_NUM_FORMS": u"",
            "item_set-0-name": "Bubble Bath",
            "item_set-0-sku": "1234567890123",
            "item_set-0-price": D("9.99"),
            "item_set-0-status": 0,
            "item_set-0-order": 1,
            "item_set-0-id": 1,
            "item_set-1-name": "Bubble Bath",
            "item_set-1-sku": "1234567890123",
            "item_set-1-price": D("9.99"),
            "item_set-1-status": 0,
            "item_set-1-order": 1,
            "item_set-1-id": 2,
            "item_set-2-name": "Bubble Bath",
            "item_set-2-sku": "1234567890123",
            "item_set-2-price": D("9.99"),
            "item_set-2-status": 0,
            "item_set-2-order": 1,
            "item_set-3-DELETE": True,
            "tests-tag-content_type-object_id-TOTAL_FORMS": 3,
            "tests-tag-content_type-object_id-INITIAL_FORMS": 1,
            "tests-tag-content_type-object_id-MAX_NUM_FORMS": u"",
            "tests-tag-content_type-object_id-0-name": u"Test",
            "tests-tag-content_type-object_id-0-id": 1,
            "tests-tag-content_type-object_id-0-DELETE": True,
            "tests-tag-content_type-object_id-1-name": u"Test 2",
            "tests-tag-content_type-object_id-2-name": u"Test 3",
        }

        res = self.client.post("/inlines/1/", data, follow=True)
        self.assertEqual(res.status_code, 200)

        order = Order.objects.get(id=1)

        self.assertEquals(3, order.item_set.count())
        self.assertEquals(2, Tag.objects.count())
        self.assertEquals("Bubble Bath", order.item_set.all()[0].name)
开发者ID:MechanisM,项目名称:django-extra-views,代码行数:60,代码来源:tests.py


示例3: test_format_item_to_json

 def test_format_item_to_json(self):
     item = Item(1, "test name", "Medium", "This is a test description")
     item.save()
     results = item.to_json()
     expected_results = dict(id=1, user_id=1, name="test name", priority="Medium",
                             description="This is a test description")
     self.assertEqual(expected_results, results)
开发者ID:Tsatsi,项目名称:list-it-REST-service,代码行数:7,代码来源:tests.py


示例4: item_create

def item_create(replace_key=None):
    if replace_key:
        item = replace_key.get()
    else:
        url_safe_name = make_url_safe(request.form.get('name'))
        item = Item(id = url_safe_name)
        
    item.populate(
        name = request.form.get('name'),
        description = request.form.get('description'),
        count = int(request.form.get('count')) if request.form.get('count') else 1,
        prices = [float(request.form.get('price_int')) if request.form.get('price_int') else 0,
                  float(request.form.get('price_ext')) if request.form.get('price_ext') else 0,
                  float(request.form.get('price_com')) if request.form.get('price_com') else 0,
                  float(request.form.get('price_buy')) if request.form.get('price_buy') else 0,
                  ],
        tax_per_day = True if request.form.get('tax_per_day') else False,
        category = request.form.get('category'),
        )
    id = item.put().id()

    file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
开发者ID:Hobbyhobbit,项目名称:Stock,代码行数:25,代码来源:rest.py


示例5: item_store

def item_store(category_name):
    """Store new item in DB"""
    if 'username' not in login_session:
        return redirect(url_for('login'))
    category = Category.query.filter(Category.name == category_name).first()
    if category.author_id != login_session['user_id']:
        return render_template('401.html', name='item')
    form = ItemForm()
    form.category_id.choices = [(c.id, c.name)
                                for c in Category.query.order_by('name')]
    form.category_id.data = category.id
    if form.validate_on_submit():
        try:
            new_item = Item(form.name.data,
                            form.description.data,
                            category.id,
                            login_session['user_id'])
            if 'image' in request.files and request.files['image']:
                filename = images.save(request.files['image'])
                new_item.image_name = filename
            db_session.add(new_item)
            db_session.commit()
            return redirect(url_for('item_view',
                                    category_name=category_name,
                                    item_name=form.name.data))
        except IntegrityError:
            db_session.rollback()
            flash("Item name must be unique value")
        except Exception, e:
            db_session.rollback()
            print e
            flash("Database error encountered")
开发者ID:vanadium23,项目名称:catalog-project,代码行数:32,代码来源:views.py


示例6: save_edited_category

def save_edited_category():
    cat_name = request.form.get("category")
    key = request.form.get("key")
    existing = Category.all().filter("owner =", users.get_current_user())
    for e in existing:
        if e.title.lower() == cat_name.lower():
            if not str(e.key()) == key:
                error = "You already have a category with that name. Please choose a different name"
                return Response(status=400)
    category = Category.get(key)
    items_from_form = request.form.get("items").split(",")
    old_items_from_db = Item.all().ancestor(category)
    for item in old_items_from_db:
        if not item.title in items_from_form:
            db.delete(item)
        else:
            items_from_form.remove(item.title)

    for new_item in items_from_form:
        if not new_item == "":
            i = Item(parent=category, title=new_item)
            i.put()
    category.title = request.form.get("category")
    category.put()
    return jsonify(new_items=items_from_form)
开发者ID:ssb402,项目名称:Vote-or-Skip-Web-App,代码行数:25,代码来源:views.py


示例7: on_message

    def on_message(self, message):
        data = json.loads(message)
        if "update_type" in data and data["update_type"] == "draw":
          board_id = data["board_id"]
          broadcastData = data
          self.broadcast(board_id, broadcastData, write_to_self=False)
          return
        message_type = data.get('message_type')
        board_id = data["board_id"]

        if message_type and message_type == 'user_update':
            self._update_user(board_id, data['username'])
            self._broadcast_user_display(board_id)
        elif message_type and message_type == 'board_name_update':
            name = self._update_board_name(board_id, data['name'])
            self._broadcast_board_name_update(board_id, name)
        else:
            board = Board.get(board_id)
            item = Item(**data["item"])
            board.updateItem(item)
            board.save()

            broadcastData = {
                "update_type": "pos_change",
                "item": json.loads(item.to_json())
            }
            self.broadcast(board_id, broadcastData, write_to_self=False)
开发者ID:econner,项目名称:pinhack,代码行数:27,代码来源:listen_handler.py


示例8: create_item

def create_item(request):
    """
    @param request:
    @param id:
    @return: JSON for account for added Inventory Item
    """
    item = Item(purchase_account=Account.objects.get(name='Purchase', company=request.company),
                sales_account=Account.objects.get(name='Sales', company=request.company),
                purchase_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company),
                sales_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company))
    scenario = 'Create'
    for query in request.GET:
        setattr(item, query, request.GET[query])
    if request.POST:
        form = ItemForm(data=request.POST, instance=item, company=request.company)
        if form.is_valid():
            item = form.save(commit=False)
            item.company = request.company
            item.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': InventoryAccountSerializer(item.account).data})
            return redirect('/inventory/items/')
    else:
        form = ItemForm(instance=item, company=request.company)
        form.hide_field(request)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'item_form.html', {
        'scenario': scenario,
        'form': form,
        'base_template': base_template,
    })
开发者ID:xtranophilist,项目名称:awecounting,代码行数:34,代码来源:views.py


示例9: item_form

def item_form(request, id=None):
    if id:
        item = get_object_or_404(Item, id=id, company=request.company)
        scenario = 'Update'
    else:
        item = Item(purchase_account=Account.objects.get(name='Purchase', company=request.company),
                    sales_account=Account.objects.get(name='Sales', company=request.company),
                    purchase_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company),
                    sales_tax_scheme=TaxScheme.objects.get(name='No Tax', company=request.company))
        scenario = 'Create'
    if request.POST:
        form = ItemForm(data=request.POST, instance=item, company=request.company)
        if form.is_valid():
            item = form.save(commit=False)
            item.company = request.company
            item.save()
            if request.is_ajax():
                return render(request, 'callback.html', {'obj': ItemSerializer(item).data})
            return redirect('/inventory/items/')
    else:
        form = ItemForm(instance=item, company=request.company)
    if request.is_ajax():
        base_template = 'modal.html'
    else:
        base_template = 'dashboard.html'
    return render(request, 'item_form.html', {
        'scenario': scenario,
        'form': form,
        'base_template': base_template,
    })
开发者ID:xtranophilist,项目名称:awecounting,代码行数:30,代码来源:views.py


示例10: post_item

def post_item(request):
    if request.method == 'POST':
        form = ItemForm(request.POST,  request.FILES)
        if form.is_valid():
            m_tags = form.cleaned_data['item_tags']
            m = Item(
                name=form.cleaned_data['item_name'],
                # type=form.cleaned_data['item_type'],
                # item_image=request.FILES['item_image'],
                image_first = form.cleaned_data['image_first'],
                image_second= form.cleaned_data['image_second'],
                image_third= form.cleaned_data['image_third'],
                looking_for = True if 'True' == form.cleaned_data['item_sellOrLookFor'] else False,
                category = form.cleaned_data['item_category'],
                #price=form.cleaned_data['item_price'],
                negotiable=form.cleaned_data['item_negotiable'],
                owner=request.user,
                description=form.cleaned_data['item_description']
            )
            m.save()
            print "item has been saved with item_id "+str(m.pk)
            print m_tags
            m.tags.add(*m_tags)
            # return my_items(request)
            return HttpResponseRedirect('/')

    else:
        form = ItemForm()
    return render_to_response('post_item.html', {'form': form, 'user': request.user}, context_instance=RequestContext(request))
开发者ID:hnassif,项目名称:scrollege,代码行数:29,代码来源:views.py


示例11: test_saving_and_retrieving_items

    def test_saving_and_retrieving_items(self):
        list_ = List()
        list_.save()

        first_item = Item()
        first_item.text = 'The first (ever) list item'
        first_item.list = list_
        first_item.save()

        second_item = Item()
        second_item.text = 'Item the second'
        second_item.list = list_
        second_item.save()

        saved_list = List.objects.first()
        self.assertEqual(saved_list, list_)

        saved_items = Item.objects.all()
        self.assertEqual(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]
        self.assertEqual(first_saved_item.text, 'The first (ever) list item')
        self.assertEqual(first_saved_item.list, list_)
        self.assertEqual(second_saved_item.text, 'Item the second')
        self.assertEqual(second_saved_item.list, list_)
开发者ID:rosomaxa,项目名称:tddgoat,代码行数:26,代码来源:tests.py


示例12: create_digest

    def create_digest(self, item_type, github_items):
        """
        builds a DigestData instance filled with the digest
        """
        issue_list = list(self.get_issues())

        digest = DigestData(item_type)
        digest.user = self._user
        digest.repo = self._repository_name

        for github_item in github_items:
            if github_item.state == ItemStates.OPEN:
                digest.total_opened += 1
            elif github_item.state == ItemStates.CLOSED:
                digest.total_closed += 1

            digest.total_items += 1

            item = Item()
            item.url = github_item.html_url
            item.label = '{}/{}#{}'.format(self._user, self._repository_name, github_item.number)
            item.title = github_item.title
            item.state = github_item.state
            github_user = github_item.user

            display_name = github_user.name or github_user.login
            if display_name not in digest.users:
                user = User()
                user.name = display_name
                user.gravatar = github_user.avatar_url
                digest.users[display_name] = user

            digest.items.setdefault(display_name, []).append(item)

        return digest
开发者ID:rainforestapp,项目名称:digestive,代码行数:35,代码来源:digestive.py


示例13: test_update

    def test_update(self):
        order = Order(name='Dummy Order')
        order.save()

        for i in range(2):
            item = Item(name='Item %i' % i, sku=str(i) * 13, price=D('9.99'), order=order, status=0)
            item.save()

        tag = Tag(name='Test', content_object=order)
        tag.save()

        res = self.client.get('/inlines/1/')

        self.assertEqual(res.status_code, 200)
        order = Order.objects.get(id=1)

        self.assertEquals(2, order.item_set.count())
        self.assertEquals('Item 0', order.item_set.all()[0].name)

        data = {
            'name': u'Dummy Order',
            'item_set-TOTAL_FORMS': u'4',
            'item_set-INITIAL_FORMS': u'2',
            'item_set-MAX_NUM_FORMS': u'',
            'item_set-0-name': 'Bubble Bath',
            'item_set-0-sku': '1234567890123',
            'item_set-0-price': D('9.99'),
            'item_set-0-status': 0,
            'item_set-0-order': 1,
            'item_set-0-id': 1,
            'item_set-1-name': 'Bubble Bath',
            'item_set-1-sku': '1234567890123',
            'item_set-1-price': D('9.99'),
            'item_set-1-status': 0,
            'item_set-1-order': 1,
            'item_set-1-id': 2,
            'item_set-2-name': 'Bubble Bath',
            'item_set-2-sku': '1234567890123',
            'item_set-2-price': D('9.99'),
            'item_set-2-status': 0,
            'item_set-2-order': 1,
            'item_set-3-DELETE': True,
            'tests-tag-content_type-object_id-TOTAL_FORMS': 3,
            'tests-tag-content_type-object_id-INITIAL_FORMS': 1,
            'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'',
            'tests-tag-content_type-object_id-0-name': u'Test',
            'tests-tag-content_type-object_id-0-id': 1,
            'tests-tag-content_type-object_id-0-DELETE': True,
            'tests-tag-content_type-object_id-1-name': u'Test 2',
            'tests-tag-content_type-object_id-2-name': u'Test 3',
        }

        res = self.client.post('/inlines/1/', data, follow=True)
        self.assertEqual(res.status_code, 200)

        order = Order.objects.get(id=1)

        self.assertEquals(3, order.item_set.count())
        self.assertEquals(2, Tag.objects.count())
        self.assertEquals('Bubble Bath', order.item_set.all()[0].name)
开发者ID:joshdrake,项目名称:django-extra-views,代码行数:60,代码来源:tests.py


示例14: import_inventory

def import_inventory(request):
    from models import PCGSNumberException
    shop = request.shop
    failures = []
    if request.method == 'POST':
        remove_inventory = bool(request.POST['r'] == "True")
        if remove_inventory:
            items = Item.objects.filter(shop=shop)
            for item in items:
                item.delete()
        
        for file in request.FILES.getlist('file'):
            try:
                from xls_parser import CoinInventoryParser
                parser = CoinInventoryParser()
                (keys, products) = parser.parse_xls(file)
                
                for product in products:
                    if product == []: continue
                    try:
                        Item.create_from_inventory(shop, keys, product)
                    except PCGSNumberException:
                        logging.critical("PCGSNumber not exists for product %s" % product)
                        failures.append(product[0])
                    
            except Exception, e:
                logging.error(e)
开发者ID:,项目名称:,代码行数:27,代码来源:


示例15: create

def create():
    form = CreateItemForm(request.form)
    if request.method == 'POST' and form.validate():
        sheetmusic_id = form.sheetmusic_id.data
        sheetmusic = Sheetmusic.query.filter_by(id=sheetmusic_id).one()
        new_item = Item()
        form.populate_obj(new_item)

        new_item.user_id = g.user.id

        g.db.add(new_item)
        g.db.commit()

        for file in request.files.getlist('images'):
            if file:
                ext = file.filename.rsplit('.', 1)[-1]
                filename = g.user.username + '_' + str(uuid4()) + '.' + ext
                image = ItemImage(filename)
                save_image(file, filename)
                new_item._images.append(image)
        g.db.commit()

        flash("You just made a new item!", "success")
        return redirect(url_for('items.index', item_id=new_item.id))

    sheetmusic_id = int(request.args.get('sheetmusic_id', 0))
    if sheetmusic_id:
        form.sheetmusic_id.data = sheetmusic_id
    return render_template('items/create_item.html', form=form)
开发者ID:sohail288,项目名称:sheetswap,代码行数:29,代码来源:controllers.py


示例16: fetch

 def fetch(self):
     self.build_service('drive', 'v3')
     timeMin = self.date_dt.isoformat()
     timeMax = self.next_date_dt.isoformat()
     query = "(viewedByMeTime > '%s' and viewedByMeTime < '%s') OR (createdTime > '%s' and createdTime < '%s' and '%s' in owners)" % (
         timeMin, timeMax, timeMin, timeMax, self.user.email)
     items = []
     results = self.service.files().list(
         orderBy='modifiedTime',
         pageSize=self.limit,
         spaces='drive,photos',
         fields='files(createdTime,description,id,kind,viewedByMeTime,modifiedTime,name,spaces,webViewLink,thumbnailLink),kind',
         q=query).execute()
     for f in results.get('files', []):
         spaces = f.get('spaces')
         is_image = 'photos' in spaces
         type = SERVICE.DOCUMENT if not is_image else SERVICE.PHOTO
         webViewLink = f.get('webViewLink')
         thumbnailLink = f.get('thumbnailLink')
         item = Item(svc=SERVICE.GDRIVE,
                     title=f.get('name'),
                     id=f.get('id'),
                     image=thumbnailLink,
                     details=f.get('description'),
                     type=type)
         if is_image:
             logging.debug(f)
         items.append(item.json())
     return items
开发者ID:onejgordon,项目名称:cloud-memory,代码行数:29,代码来源:services.py


示例17: post

 def post(self):
     user = users.get_current_user()
     
     if user == None:
         self.redirect("/")
         return 
     
     # get category information
     category = self.request.get('category') 
     item = self.request.get('newItem')
     if item != "":
         cs = Category.all()
         cs.filter('user =', user.email()) # get user category
         cs.filter('category =', category) # get category
         c = cs.get()
         if c != None:
             items = Item.all()
             items.filter('item =', item)
             items.ancestor(c.key())
             if items.get() == None:
                 newItem = Item(item = item, win = 0, lose = 0, rate = 0, parent = c.key()) # post a new item
                 newItem.put() # save 
             else:
                 errorMessage = "Item %s already exists!" % item
                 self.redirect("/manageCategory?category=%s&error=%s" % (category, errorMessage))
                 return 
     
     self.redirect("/manageCategory?category=%s" % category)
开发者ID:freedomd,项目名称:Head2Head,代码行数:28,代码来源:item.py


示例18: updateLocalDB

def updateLocalDB(request):
    cursor = connections['cineca'].cursor()         # Cursor connessione Cineca
    cursorLocal = connections['default'].cursor()   # Cursor DB locale

    # Seleziona tutti i dati necessari dal DB remoto
    cursor.execute(
        "SELECT \
                INV.ID_INVENTARIO_BENI,\
                INV.DS_BENE,\
                MOV.DT_REGISTRAZIONE_BUONO,\
                INV.VALORE_CONVENZIONALE,\
                SPA.DS_SPAZIO,\
                INV.DT_INI_AMMORTAMENTO,\
			    INV.VALORE_CONVENZIONALE - (LEAST((extract(year from sysdate) - EXTRACT(year FROM INV.DT_INI_AMMORTAMENTO)),AMM.NUM_ANNUALITA) * (INV.VALORE_CONVENZIONALE / AMM.NUM_ANNUALITA)) AS VALORE_RESIDUO\
            FROM\
                (((V_IE_CO_MOVIMENTI_BENE MOV RIGHT JOIN V_IE_CO_INVENTARIO_BENI INV\
                ON MOV.ID_INVENTARIO_BENI = INV.ID_INVENTARIO_BENI) LEFT JOIN\
	    		V_IE_AC_SPAZI SPA ON INV.CD_UBICAZIONE = SPA.CD_SPAZIO) INNER JOIN\
			    V_IE_CO_AS_TIP_AMM_CAT_GRP_INV AMM on INV.CD_CATEG_GRUPPO = AMM.CD_CATEG_GRUPPO )\
            WHERE\
                (AMM.ESERCIZIO - EXTRACT(year FROM INV.DT_INI_AMMORTAMENTO)) = 0\
            ORDER BY\
                MOV.ID_INVENTARIO_BENI DESC"
        )

    rows = rows_to_dict_list(cursor)

    # Scorre tutti i dati riga per riga
    for row in rows:
        # Per ogni riga vede se l'oggetto esiste gia' nel database
        try:
            #print "obj ",row['ID_INVENTARIO_BENI'],"val res: ",row['VALORE_RESIDUO']
            item = Item.objects.get(item_id=row['ID_INVENTARIO_BENI'])

            # Se l'oggetto esiste i dati vengono aggiornati
            item.item_id = row['ID_INVENTARIO_BENI']
            item.description = row['DS_BENE'] if row['DS_BENE'] else ''
            item.purchase_date = row['DT_REGISTRAZIONE_BUONO'] if row['DT_REGISTRAZIONE_BUONO'] is not None else '0001-01-01 00:00'
            item.price = row['VALORE_CONVENZIONALE'] if row['VALORE_CONVENZIONALE'] else -1
            item.location = row['DS_SPAZIO'] if row['DS_SPAZIO'] is not None else ''
            item.depreciation_starting_date = row['DT_INI_AMMORTAMENTO'] if row['DT_INI_AMMORTAMENTO'] else '0001-01-01 00:00'
            item.residual_value = row['VALORE_RESIDUO'] if row['VALORE_RESIDUO'] is not None else -1

            # item = Item(None,item_id,description,purchase_date,price,location,depreciation_starting_date)
            item.save()
        except Item.DoesNotExist:
            # Se non esiste viene creato un nuovo oggetto
            item_id = row['ID_INVENTARIO_BENI']
            description = row['DS_BENE'] if row['DS_BENE'] else ''
            purchase_date = row['DT_REGISTRAZIONE_BUONO'] if row['DT_REGISTRAZIONE_BUONO'] is not None else '0001-01-01 00:00'
            price = row['VALORE_CONVENZIONALE'] if row['VALORE_CONVENZIONALE'] else -1
            location = row['DS_SPAZIO'] if row['DS_SPAZIO'] is not None else ''
            depreciation_starting_date = row['DT_INI_AMMORTAMENTO'] if row['DT_INI_AMMORTAMENTO'] else '0001-01-01 00:00'
            residual_value = row['VALORE_RESIDUO'] if row['VALORE_RESIDUO'] is not None else -1

            item = Item(None,item_id,description,purchase_date,price,location,depreciation_starting_date,residual_value)
            item.save()

    return redirect ('showLocalDB')
开发者ID:a4ucoop,项目名称:SegreteriaInventario,代码行数:59,代码来源:views.py


示例19: post

 def post(self):
     name    = self.request.get('name')
     itemNum = self.request.get('itemNum')
     origin = self.request.get('origin')
     
     item_post = Item(name=name, itemNum=itemNum, origin=origin)
     item_post.put()
     self.redirect('/')    
开发者ID:ForrestSutton,项目名称:foodsafely,代码行数:8,代码来源:views.py


示例20: fetch

def fetch():
    if not request.user or not session.get('token'):
        return redirect(url_for('login'))
    auth = github.get_session(token=session['token'])
    for feed in request.user.feeds:
        resp = auth.get(feed.url).json()
        for resp_item in resp:
            Item.parse_and_add(resp_item, feed, request.user)
    return redirect(url_for('index'))
开发者ID:kvch,项目名称:ghai,代码行数:9,代码来源:webapp.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Job类代码示例发布时间:2022-05-27
下一篇:
Python models.Issue类代码示例发布时间: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