Skip to content

Commit

Permalink
Merge pull request #1778 from OpenEnergyPlatform/bugfix-resolve-oep-l…
Browse files Browse the repository at this point in the history
…og-error

Bugfix resolve oep log error
  • Loading branch information
jh-RLI authored Jul 29, 2024
2 parents d415f41 + d5812fc commit 6c623be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/automated-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip 'setuptools<72.0.0' wheel
pip install -r requirements.txt
pip install tox
- name: Add schemas for testing
Expand Down
24 changes: 18 additions & 6 deletions modelview/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ def getClasses(sheettype):
"""
Returns the model and form class w.r.t sheettype.
"""
allowed_sheet_types = ["model", "framework"]
c = None
f = None
if sheettype == "model":
c = Energymodel
f = EnergymodelForm
elif sheettype == "framework":
c = Energyframework
f = EnergyframeworkForm

if isinstance(sheettype, str):
if sheettype in allowed_sheet_types:
if sheettype == "model":
c = Energymodel
f = EnergymodelForm
elif sheettype == "framework":
c = Energyframework
f = EnergyframeworkForm

return c, f


Expand Down Expand Up @@ -187,6 +192,12 @@ def model_to_csv(request, sheettype):
match = re.match(r"^select_(?P<tid>\d+)$", label)
tags.append(int(match.group("tid")))
c, f = getClasses(sheettype)

if not c:
raise Http404(
"We dropped the scenario factsheets in favor of scenario bundles."
)

header = list(
field.attname
for field in c._meta.get_fields()
Expand All @@ -203,6 +214,7 @@ def model_to_csv(request, sheettype):
for model in c.objects.all().order_by("id"):
if all(tid in model.tags for tid in tags):
writer.writerow([printable(model, col) for col in header])

return response


Expand Down

0 comments on commit 6c623be

Please sign in to comment.