use db models instead of tuples when referring to rate objects

makes it less confusing
This commit is contained in:
Leo Hemsted
2019-04-03 13:07:49 +01:00
parent fcc25abf18
commit 6f41f6c7d7
3 changed files with 46 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
import random
import uuid
from datetime import datetime, date
from decimal import Decimal
from app import db
from app.dao.email_branding_dao import dao_create_email_branding
@@ -29,6 +30,7 @@ from app.models import (
Job,
Notification,
EmailBranding,
LetterRate,
Organisation,
Rate,
Service,
@@ -403,6 +405,23 @@ def create_rate(start_date, value, notification_type):
return rate
def create_letter_rate(start_date=None, end_date=None, crown=True, sheet_count=1, rate=0.33, post_class='second'):
if start_date is None:
start_date = datetime(2016, 1, 1)
rate = LetterRate(
id=uuid.uuid4(),
start_date=start_date,
end_date=end_date,
crown=crown,
sheet_count=sheet_count,
rate=Decimal(rate),
post_class=post_class
)
db.session.add(rate)
db.session.commit()
return rate
def create_api_key(service, key_type=KEY_TYPE_NORMAL):
id_ = uuid.uuid4()
api_key = ApiKey(