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 23, 2024
1 parent f2bb516 commit 478e902
Show file tree
Hide file tree
Showing 21 changed files with 514 additions and 355 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
*.db
*.sqlite
*.DS_Store
*.json
.idea/
services.yml
10 changes: 1 addition & 9 deletions install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# This file should be committed to your app code.
version: 1.1
# This should be greater or equal to your tethys-platform in your environment
tethys_version: ">=4.0.0"
version: 1.0
# This should match the app - package name in your setup.py
name: dam_inventory

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

pip:

npm:

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

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

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

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


setup(
name=release_package,
Expand All @@ -29,4 +28,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
22 changes: 20 additions & 2 deletions tethysapp/dam_inventory/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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 App(TethysAppBase):
class DamInventory(TethysAppBase):
"""
Tethys app class for Dam Inventory.
"""

name = 'Dam Inventory'
description = ''
package = 'dam_inventory' # WARNING: Do not change this value
Expand All @@ -30,6 +31,7 @@ def custom_settings(self):
required=False
),
)

return custom_settings

def persistent_store_settings(self):
Expand Down Expand Up @@ -64,3 +66,19 @@ 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 478e902

Please sign in to comment.