Skip to content

Commit

Permalink
Updates for Tethys 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
swainn committed Jan 20, 2023
1 parent 203267f commit 96bb1f7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 95 deletions.
6 changes: 5 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
# 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: earth_engine

Expand All @@ -14,4 +16,6 @@ requirements:
- oauth2client
pip:

post:
npm:

post:
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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 = 'earth_engine'
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(
Expand Down
2 changes: 1 addition & 1 deletion tethysapp/earth_engine/__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
30 changes: 7 additions & 23 deletions tethysapp/earth_engine/app.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
from tethys_sdk.base import TethysAppBase, url_map_maker
from tethys_sdk.base import TethysAppBase


class EarthEngine(TethysAppBase):
"""
Tethys app class for Earth Engine.
"""

name = 'Earth Engine'
index = 'earth_engine:home'
icon = 'earth_engine/images/earth-engine-logo.png'
package = 'earth_engine'
name = 'Google Earth Engine Tutorial'
description = ''
package = 'earth_engine' # WARNING: Do not change this value
index = 'home'
icon = f'{package}/images/earth-engine-logo.png'
root_url = 'earth-engine'
color = '#524745'
description = ''
tags = ''
enable_feedback = False
feedback_emails = []

def url_maps(self):
"""
Add controllers
"""
UrlMap = url_map_maker(self.root_url)

url_maps = (
UrlMap(
name='home',
url='earth-engine',
controller='earth_engine.controllers.home'
),
)

return url_maps
feedback_emails = []
30 changes: 15 additions & 15 deletions tethysapp/earth_engine/controllers.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
from django.shortcuts import render
from tethys_sdk.permissions import login_required
from tethys_sdk.routing import controller
from tethys_sdk.gizmos import Button

@login_required()
@controller
def home(request):
"""
Controller for the app home page.
"""
save_button = Button(
display_text='',
name='save-button',
icon='glyphicon glyphicon-floppy-disk',
icon='save',
style='success',
attributes={
'data-toggle':'tooltip',
'data-placement':'top',
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Save'
}
)

edit_button = Button(
display_text='',
name='edit-button',
icon='glyphicon glyphicon-edit',
icon='pen',
style='warning',
attributes={
'data-toggle':'tooltip',
'data-placement':'top',
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Edit'
}
)

remove_button = Button(
display_text='',
name='remove-button',
icon='glyphicon glyphicon-remove',
icon='trash',
style='danger',
attributes={
'data-toggle':'tooltip',
'data-placement':'top',
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Remove'
}
)
Expand All @@ -47,8 +47,8 @@ def home(request):
display_text='Previous',
name='previous-button',
attributes={
'data-toggle':'tooltip',
'data-placement':'top',
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Previous'
}
)
Expand All @@ -57,8 +57,8 @@ def home(request):
display_text='Next',
name='next-button',
attributes={
'data-toggle':'tooltip',
'data-placement':'top',
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Next'
}
)
Expand Down
3 changes: 0 additions & 3 deletions tethysapp/earth_engine/handoff.py

This file was deleted.

Binary file removed tethysapp/earth_engine/public/images/icon.gif
Binary file not shown.
20 changes: 10 additions & 10 deletions tethysapp/earth_engine/templates/earth_engine/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
{% block app_title %}{{ tethys_app.name }}{% endblock %}

{% block app_navigation_items %}
<li class="title">App Navigation</li>
<li class="active"><a href="">Home</a></li>
<li><a href="">Jobs</a></li>
<li><a href="">Results</a></li>
<li class="title">Steps</li>
<li><a href="">1. The First Step</a></li>
<li><a href="">2. The Second Step</a></li>
<li><a href="">3. The Third Step</a></li>
<li class="separator"></li>
<li><a href="">Get Started</a></li>
<li class="nav-item title">App Navigation</li>
<li class="nav-item active"><a class="nav-link" href="">Home</a></li>
<li class="nav-item"><a class="nav-link" href="">Jobs</a></li>
<li class="nav-item"><a class="nav-link" href="">Results</a></li>
<li class="nav-item title">Steps</li>
<li class="nav-item"><a class="nav-link" href="">1. The First Step</a></li>
<li class="nav-item"><a class="nav-link" href="">2. The Second Step</a></li>
<li class="nav-item"><a class="nav-link" href="">3. The Third Step</a></li>
<li class="nav-item separator"></li>
<li class="nav-item"><a class="nav-link" href="">Get Started</a></li>
{% endblock %}

{% block app_content %}
Expand Down
14 changes: 7 additions & 7 deletions tethysapp/earth_engine/templates/earth_engine/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% load tethys_gizmos %}

{% block header_buttons %}
<div class="header-button glyphicon-button" data-toggle="tooltip" data-placement="bottom" title="Help">
<a data-toggle="modal" data-target="#help-modal"><span class="glyphicon glyphicon-question-sign"></span></a>
<div class="header-button glyphicon-button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Help">
<a data-bs-toggle="modal" data-bs-target="#help-modal"><i class="bi bi-question-circle"></i></a>
</div>
{% endblock %}

Expand All @@ -25,17 +25,17 @@ <h6>Heading 6</h6>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h5 class="modal-title" id="help-modal-label">Example Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>You can add custom buttons to the app header using the <code>header_buttons</code> block. Use anchor/link tags for the button and wrap it in a div with the class <code>header-button</code>. For buttons with the gliphyicons, add the <code>glyphicon-button</code> class as well.</p>
<p>Ever have trouble using a modal in a Tethys app? Use the <code>after_app_content</code> block for modal content to allow them to function properly. See: <a href="https://getbootstrap.com/javascript/#modals">Bootstrap Modals</a></p>
<p>Add tooltips to any element by adding the <code>data-toggle</code>, <code>data-placement</code>, and <code>title</code> attributes to the button. See: <a href="https://getbootstrap.com/javascript/#tooltips">Bootstrap Tooltips</a></p>
<p>Ever have trouble using a modal in a Tethys app? Use the <code>after_app_content</code> block for modal content to allow them to function properly. See: <a href="https://getbootstrap.com/docs/5.1/components/modal/">Bootstrap Modals</a></p>
<p>Add tooltips to any element by adding the <code>data-bs-toggle</code>, <code>data-bs-placement</code>, and <code>title</code> attributes to the button. See: <a href="https://getbootstrap.com/docs/5.1/components/tooltips/">Bootstrap Tooltips</a></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>
</div>
</div>
</div>
Expand Down
44 changes: 13 additions & 31 deletions tethysapp/earth_engine/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# Most of your test classes should inherit from TethysTestCase
from tethys_sdk.testing import TethysTestCase

# Use if your app has persistent stores that will be tested against.
# Your app class from app.py must be passed as an argument to the TethysTestCase functions to both
# create and destroy the temporary persistent stores for your app used during testing
# from ..app import EarthEngine

# Use if you'd like a simplified way to test rendered HTML templates.
# You likely need to install BeautifulSoup, as it is not included by default in Tethys Platform
# 1. Open a terminal
# 2. Enter command ". /usr/lib/tethys/bin/activate" to activate the Tethys python environment
# 3. Enter command "pip install beautifulsoup4"
# For help, see https://www.crummy.com/software/BeautifulSoup/bs4/doc/
# For testing rendered HTML templates it may be helpful to use BeautifulSoup.
# from bs4 import BeautifulSoup
# For help, see https://www.crummy.com/software/BeautifulSoup/bs4/doc/


"""
To run any tests:
1. Open a terminal
2. Enter command ". /usr/lib/tethys/bin/activate" to activate the Tethys python environment
3. In portal_config.yml make sure that the default database user is set to tethys_super or is a super user of the database
To run tests for an app:
1. Open a terminal and activate the Tethys environment::
conda activate tethys
2. In portal_config.yml make sure that the default database user is set to tethys_super or is a super user of the database
DATABASES:
default:
ENGINE: django.db.backends.postgresql_psycopg2
Expand All @@ -28,28 +23,15 @@
HOST: 127.0.0.1
PORT: 5435
4. Enter tethys test command.
The general form is: "tethys test -f tethys_apps.tethysapp.<app_name>.<folder_name>.<file_name>.<class_name>.<function_name>"
See below for specific examples
To run all tests across this app:
Test command: "tethys test -f tethys_apps.tethysapp.earth_engine"
3. From the root directory of your app, run the ``tethys manage test`` command::
To run all tests in this file:
Test command: "tethys test -f tethys_apps.tethysapp.earth_engine.tests.tests"
tethys manage test tethysapp/<app_name>/tests
To run tests in the EarthEngineTestCase class:
Test command: "tethys test -f tethys_apps.tethysapp.earth_engine.tests.tests.EarthEngineTestCase"
To run only the test_if_tethys_platform_is_great function in the EarthEngineTestCase class:
Test command: "tethys test -f tethys_apps.tethysapp.earth_engine.tests.tests.EarthEngineTestCase.test_if_tethys_platform_is_great"
To learn more about writing tests, see:
https://docs.djangoproject.com/en/1.9/topics/testing/overview/#writing-tests
https://docs.python.org/2.7/library/unittest.html#module-unittest
https://docs.tethysplatform.org/en/stable/tethys_sdk/testing.html
"""


class EarthEngineTestCase(TethysTestCase):
"""
In this class you may define as many functions as you'd like to test different aspects of your app.
Expand Down

0 comments on commit 96bb1f7

Please sign in to comment.