Skip to content

Commit

Permalink
updates for tethys 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeymac committed Aug 18, 2024
1 parent e4a5b30 commit f2bb516
Show file tree
Hide file tree
Showing 21 changed files with 353 additions and 509 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
*.db
*.sqlite
*.DS_Store
*.json
.idea/
services.yml
10 changes: 9 additions & 1 deletion install.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file should be committed to your app code.
version: 1.0
version: 1.1
# This should be greater or equal to your tethys-platform in your environment
tethys_version: ">=4.0.0"
# This should match the app - package name in your setup.py
name: dam_inventory

Expand All @@ -8,8 +10,14 @@ requirements:
skip: false
conda:
channels:
- conda-forge
packages:
- sqlalchemy<2
- psycopg2
- plotly

pip:

npm:

post:
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from setuptools import setup, find_namespace_packages
from tethys_apps.app_installation import find_resource_files
from tethys_apps.app_installation import find_all_resource_files
from tethys_apps.base.app_base import TethysAppBase

# -- Apps Definition -- #
app_package = 'dam_inventory'
release_package = 'tethysapp-' + app_package
release_package = f'{TethysAppBase.package_namespace}-{app_package}'

# -- Python Dependencies -- #
dependencies = []

# -- Get Resource File -- #
resource_files = find_resource_files('tethysapp/' + app_package + '/templates', 'tethysapp/' + app_package)
resource_files += find_resource_files('tethysapp/' + app_package + '/public', 'tethysapp/' + app_package)
resource_files = find_all_resource_files(
app_package, TethysAppBase.package_namespace
)

setup(
name=release_package,
Expand All @@ -27,4 +29,4 @@
include_package_data=True,
zip_safe=False,
install_requires=dependencies,
)
)
2 changes: 1 addition & 1 deletion tethysapp/dam_inventory/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Included for native namespace package support
# Included for native namespace package support
21 changes: 2 additions & 19 deletions tethysapp/dam_inventory/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from tethys_sdk.base import TethysAppBase, url_map_maker
from tethys_sdk.app_settings import CustomSetting, PersistentStoreDatabaseSetting
from tethys_sdk.base import TethysAppBase
from tethys_sdk.permissions import Permission, PermissionGroup


class DamInventory(TethysAppBase):
class App(TethysAppBase):
"""
Tethys app class for Dam Inventory.
"""

name = 'Dam Inventory'
description = ''
package = 'dam_inventory' # WARNING: Do not change this value
Expand Down Expand Up @@ -65,19 +64,3 @@ def permissions(self):
permissions = (admin,)

return permissions

@classmethod
def pre_delete_user_workspace(cls, user):
from .model import Dam
Session = cls.get_persistent_store_database('primary_db', as_sessionmaker=True)
session = Session()

# Delete all hydrographs connected to dams created by user
dams = session.query(Dam).filter(Dam.user_id == user.id)

for dam in dams:
if dam.hydrograph:
session.delete(dam.hydrograph)

session.commit()
session.close()
Loading

0 comments on commit f2bb516

Please sign in to comment.