diff --git a/aleksis/core/migrations/0010_auto_20210303_2004.py b/aleksis/core/migrations/0010_auto_20210303_2004.py new file mode 100644 index 0000000000000000000000000000000000000000..7605e0743d925d0b8b0c655464be86cc8fa70ce2 --- /dev/null +++ b/aleksis/core/migrations/0010_auto_20210303_2004.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.7 on 2021-03-03 20:04 + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0009_default_dashboard'), + ] + + operations = [ + migrations.CreateModel( + name='ExternalLinkWidget', + fields=[ + ('dashboardwidget_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.dashboardwidget')), + ('url', models.URLField(verbose_name='URL')), + ('icon_url', models.URLField(verbose_name='Icon URL')), + ], + options={ + 'verbose_name': 'External link widget', + 'verbose_name_plural': 'External link widgets', + }, + bases=('core.dashboardwidget',), + ), + ] diff --git a/aleksis/core/models.py b/aleksis/core/models.py index b6e95bc3768e2a24eb402f17d71693f6f2b0311a..126869cfae235d7de0f339bd03899eb959cb5420 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -797,6 +797,20 @@ class DashboardWidget(PolymorphicModel, PureDjangoModel): verbose_name_plural = _("Dashboard Widgets") +class ExternalLinkWidget(DashboardWidget): + template = "core/dashboard_widget/external_link_widget.html" + + url = models.URLField(verbose_name=_("URL")) + icon_url = models.URLField(verbose_name=_("Icon URL")) + + def get_context(self, request): + return {"title": self.title, "url": self.url, "icon_url": self.icon_url} + + class Meta: + verbose_name = _("External link widget") + verbose_name_plural = _("External link widgets") + + class DashboardWidgetOrder(ExtensibleModel): widget = models.ForeignKey( DashboardWidget, on_delete=models.CASCADE, verbose_name=_("Dashboard widget") diff --git a/aleksis/core/templates/core/dashboard_widget/external_link_widget.html b/aleksis/core/templates/core/dashboard_widget/external_link_widget.html new file mode 100644 index 0000000000000000000000000000000000000000..bfbb5bda23e0e5034425ff745efab7f630119355 --- /dev/null +++ b/aleksis/core/templates/core/dashboard_widget/external_link_widget.html @@ -0,0 +1,8 @@ +<div class="card"> + <div class="card-image"> + <img src="{{ icon_url }}" alt="{{ title }}" /> + </div> + <div class="card-action"> + <a href="{{ url }}">{{ title }}</a> + </div> +</div>