Skip to content

Commit

Permalink
Merge branch 'main' into TV3/published-views-and-tombstones
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb committed Apr 28, 2024
2 parents b714583 + 465b2ba commit 790fc63
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
3 changes: 2 additions & 1 deletion designsafe/apps/workspace/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
AppListingEntry,
AppVariant,
AppTrayCategory,
AppTag
AppTag,
)

admin.site.register(AppDescription)
Expand Down Expand Up @@ -43,6 +43,7 @@ def get_fieldsets(self, request, obj=None):
"label",
"description",
"enabled",
"priority",
)
},
),
Expand Down
4 changes: 3 additions & 1 deletion designsafe/apps/workspace/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class RelatedApps(CMSPluginBase):

def render(self, context, instance: AppListingEntry, placeholder):
context = super().render(context, instance, placeholder)
listing_entries = instance.app.related_apps.filter(enabled=True)
listing_entries = instance.app.related_apps.filter(enabled=True).order_by(
"label"
)
serialized_listing = [
{
"label": entry.label,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 4.2.11 on 2024-04-26 19:18

from django.db import migrations, models
import django.db.models.functions.comparison


class Migration(migrations.Migration):
dependencies = [
("workspace", "0009_alter_applistingentry_icon"),
]

operations = [
migrations.AlterModelOptions(
name="applistingentry",
options={
"ordering": ["is_popular", "label"],
"verbose_name_plural": "App Listing Entries",
},
),
migrations.AlterModelOptions(
name="appvariant",
options={
"ordering": [
"priority",
django.db.models.functions.comparison.Coalesce("label", "app_id"),
]
},
),
migrations.AddField(
model_name="appvariant",
name="priority",
field=models.IntegerField(
default=0,
help_text="App variant priority, rendered in ascending order.",
),
),
]
10 changes: 10 additions & 0 deletions designsafe/apps/workspace/models/app_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""

from django.db import models
from django.db.models.functions import Coalesce

APP_ICONS = [
("Generic-App", "Generic: Application"),
Expand Down Expand Up @@ -146,6 +147,8 @@ class Meta:
)
]

ordering = ["is_popular", "label"]


class AppVariant(models.Model):
"""Model to represent a variant of an app, e.g. a software version or execution environment"""
Expand Down Expand Up @@ -181,6 +184,11 @@ class AppVariant(models.Model):
null=True,
)

priority = models.IntegerField(
help_text="App variant priority, rendered in ascending order.",
default=0,
)

# HTML Apps
html = models.TextField(
help_text="HTML definition to display when app is loaded.",
Expand Down Expand Up @@ -223,3 +231,5 @@ class Meta:
name="unique_apps_per_bundle",
)
]

ordering = ["priority", Coalesce("label", "app_id")]
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% if listing|length > 0 %}
<h2>Related Applications</h2>
<section class="o-app-grid">
{% for app in listing %}
{% include "designsafe/apps/workspace/app_card.html" with app=app %}
{% endfor %}
</section>
{% else %}
<!-- No related apps -->
{% endif %}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 790fc63

Please sign in to comment.