Skip to content

Commit

Permalink
Prepare 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Jul 12, 2021
1 parent a1cdc8d commit 2b4700c
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ are used for versioning (schema follows below):

0.3.2
-----
2021-07-12
2021-07-13

- Add basic SQLAlchemy support.

Expand Down
39 changes: 39 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,45 @@ SQLAlchemy integration
Similarly to Django integration package, the SQLAlchemy integration package is
a simple ``CurrencyType`` representing the ISO-4217 codes of the currencies.

No magic methods are implemented yet (although planned to). What you get
is a simple SQLAlchemy type for storing the data. For the rest you will have
to make use of the ``valuta.shortcuts``.

See `sqlalchemy-integration/examples/sqlalchemy_example/valuta_admin/models.py <https://github.com/barseghyanartur/valuta/blob/feature/sqlalchemy-integration/examples/sqlalchemy_example/valuta_admin/models.py#L50>`
as a good example.

Model definition
~~~~~~~~~~~~~~~~
**Sample model**

*product/models.py*

.. code-block:: python
from valuta.contrib.sqlalchemy_integration.types import CurrencyType
from . import db # Standard SQLAlchemy way
class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Unicode(64), unique=True)
price = db.Column(db.Integer())
price_with_tax = db.Column(db.Integer())
currency = db.Column(CurrencyType())
**Sample data**

.. code-block:: python
import valuta
from product.models import Product
product = Product(
name="My test product",
price=100,
price_with_tax=120,
currency=valuta.AMD.uid,
)
Supported currencies
====================
Currencies marked with `(*)` are custom (added manually). The rest is obtained
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.3.2
-----
2021-07-13

- Add basic SQLAlchemy support.

0.3.1
-----
2021-07-01
Expand Down
46 changes: 46 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Prerequisites
- Core package requires Python 3.6, 3.7, 3.8 or 3.9.
- Django integration package (``valuta.contrib.django_integration``) requires
Django 2.2, 3.0, 3.1 or 3.2.
- SQLAlchemy integration package (``valuta.contrib.sqlalchemy_integration``)
has been tested with SQLAlchemy 1.4.x.

Documentation
=============
Expand Down Expand Up @@ -688,6 +690,50 @@ Sample template tags renderer
"template_tag_price_display_in_currency_units.html", {"instance": instance}
)
SQLAlchemy integration
----------------------
Similarly to Django integration package, the SQLAlchemy integration package is
a simple ``CurrencyType`` representing the ISO-4217 codes of the currencies.

No magic methods are implemented yet (although planned to). What you get
is a simple SQLAlchemy type for storing the data. For the rest you will have
to make use of the ``valuta.shortcuts``.

See `sqlalchemy-integration/examples/sqlalchemy_example/valuta_admin/models.py <https://github.com/barseghyanartur/valuta/blob/feature/sqlalchemy-integration/examples/sqlalchemy_example/valuta_admin/models.py#L50>`
as a good example.

Model definition
~~~~~~~~~~~~~~~~
**Sample model**

*product/models.py*

.. code-block:: python
from valuta.contrib.sqlalchemy_integration.types import CurrencyType
from . import db # Standard SQLAlchemy way
class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Unicode(64), unique=True)
price = db.Column(db.Integer())
price_with_tax = db.Column(db.Integer())
currency = db.Column(CurrencyType())
**Sample data**

.. code-block:: python
import valuta
from product.models import Product
product = Product(
name="My test product",
price=100,
price_with_tax=120,
currency=valuta.AMD.uid,
)
Supported currencies
====================
Currencies marked with `(*)` are custom (added manually). The rest is obtained
Expand Down
1 change: 0 additions & 1 deletion examples/sqlalchemy_example/valuta_admin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class AbstractProduct(db.Model):
name = db.Column(db.Unicode(64), unique=True)
price = db.Column(db.Integer())
price_with_tax = db.Column(db.Integer())
# currency = db.Column(CurrencyType())

def __str__(self):
return f"{self.name}"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

version = "0.3.1"
version = "0.3.2"

try:
readme = open(os.path.join(os.path.dirname(__file__), "README.rst")).read()
Expand Down
2 changes: 1 addition & 1 deletion src/valuta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__title__ = "valuta"
__copyright__ = "2021 Artur Barseghyan"
__license__ = "GPL-2.0-only OR LGPL-2.1-or-later"
__version__ = "0.3.1"
__version__ = "0.3.2"

0 comments on commit 2b4700c

Please sign in to comment.