Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetaure/installed app api #941

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
417 changes: 216 additions & 201 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ astropy = [
{ version = ">=5.3.3,<6", python = ">=3.9" },
{ version = ">=3,<6", python = "<3.12" }
]
django = "<5"
django = ">4,<6"
djangorestframework = "<4"
django-bootstrap4 = ">3,<25"
beautifulsoup4 = "<5"
Expand Down
4 changes: 2 additions & 2 deletions tom_alerts/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from tom_common.apps import TOMToolkitAppConfig


class TomAlertsConfig(AppConfig):
class TomAlertsConfig(TOMToolkitAppConfig):
name = 'tom_alerts'
4 changes: 2 additions & 2 deletions tom_catalogs/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from tom_common.apps import TOMToolkitAppConfig


class TomCatalogsConfig(AppConfig):
class TomCatalogsConfig(TOMToolkitAppConfig):
name = 'tom_catalogs'
56 changes: 55 additions & 1 deletion tom_common/apps.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,66 @@
import logging

from django.apps import AppConfig
from django.conf import settings

import plotly.io as pio


class TomCommonConfig(AppConfig):
logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)


class TOMToolkitAppConfig(AppConfig):
"""Base class for TOM Toolkit apps.

This class defines a common API for TOM Toolkit apps to use to so tom_base
knows how to interact with them (i.e. where are the integration points, etc.)
"""

def ready(self):
super().ready()
logger.debug(f'{self.name} is a TOM Toolkit app and is ready')

## integration_points = {
## 'navbar': {},
## 'target_detail_button': {},
## 'api_urls': {},
## 'target_detail_panels': {},
## }
##
## def target_detail_button(self, target):
## """Retuns a dictionary of buttons to be displayed on the target detail page.
##
## Called by target_extras.get_buttons inclusion tag.
## """
## return {}
##
## def install_my_navbar_items_in_other_app(self):
## """This method allows an INSTALLED_APP to place navbar items in the navbar
## menu of another app. Check that the destination app is installed before
## tryiing to install your items into it's navbar menu.
## """
## # tom_altas....
## if TOMTargetsAppConfig:
## pass
## if TOMObservationsAppConfig:
## pass
##
## return []
##
## def receive_navbar_intems_from_other_app(self):
## """Returns a list of dictionaries to be displayed in the navbar.
##
## Called by navbar inclusion tag. (maybe?).
## """
## return []


class TomCommonConfig(TOMToolkitAppConfig):
name = 'tom_common'

def ready(self):
super().ready()
# Set default plotly theme on startup
valid_themes = ['plotly', 'plotly_white', 'plotly_dark', 'ggplot2', 'seaborn', 'simple_white', 'none']

Expand Down
4 changes: 2 additions & 2 deletions tom_dataproducts/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from tom_common.apps import TOMToolkitAppConfig


class TomDataproductsConfig(AppConfig):
class TomDataproductsConfig(TOMToolkitAppConfig):
name = 'tom_dataproducts'
4 changes: 2 additions & 2 deletions tom_observations/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig
from tom_common.apps import TOMToolkitAppConfig


class TomObservationsConfig(AppConfig):
class TomObservationsConfig(TOMToolkitAppConfig):
name = 'tom_observations'
12 changes: 6 additions & 6 deletions tom_setup/templates/tom_setup/settings.tmpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to include these specifically. They should run automatically when the app is installed.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ INSTALLED_APPS = [
'django.contrib.sites',
'django_extensions',
'guardian',
'tom_common',
'tom_common.apps.TomCommonConfig',
'django_comments',
'bootstrap4',
'crispy_bootstrap4',
Expand All @@ -54,11 +54,11 @@ INSTALLED_APPS = [
'rest_framework.authtoken',
'django_filters',
'django_gravatar',
'tom_targets',
'tom_alerts',
'tom_catalogs',
'tom_observations',
'tom_dataproducts',
'tom_targets.apps.TomTargetsConfig',
'tom_alerts.apps.TomAlertsConfig',
'tom_catalogs.apps.TomCatalogsConfig',
'tom_observations.apps.TomObservationsConfig',
'tom_dataproducts.apps.TomDataproductsConfig',
]

SITE_ID = 1
Expand Down
9 changes: 7 additions & 2 deletions tom_targets/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from django.apps import AppConfig
import logging

from tom_common.apps import TOMToolkitAppConfig

class TomTargetsConfig(AppConfig):
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


class TomTargetsConfig(TOMToolkitAppConfig):
name = 'tom_targets'
4 changes: 3 additions & 1 deletion tom_targets/templatetags/targets_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def get_buttons(target):
Returns a list of buttons from imported modules to be displayed on the target detail page.
In order to add a button to the target detail page, an app must contain an integration points attribute.
The Integration Points attribute must be a dictionary with a key of 'target_detail_button':

'target_detail_button' = {'namespace': <<redirect path, i.e. 'app:name'>>,
'title': <<Button title>>,
'class': <<Button class i.e 'btn btn-info'>>,
Expand All @@ -341,4 +342,5 @@ def get_buttons(target):
if integration_points.get('target_detail_button', False):
button_list.append(integration_points['target_detail_button'])

return {'target': target, 'button_list': button_list}
context = {'target': target, 'button_list': button_list}
return context
Loading