Skip to content

Commit

Permalink
Chore: logic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
whabanks committed Jun 17, 2024
1 parent fcb3550 commit d8799ac
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/dao/template_categories_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
from app.models import Template, TemplateCategory


DEFAULT_TEMPLATE_CATEGORIES = {
'bulk': current_app.config['DEFAULT_TEMPLATE_CATEGORY_LOW'],
'normal': current_app.config['DEFAULT_TEMPLATE_CATEGORY_MEDIUM'],
'priority': current_app.config['DEFAULT_TEMPLATE_CATEGORY_HIGH']
}

@transactional
def dao_create_template_category(template_category: TemplateCategory):
template_category.id = uuid.uuid4()
Expand Down Expand Up @@ -58,7 +64,9 @@ def dao_delete_template_category_by_id(template_category_id, cascade = False):
try:
for template in templates:
process_type = template_category.sms_process_type if template.template_type == 'sms' else template_category.email_process_type
template.category = dao_get_template_category_by_id(_get_default_category_id(process_type))
default_category_id = DEFAULT_TEMPLATE_CATEGORIES.get(process_type, current_app.config['DEFAULT_TEMPLATE_CATEGORY_LOW'])
template.category = dao_get_template_category_by_id(default_category_id)

db.session.add(template)

db.session.delete(template_category)
Expand All @@ -69,11 +77,3 @@ def dao_delete_template_category_by_id(template_category_id, cascade = False):
db.session.delete(template_category)
db.session.commit()


def _get_default_category_id(process_type):
default_categories = {
'bulk': current_app.config['DEFAULT_TEMPLATE_CATEGORY_LOW'],
'normal': current_app.config['DEFAULT_TEMPLATE_CATEGORY_MEDIUM'],
'priority': current_app.config['DEFAULT_TEMPLATE_CATEGORY_HIGH']
}
return default_categories.get(process_type, current_app.config['DEFAULT_TEMPLATE_CATEGORY_LOW'])

0 comments on commit d8799ac

Please sign in to comment.