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

task/DES-2654: Tapis v2/v3 apps model #1158

Merged
merged 18 commits into from
Mar 4, 2024
Merged
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
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[flake8]
# E501: line is too long.
# H101: Use TODO(NAME)
ignore = E501, H101
# W503: line break before binary operator. Ingore as black will break this rule.
ignore = E501, H101, W503
exclude = __pycache__,
tests.py,
migrations
Expand Down
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,11 @@ disable=raw-checker-failed,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
line-too-long,
duplicate-code,
logging-fstring-interpolation


# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
Expand Down
95 changes: 95 additions & 0 deletions designsafe/apps/workspace/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,99 @@
"""Admin layout for Tools & Applications workspace models.
"""

from django.contrib import admin
from django.db import models
from django.forms import CheckboxSelectMultiple
from designsafe.apps.workspace.models.app_descriptions import AppDescription
from designsafe.apps.workspace.models.app_entries import (
AppListingEntry,
AppVariant,
AppTrayCategory,
)

admin.site.register(AppDescription)
admin.site.register(AppTrayCategory)


class AppVariantInline(admin.StackedInline):
"""Admin layout for app variants."""

extra = 0
model = AppVariant
fk_name = "bundle"

def get_fieldsets(self, request, obj=None):
return [
(
"Tapis App information",
{
"fields": (
"app_type",
"app_id",
"version",
"license_type",
)
},
),
(
"Display information",
{
"fields": (
"label",
"enabled",
)
},
),
(
"HTML App Body for app_type: HTML",
{
"classes": ["collapse"],
"fields": ["html"],
},
),
]


@admin.register(AppListingEntry)
class AppTrayEntryAdmin(admin.ModelAdmin):
"""Admin layout for AppTrayEntry items."""

class Media:
css = {"all": ("styles/cms-form-styles.css",)}

inlines = [AppVariantInline]

def get_fieldsets(self, request, obj=None):
default_fieldset = [
(
"Portal Display Options",
{
"fields": [
"category",
"label",
"icon",
"enabled",
],
},
),
]

cms_fieldset = [
(
"CMS Display Options",
{
"fields": [
"href",
"popular",
"not_bundled",
"related_apps",
],
},
),
]

return default_fieldset + cms_fieldset

formfield_overrides = {
models.ManyToManyField: {"widget": CheckboxSelectMultiple},
}
4 changes: 2 additions & 2 deletions designsafe/apps/workspace/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='AppDescription',
fields=[
('appId', models.CharField(max_length=120, primary_key=True, serialize=False, unique=True)),
('appDescription', models.TextField(help_text=b'App dropdown description text for apps that have a dropdown.')),
('appid', models.CharField(max_length=120, primary_key=True, serialize=False, unique=True)),
('appdescription', models.TextField(help_text=b'App dropdown description text for apps that have a dropdown.')),
],
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='appdescription',
name='appDescription',
name='appdescription',
field=models.TextField(help_text='App dropdown description text for apps that have a dropdown.'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# Generated by Django 4.2.6 on 2024-03-01 20:10

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("workspace", "0002_auto_20200423_1940"),
]

operations = [
migrations.CreateModel(
name="AppListingEntry",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"label",
models.CharField(
help_text="The display name of this bundle in the Apps Tray. Not used if this entry is a single app ID.",
max_length=64,
),
),
(
"icon",
models.CharField(
blank=True,
choices=[
("adcirc", "ADCIRC"),
("ansys", "Ansys"),
("blender", "Blender"),
("clawpack", "Clawpack"),
("compress", "Compress"),
("dakota", "Dakota"),
("extract", "Extract"),
("hazmapper", "Hazmapper"),
("jupyter", "Jupyter"),
("ls-dyna", "LS-DYNA"),
("matlab", "MATLAB"),
("ngl", "NGL"),
("openfoam", "OpenFOAM"),
("opensees", "OpenSees"),
("paraview", "Paraview"),
("qgis", "QGIS"),
("rwhale", "rWHALE"),
("stko", "STKO"),
("swbatch", "swbatch"),
("visit", "VisIt"),
],
help_text="The icon associated with this app.",
max_length=64,
),
),
(
"enabled",
models.BooleanField(
default=True, help_text="App bundle visibility in app tray."
),
),
(
"popular",
models.BooleanField(
default=False,
help_text="Mark as popular on tools & apps overview.",
),
),
(
"not_bundled",
models.BooleanField(
default=False,
help_text="Select if this entry represents a single app ID and not a bundle.",
),
),
(
"href",
models.CharField(
blank=True,
help_text="Link to overview page for this app.",
max_length=128,
),
),
],
options={
"verbose_name_plural": "App Listing Entries",
},
),
migrations.CreateModel(
name="AppTrayCategory",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"category",
models.CharField(
help_text="A category for the app tray.",
max_length=64,
unique=True,
),
),
(
"priority",
models.IntegerField(
default=0,
help_text="Category priority, where higher number tabs appear before lower ones.",
),
),
],
options={
"verbose_name_plural": "App Categories",
},
),
migrations.CreateModel(
name="AppVariant",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"app_id",
models.CharField(
help_text="The id of this app or app bundle. The id appears in the unique url path to the app.",
max_length=64,
),
),
(
"app_type",
models.CharField(
choices=[
("tapis", "Tapis App"),
("html", "HTML or External app"),
],
default="tapis",
help_text="Application type.",
max_length=10,
),
),
(
"label",
models.CharField(
blank=True,
help_text="The display name of this app in the Apps Tray. If not defined, uses notes.label from app definition.",
max_length=64,
),
),
(
"license_type",
models.CharField(
choices=[("OS", "Open Source"), ("LS", "Licensed")],
default="OS",
help_text="License Type.",
max_length=2,
),
),
(
"html",
models.TextField(
blank=True,
default="",
help_text="HTML definition to display when app is loaded.",
),
),
(
"version",
models.CharField(
blank=True,
default="",
help_text="The version number of the app. The app id + version denotes a unique app.",
max_length=64,
),
),
(
"enabled",
models.BooleanField(
default=True, help_text="App variant visibility in app tray."
),
),
(
"bundle",
models.ForeignKey(
blank=True,
help_text="Bundle that the app belongs to.",
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="workspace.applistingentry",
),
),
],
),
migrations.AddField(
model_name="applistingentry",
name="category",
field=models.ForeignKey(
help_text="The category for this app entry.",
on_delete=django.db.models.deletion.CASCADE,
to="workspace.apptraycategory",
),
),
migrations.AddField(
model_name="applistingentry",
name="related_apps",
field=models.ManyToManyField(
blank=True,
help_text="Related apps that will display on app overview page.",
to="workspace.applistingentry",
),
),
]
Loading
Loading