Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Add a cost column to the occasion
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed Nov 28, 2016
1 parent 875df6d commit 9a00433
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions onegov/activity/models/occasion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sqlalchemy import ForeignKey
from sqlalchemy import func
from sqlalchemy import Integer
from sqlalchemy import Numeric
from sqlalchemy import Text
from sqlalchemy.dialects.postgresql import INT4RANGE
from sqlalchemy.ext.hybrid import hybrid_property
Expand Down Expand Up @@ -69,6 +70,11 @@ def __hash__(self):
#: A note about the occurrence
note = Column(Text, nullable=True)

#: The cost of the occasion (max value is 100'000.00), the currency is
#: assumed to be CHF as this system will probably never be used outside
#: Switzerland
cost = Column(Numeric(precision=8, scale=2), nullable=True)

#: The activity this occasion belongs to
activity_id = Column(
UUID, ForeignKey("activities.id", use_alter=True), nullable=False)
Expand Down
9 changes: 8 additions & 1 deletion onegov/activity/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from onegov.activity import Booking, Period, Occasion
from onegov.core.orm.types import UUID, JSON
from onegov.core.upgrade import upgrade_task
from sqlalchemy import Boolean, Column, Enum, ForeignKey, Integer
from sqlalchemy import Boolean, Column, Enum, ForeignKey, Integer, Numeric
from sqlalchemy.orm import joinedload


Expand Down Expand Up @@ -112,3 +112,10 @@ def add_finalized_flag_to_period(context):

context.session.flush()
context.operations.alter_column('periods', 'finalized', nullable=False)


@upgrade_task('Add cost column to occasion')
def add_cost_column_to_occasion(context):
context.operations.add_column('occasions', Column(
'cost', Numeric(precision=8, scale=2), nullable=True
))

0 comments on commit 9a00433

Please sign in to comment.