コード例 #1
0
    def post(self, request, key=None):
        if 'value' not in request.POST:
            return self._get_success_response(False, 'Value is empty!')

        storage = Storage(key=key, value=request.POST['value'])

        try:
            storage.save()
        except DatabaseError as error:
            return self._get_success_response(
                False, self._get_database_error_string(error, key))

        return self._get_success_response(True)
コード例 #2
0
ファイル: views.py プロジェクト: conwetlab/fast
    def create(self, request):
        try:
            user = get_user_authentication(request)

            gadgetData = self.__completeGadgetData(request)

            metadata = gadgetData['metadata']

            storage = Storage(name=metadata['name'],
                              owner=metadata['owner'],
                              version=metadata['version'],
                              screenflow=gadgetData['screenflow'])

            storage.save()

            self.__createResourceURI(request, metadata, storage)

            self.__createGadget(gadgetData, storage)

            self.__storeGadget(metadata)

            if not isLocalStorage():
                self.__setPlatformUrls(metadata)

            metadata['creationDate'] = storage.creationDate
            metadata['id'] = storage.pk
            storage.data = json_encode(metadata)
            storage.save()

            return HttpResponse(storage.data,
                                mimetype='application/json; charset=UTF-8')

        except Exception, e:
            transaction.rollback()
            storage.delete()
            return HttpResponseServerError(
                unicode(e), mimetype='text/plain; charset=UTF-8')
コード例 #3
0
ファイル: views.py プロジェクト: conwetlab/fast
    def create(self, request):
        try:
            user = get_user_authentication(request)


            gadgetData = self.__completeGadgetData(request)


            metadata = gadgetData['metadata']

            storage = Storage(name=metadata['name'],
                              owner=metadata['owner'],
                              version=metadata['version'],
                              screenflow = gadgetData['screenflow'])


            storage.save()


            self.__createResourceURI(request, metadata, storage)

            self.__createGadget(gadgetData, storage)

            self.__storeGadget(metadata)

            if not isLocalStorage():
                self.__setPlatformUrls(metadata)

            metadata['creationDate'] = storage.creationDate
            metadata['id'] = storage.pk
            storage.data = json_encode(metadata)
            storage.save()

            return HttpResponse(storage.data, mimetype='application/json; charset=UTF-8')

        except Exception, e:
            transaction.rollback()
            storage.delete()
            return HttpResponseServerError(unicode(e), mimetype='text/plain; charset=UTF-8')
コード例 #4
0
ファイル: data_loader.py プロジェクト: redmapleaf/pwarehouse
def load():
    #adding new category
    cat1 = Category(name='Opony')
    cat1.save()

    #adding new storage
    stor1 = Storage(name='Magazyn 1')
    stor2 = Storage(name='Magazyn 2')
    stor3 = Storage(name='Magazyn 3')
    stor1.save()
    stor2.save()
    stor3.save()

    #adding new currency
    cur1 = Currency(name='PLN')
    cur1.save()

    #adding new price
    # pr1 = Price(amount = Decimal(100.0000), currency = cur1)
    # pr1.save()
    # pr2 = Price(amount = Decimal(120.0000), currency = cur1)
    # pr2.save()

    #adding new tax rate
    tx = TaxRate(percentage=12)
    tx.save()

    #adding new item
    it1 = Item(name='Opony 165/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it1.save()
    it2 = Item(name='Opony 175/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it2.save()
    it3 = Item(name='Opony 185/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it3.save()
    it4 = Item(name='Opony 195/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it4.save()
    it5 = Item(name='Opony 205/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it5.save()
    it6 = Item(name='Opony 215/65R15',
               description='Opony...',
               category=cat1,
               tax_rate=tx)
    it6.save()

    #adding new items bucket
    ib1 = ItemsBucket(item=it1,
                      count=10,
                      buy_price=Decimal(100.0000),
                      sell_price=Decimal(120.0000),
                      storage=stor1)
    ib1.save()
    ib2 = ItemsBucket(item=it2,
                      count=10,
                      buy_price=Decimal(100.0000),
                      sell_price=Decimal(120.0000),
                      storage=stor1)
    ib2.save()
    ib3 = ItemsBucket(item=it3,
                      count=10,
                      buy_price=Decimal(100.0000),
                      sell_price=Decimal(120.0000),
                      storage=stor1)
    ib3.save()
    ib4 = ItemsBucket(item=it4,
                      count=10,
                      buy_price=Decimal(100.0000),
                      sell_price=Decimal(120.0000),
                      storage=stor1)
    ib4.save()

    #adding new country
    pl = Country(name='Polska')
    pl.save()

    #adding new clients
    cl1 = Client(name='ACMA',
                 address='ul. Krakowska 1/2',
                 zip_code='30100',
                 country=pl)
    cl1.save()
    cl2 = Client(name='ACMA 2',
                 address='ul. Wadowicka 1/2',
                 zip_code='30100',
                 country=pl)
    cl2.save()
    cl3 = Client(name='ACMA 3',
                 address='ul. Zakopianska 8',
                 zip_code='30100',
                 country=pl)
    cl3.save()

    #adding doc types
    # dt1 = DocumentType(name = 'invoice')
    # dt1.save()
    dt2 = DocumentType(name='mmplus')
    dt2.save()
    dt3 = DocumentType(name='mmminus')
    dt3.save()
コード例 #5
0
from storage.models import Storage
from storage.serializers import StorageSerializer
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser

storage = Storage(title = 'HP StoreEver LTO-5 Ultrium SB3000c Tape Blade', description = "The \
HP Ultrium Tape Blades are ideal for HP BladeSystem c-Class customers who need an integrated data \
protection solution. \nThese half-height tape blades provides direct attach data protection for the adjacent \
server and network backup protection for all data residing within the enclosure. \nHP Ultrium Tape Blades \
offer a complete data protection, \ndisaster recovery and archiving solution for BladeSystem c-Class customers.")
storage.save()

storage = Storage(title = 'Business Class Libraries', description = 'Up to 16 tape drives and 240 slots with a choice of tape technologies.\n\
Investment protection with both capacity and performance upgrades for environments with unpredictable data growth')
storage.save()

serializer = StorageSerializer(storage)
serializer.data
コード例 #6
0
ファイル: data_loader.py プロジェクト: waso/pwarehouse
def load():
	#adding new category
	cat1 = Category(name = 'Opony')
	cat1.save()

	#adding new storage
	stor1 = Storage(name = 'Magazyn 1')
	stor2 = Storage(name = 'Magazyn 2')
	stor3 = Storage(name = 'Magazyn 3')
	stor1.save()
	stor2.save()
	stor3.save()

	#adding new currency
	cur1 = Currency(name = 'PLN')
	cur1.save()

	#adding new price
	# pr1 = Price(amount = Decimal(100.0000), currency = cur1)
	# pr1.save()
	# pr2 = Price(amount = Decimal(120.0000), currency = cur1)
	# pr2.save()

	#adding new tax rate
	tx = TaxRate(percentage = 12)
	tx.save()

	#adding new item
	it1 = Item(name = 'Opony 165/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it1.save()
	it2 = Item(name = 'Opony 175/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it2.save()
	it3 = Item(name = 'Opony 185/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it3.save()
	it4 = Item(name = 'Opony 195/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it4.save()
	it5 = Item(name = 'Opony 205/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it5.save()
	it6 = Item(name = 'Opony 215/65R15', description = 'Opony...', category = cat1, tax_rate = tx)
	it6.save()

	#adding new items bucket
	ib1 = ItemsBucket(item = it1, count = 10, buy_price = Decimal(100.0000), sell_price = Decimal(120.0000), storage = stor1)
	ib1.save()
	ib2 = ItemsBucket(item = it2, count = 10, buy_price = Decimal(100.0000), sell_price = Decimal(120.0000), storage = stor1)
	ib2.save()
	ib3 = ItemsBucket(item = it3, count = 10, buy_price = Decimal(100.0000), sell_price = Decimal(120.0000), storage = stor1)
	ib3.save()
	ib4 = ItemsBucket(item = it4, count = 10, buy_price = Decimal(100.0000), sell_price = Decimal(120.0000), storage = stor1)
	ib4.save()
	
	#adding new country
	pl = Country(name = 'Polska')
	pl.save()

	#adding new clients
	cl1 = Client(name = 'ACMA', address = 'ul. Krakowska 1/2', zip_code = '30100', country = pl)
	cl1.save()
	cl2 = Client(name = 'ACMA 2', address = 'ul. Wadowicka 1/2', zip_code = '30100', country = pl)
	cl2.save()
	cl3 = Client(name = 'ACMA 3', address = 'ul. Zakopianska 8', zip_code = '30100', country = pl)
	cl3.save()

	#adding doc types
	# dt1 = DocumentType(name = 'invoice')
	# dt1.save()
	dt2 = DocumentType(name = 'mmplus')
	dt2.save()
	dt3 = DocumentType(name = 'mmminus')
	dt3.save()