from nereid import jsonify, render_template, flash, request, login_required, \ url_for, current_user, route, context_processor, abort, current_locale, \ current_website from nereid.contrib.locale import make_lazy_gettext from nereid.globals import session, current_app from flask.ext.login import user_logged_in from werkzeug import redirect from babel import numbers from trytond.model import ModelSQL, fields from trytond.pool import Pool, PoolMeta from .forms import AddtoCartForm _ = make_lazy_gettext('nereid_cart_b2c') __all__ = ['Cart'] __metaclass__ = PoolMeta class Cart(ModelSQL): """ Shopping Cart plays the link between a customer's shopping experience and the creation of a Sale Order in the backend. A Draft Sale Order is maintained through out the process of the existance of a cart which is finally converted into a confirmed sale order once the process is complete. """ __name__ = 'nereid.cart'
Test the Internationalisation :copyright: (c) 2012-2013 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details. """ import unittest import trytond.tests.test_tryton from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT from nereid.testing import NereidTestCase from nereid import render_template from trytond.transaction import Transaction from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _ = make_lazy_gettext('nereid') ngettext = make_lazy_ngettext('nereid') class TestI18N(NereidTestCase): """ Test the internationalisation """ def setUp(self): trytond.tests.test_tryton.install_module('nereid_test') self.nereid_website_obj = POOL.get('nereid.website') self.nereid_website_locale_obj = POOL.get('nereid.website.locale') self.nereid_permission_obj = POOL.get('nereid.permission') self.nereid_user_obj = POOL.get('nereid.user') self.url_map_obj = POOL.get('nereid.url_map')
url_for, current_user, route, context_processor, abort, current_website, \ current_locale, Nereid from nereid.contrib.locale import make_lazy_gettext from nereid.globals import session, current_app from flask.ext.login import user_logged_in from werkzeug import redirect from babel import numbers from nereid.ctx import has_request_context from trytond.model import ModelSQL, ModelView, fields from trytond.pool import Pool, PoolMeta from .forms import AddtoCartForm from .signals import cart_updated _ = make_lazy_gettext('nereid_cart_b2c') __all__ = ['Cart'] __metaclass__ = PoolMeta class Cart(ModelSQL, ModelView): """ Shopping Cart plays the link between a customer's shopping experience and the creation of a Sale Order in the backend. A Draft Sale Order is maintained through out the process of the existance of a cart which is finally converted into a confirmed sale order once the process is complete. """ __name__ = 'nereid.cart'
Test the Internationalisation :copyright: (c) 2012-2013 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details. """ import unittest import trytond.tests.test_tryton from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT from nereid.testing import NereidTestCase from nereid import render_template from trytond.transaction import Transaction from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _ = make_lazy_gettext("nereid") ngettext = make_lazy_ngettext("nereid") class TestI18N(NereidTestCase): """ Test the internationalisation """ def setUp(self): trytond.tests.test_tryton.install_module("nereid_test") self.nereid_website_obj = POOL.get("nereid.website") self.nereid_website_locale_obj = POOL.get("nereid.website.locale") self.nereid_permission_obj = POOL.get("nereid.permission") self.nereid_user_obj = POOL.get("nereid.user")
# -*- coding: utf-8 -*- """ nereid_wishlist.py """ from trytond.pool import PoolMeta, Pool from trytond.model import ModelView, ModelSQL, fields from nereid import login_required, current_user, request, \ redirect, url_for, render_template, route, abort, flash from nereid.contrib.locale import make_lazy_gettext from wtforms import ValidationError _ = make_lazy_gettext('nereid-wishlist') __all__ = [ 'NereidUser', 'Wishlist', 'Product', 'ProductWishlistRelationship', ] __metaclass__ = PoolMeta class Product: """ Extension of product variant """ __name__ = 'product.product' wishlists = fields.Many2Many( 'product.wishlist-product',
# -*- coding: utf-8 -*- from decimal import Decimal from trytond.pool import Pool, PoolMeta from jinja2.filters import do_striptags from werkzeug.exceptions import NotFound from nereid import jsonify, flash, request, url_for, route, redirect, \ render_template, abort from nereid.contrib.locale import make_lazy_gettext from forms import GiftCardForm _ = make_lazy_gettext('gift_card') __all__ = ['Product'] __metaclass__ = PoolMeta class Product: "Product extension for Nereid" __name__ = "product.product" def serialize(self, purpose=None): """ Downstream implementation which adds a key called inventory_status to the dictionary if purpose is 'variant_selection'. :param purpose: String which decides structure of dictionary """
# -*- coding: utf-8 -*- from decimal import Decimal from trytond.pool import Pool, PoolMeta from jinja2.filters import do_striptags from werkzeug.exceptions import NotFound from nereid import jsonify, flash, request, url_for, route, redirect, render_template, abort, current_locale from nereid.contrib.locale import make_lazy_gettext from forms import GiftCardForm _ = make_lazy_gettext("gift_card") __all__ = ["Product"] __metaclass__ = PoolMeta class Product: "Product extension for Nereid" __name__ = "product.product" def serialize(self, purpose=None): """ Downstream implementation which adds a key called inventory_status to the dictionary if purpose is 'variant_selection'. :param purpose: String which decides structure of dictionary """ res = super(Product, self).serialize(purpose=purpose)
:copyright: (c) 2010-2014 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details """ from functools import partial from babel import numbers from decimal import Decimal from trytond.pool import Pool, PoolMeta from trytond.model import fields from trytond.transaction import Transaction from nereid import current_user, url_for, request, redirect, flash, abort from nereid.contrib.locale import make_lazy_gettext from nereid.ctx import has_request_context _ = make_lazy_gettext("nereid_cart_b2c") __all__ = ["Sale", "SaleLine"] __metaclass__ = PoolMeta class Sale: """Add a boolean to indicate if the order originated from a shopping cart. """ __name__ = "sale.sale" is_cart = fields.Boolean("Is Cart Order?", readonly=True, select=True) website = fields.Many2One("nereid.website", "Website", readonly=True, select=True) nereid_user = fields.Many2One("nereid.user", "Nereid User", select=True)
# -*- coding: utf-8 -*- from flask_wtf import Form from wtforms import TextField, TextAreaField, SelectField, DecimalField, \ validators from wtforms.validators import ValidationError from nereid import abort from trytond.pool import Pool from nereid.contrib.locale import make_lazy_gettext _ = make_lazy_gettext('nereid_webshop') class GiftCardForm(Form): """ A form for purchasing gift cards """ recipient_name = TextField('Recipient Name', [validators.Optional()]) recipient_email = TextField('Recipient Email') message = TextAreaField('Message', [validators.Optional()]) selected_amount = SelectField('Select Amount', choices=[], coerce=int) open_amount = DecimalField('Amount', default=0) def __init__(self, product, *args, **kwargs): super(GiftCardForm, self).__init__(*args, **kwargs) Product = Pool().get('product.product') if not isinstance(product, Product): abort(400)
Test the Internationalisation :copyright: (c) 2012-2013 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details. """ import unittest import trytond.tests.test_tryton from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT from nereid.testing import NereidTestCase from nereid import render_template from trytond.transaction import Transaction from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _ = make_lazy_gettext('nereid') ngettext = make_lazy_ngettext('nereid') class TestI18N(NereidTestCase): """ Test the internationalisation """ def setUp(self): trytond.tests.test_tryton.install_module('nereid_test') self.nereid_website_obj = POOL.get('nereid.website') self.nereid_website_locale_obj = POOL.get('nereid.website.locale') self.nereid_permission_obj = POOL.get('nereid.permission') self.nereid_user_obj = POOL.get('nereid.user')
# -*- coding: utf-8 -*- """ nereid_wishlist.py """ from trytond.pool import PoolMeta, Pool from trytond.model import ModelView, ModelSQL, fields from nereid import login_required, current_user, request, redirect, url_for, render_template, route, abort, flash from nereid.contrib.locale import make_lazy_gettext from wtforms import ValidationError _ = make_lazy_gettext("nereid-wishlist") __all__ = ["NereidUser", "Wishlist", "Product", "ProductWishlistRelationship"] __metaclass__ = PoolMeta class Product: """ Extension of product variant """ __name__ = "product.product" wishlists = fields.Many2Many("product.wishlist-product", "product", "wishlist", "Wishlists") @classmethod def copy(cls, products, default=None): """Duplicate products
# -*- coding: utf-8 -*- ''' Internationalisation for Nereid :copyright: (c) 2010-2014 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details ''' from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _ = make_lazy_gettext('nereid_checkout') N_ = make_lazy_ngettext('nereid_checkout')
user :copyright: (c) 2014 by Openlabs Technologies & Consulting (P) Limited :license: BSD, see LICENSE for more details. """ from nereid import url_for, flash, redirect, current_app, route from nereid.globals import session, request from nereid.signals import failed_login from nereid.contrib.locale import make_lazy_gettext from flask_oauth import OAuth from flask.ext.login import login_user from trytond.model import fields from trytond.pool import PoolMeta, Pool from trytond.transaction import Transaction _ = make_lazy_gettext('auth_google') __all__ = ['Website', 'NereidUser'] __metaclass__ = PoolMeta class Website: """Add Google auth settings to website""" __name__ = "nereid.website" google_app_id = fields.Char("Google App ID") google_app_secret = fields.Char("Google App Secret") def get_google_oauth_client(self): """ Returns a instance of WebCollect
# -*- coding: utf-8 -*- ''' Internationalisation for Nereid :copyright: (c) 2010-2014 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details ''' from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _, N_ = make_lazy_gettext('nereid'), make_lazy_ngettext('nereid')
# -*- coding: utf-8 -*- from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _ = make_lazy_gettext('nereid_checkout') N_ = make_lazy_ngettext('nereid_checkout')
# -*- coding: utf-8 -*- from flask_wtf import Form from wtforms import TextField, TextAreaField, SelectField, DecimalField, \ validators from wtforms.validators import ValidationError from nereid import abort from trytond.pool import Pool from nereid.contrib.locale import make_lazy_gettext _ = make_lazy_gettext('nereid_webshop') class GiftCardForm(Form): """ A form for purchasing gift cards """ recipient_name = TextField('Recipient Name', [validators.Optional()]) recipient_email = TextField('Recipient Email') message = TextAreaField('Message', [validators.Optional()]) selected_amount = SelectField('Select Amount', choices=[], coerce=int) open_amount = DecimalField('Amount', default=0) def __init__(self, product, *args, **kwargs): super(GiftCardForm, self).__init__(*args, **kwargs) Product = Pool().get('product.product') if not isinstance(product, Product): abort(400)
:license: GPLv3, see LICENSE for more details ''' from decimal import Decimal from trytond.pool import Pool, PoolMeta from jinja2.filters import do_striptags from werkzeug.exceptions import NotFound from nereid import jsonify, flash, request, url_for, route, redirect, \ render_template, abort from nereid.contrib.locale import make_lazy_gettext from forms import GiftCardForm _ = make_lazy_gettext('gift_card') __all__ = ['Product'] __metaclass__ = PoolMeta class Product: "Product extension for Nereid" __name__ = "product.product" def serialize(self, purpose=None): """ Downstream implementation which adds a key called inventory_status to the dictionary if purpose is 'variant_selection'.
# -*- coding: utf-8 -*- """ nereid_wishlist.py """ from trytond.pool import PoolMeta, Pool from trytond.model import ModelView, ModelSQL, fields from nereid import login_required, current_user, request, \ redirect, url_for, render_template, route, abort, flash from nereid.contrib.locale import make_lazy_gettext from wtforms import ValidationError _ = make_lazy_gettext('nereid-wishlist') __all__ = [ 'NereidUser', 'Wishlist', 'Product', 'ProductWishlistRelationship', ] __metaclass__ = PoolMeta class Product: """ Extension of product variant """ __name__ = 'product.product' wishlists = fields.Many2Many('product.wishlist-product', 'product',
# -*- coding: utf-8 -*- from datetime import datetime from trytond.pool import PoolMeta, Pool from nereid import route, login_required, render_template, request, \ current_user, redirect, url_for, flash, jsonify, abort from flask_wtf import Form from wtforms import TextField, validators, \ ValidationError, SelectField, IntegerField from trytond.error import UserError from nereid.contrib.locale import make_lazy_gettext __metaclass__ = PoolMeta __all__ = ['Party', 'PaymentProfile'] _ = make_lazy_gettext('nereid_payment_gateway') class PaymentProfileForm(Form): address = IntegerField([validators.DataRequired()]) owner = TextField('Full Name on Card', [validators.DataRequired(), ]) number = TextField( 'Card Number', [validators.DataRequired(), validators.Length(max=20)] ) expiry_month = SelectField( 'Card Expiry Month', [validators.DataRequired(), validators.Length(min=2, max=2)], choices=[ ('01', _('01-January')), ('02', _('02-February')), ('03', _('03-March')), ('04', _('04-April')),
# -*- coding: utf-8 -*- ''' Internationalisation for Nereid :copyright: (c) 2010-2014 by Openlabs Technologies & Consulting (P) Ltd. :license: GPLv3, see LICENSE for more details ''' from nereid.contrib.locale import make_lazy_gettext, make_lazy_ngettext _, N_ = make_lazy_gettext('nereid'), make_lazy_ngettext('nereid')