예제 #1
0
파일: views.py 프로젝트: Callek/tuxedo
def product_add(request):
    """
    Add a new product to the DB
    Will return the single product on success
    """
    xml = XMLRenderer()

    prodname = request.POST.get('product', None)
    if not prodname:
        return xml.error('Cannot add an empty product name', errno=103)

    # check languages
    langs = request.POST.getlist('languages')
    locales = product_details.languages.keys()
    if [ l for l in langs if l not in locales ]:
        return xml.error('invalid language code(s)', errno=103)

    # save new product
    products = Product.objects.filter(name__exact=prodname)
    if not products:
        try:
            prod = Product(name=prodname)
            prod.save()
            for lang in langs:
                prod.languages.create(lang=lang)
        except Exception, e:
            return xml.error(e)
        products = Product.objects.filter(pk=prod.pk)
예제 #2
0
파일: views.py 프로젝트: lauraxt/tuxedo
def product_add(request):
    """
    Add a new product to the DB
    Will return the single product on success
    """
    xml = XMLRenderer()

    prodname = request.POST.get("product", None)
    if not prodname:
        return xml.error("Cannot add an empty product name", errno=103)

    # check languages
    langs = request.POST.getlist("languages")
    locales = product_details.languages.keys()
    ssl_only = bool(request.POST.get("ssl_only", False) == "true")
    if [l for l in langs if l not in locales]:
        return xml.error("invalid language code(s)", errno=103)

    # save new product
    products = Product.objects.filter(name__exact=prodname)
    if not products:
        try:
            prod = Product(name=prodname, ssl_only=ssl_only)
            prod.save()
            for lang in langs:
                prod.languages.create(lang=lang)
        except Exception, e:
            return xml.error(e)
        products = Product.objects.filter(pk=prod.pk)
def product_add(request):
    """
    Add a new product to the DB
    Will return the single product on success
    """
    xml = XMLRenderer()

    prodname = request.POST.get('product', None)
    if not prodname:
        return xml.error('Cannot add an empty product name', errno=103)

    # check languages
    langs = request.POST.getlist('languages')
    locales = product_details('languages').keys()
    ssl_only = bool(request.POST.get('ssl_only', False) == "true")
    if [l for l in langs if l not in locales]:
        return xml.error('invalid language code(s)', errno=103)

    # save new product
    products = Product.objects.filter(name__exact=prodname)
    if not products:
        try:
            prod = Product(name=prodname, ssl_only=ssl_only)
            prod.save()
            for lang in langs:
                prod.languages.create(lang=lang)
        except Exception, e:
            return xml.error(e)
        products = Product.objects.filter(pk=prod.pk)
예제 #4
0
파일: testcases.py 프로젝트: rik/tuxedo
    def setUp(self):
        super(ProductTestCase, self).setUp()

        self.locales = ("ar", "da", "vi")

        # products
        self.products = []
        for i in range(1, 11):
            name = "Product-%s-%s" % (i, i % 2 and "odd" or "even")
            p = Product(name=name)
            p.save()

            for lang in self.locales:
                p.languages.create(lang=lang)

            self.products.append(p)
예제 #5
0
    def setUp(self):
        super(ProductTestCase, self).setUp()

        self.locales = ('ar', 'da', 'vi')

        # products
        self.products = []
        for i in range(1, 11):
            name = 'Product-%s-%s' % (i, i % 2 and 'odd' or 'even')
            p = Product(name=name)
            p.save()

            for lang in self.locales:
                p.languages.create(lang=lang)

            self.products.append(p)
예제 #6
0
파일: testcases.py 프로젝트: gozer/tuxedo
    def setUp(self):
        super(ProductTestCase, self).setUp()

        self.locales = ('ar', 'da', 'vi')

        # products
        self.products = []
        for i in range(1, 11):
            name = 'Product-%s-%s' % (i, i % 2 and 'odd' or 'even')
            p = Product(name=name)
            p.save()

            for lang in self.locales:
                p.languages.create(lang=lang)

            self.products.append(p)