Skip to content

Commit

Permalink
removal(dev): version 2 templates;
Browse files Browse the repository at this point in the history
- removed version 2 templates.
  • Loading branch information
JVickery-TBS committed Dec 10, 2024
1 parent 7074987 commit 4635246
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 376 deletions.
5 changes: 4 additions & 1 deletion ckanext/recombinant/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def template(dataset_type, lang, owner_org):
except ckanapi.NotFound:
return abort(404, _('Not found'))

book = excel_template(dataset_type, org)
try:
book = excel_template(dataset_type, org)
except RecombinantException as e:
return abort(400, _('Unable to download template.\n%s') % e)

if request.method == 'POST':
filters = {}
Expand Down
19 changes: 9 additions & 10 deletions ckanext/recombinant/write_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from ckanext.recombinant.datatypes import datastore_type
from ckanext.recombinant.helpers import (
recombinant_choice_fields, recombinant_language_text)
from ckanext.recombinant.write_excel_v2 import (
_populate_excel_sheet_v2, _populate_reference_sheet_v2)

from ckan.plugins.toolkit import _, h, config, request
from flask_babel import force_locale

from datetime import datetime
from decimal import Decimal

DEFAULT_TEMPLATE_VERSION = 3

HEADER_ROW, HEADER_HEIGHT = 1, 27
CHEADINGS_ROW, CHEADINGS_HEIGHT = 2, 22
CHEADINGS_MIN_WIDTH = 10
Expand Down Expand Up @@ -99,10 +99,13 @@
def excel_template(dataset_type, org):
"""
return an openpyxl.Workbook object containing the sheet and header fields
for passed dataset_type and org. Supports version 2 and 3 templates.
for passed dataset_type and org. Supports version 3 templates.
"""
geno = get_geno(dataset_type)
version = geno.get('template_version', 2)
version = geno.get('template_version', DEFAULT_TEMPLATE_VERSION)

if version < DEFAULT_TEMPLATE_VERSION:
raise RecombinantException(_('Unsupported template version: %s') % version)

book = openpyxl.Workbook()
sheet = book.active
Expand All @@ -112,9 +115,7 @@ def excel_template(dataset_type, org):
if version == 3:
_build_styles(book, geno)
for rnum, chromo in enumerate(geno['resources'], 1):
if version == 2:
_populate_excel_sheet_v2(sheet, chromo, org, refs)
elif version == 3:
if version == 3:
_append_resource_ref_header(geno, refs, rnum)
choice_ranges.append(_populate_excel_sheet(
book, sheet, geno, chromo, org, refs, rnum))
Expand All @@ -123,9 +124,7 @@ def excel_template(dataset_type, org):
sheet.protection.formatColumns = False
sheet = book.create_sheet()

if version == 2:
_populate_reference_sheet_v2(sheet, chromo, refs)
elif version == 3:
if version == 3:
_populate_reference_sheet(sheet, geno, refs)
sheet.title = 'reference'
sheet.protection.enabled = True
Expand Down
Loading

0 comments on commit 4635246

Please sign in to comment.