Skip to content
Snippets Groups Projects
Commit c4354d40 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch 'feature/static-content-dashboard-widget' into 'master'

Implement StaticContentWidget

Closes #662

See merge request !981
parents e5e4f551 1322d730
No related branches found
No related tags found
1 merge request!981Implement StaticContentWidget
Pipeline #56751 passed
Pipeline: AlekSIS

#56996

    ......@@ -19,6 +19,7 @@ Added
    * Allow to configure if additional field is required
    * Allow to configure description of additional fields
    * Allow configuring regex for allowed usernames
    * Implement StaticContentWidget
    Changed
    ~~~~~~~
    ......
    # Generated by Django 3.2.12 on 2022-02-23 18:03
    import ckeditor.fields
    from django.db import migrations, models
    import django.db.models.deletion
    class Migration(migrations.Migration):
    dependencies = [
    ('core', '0036_additionalfields_helptext_required'),
    ]
    operations = [
    migrations.CreateModel(
    name='StaticContentWidget',
    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')),
    ('content', ckeditor.fields.RichTextField(verbose_name='Content')),
    ],
    options={
    'verbose_name': 'Static content widget',
    'verbose_name_plural': 'Static content widgets',
    },
    bases=('core.dashboardwidget',),
    ),
    ]
    ......@@ -29,6 +29,7 @@ import customidenticon
    import jsonstore
    from cachalot.api import cachalot_disabled
    from cache_memoize import cache_memoize
    from ckeditor.fields import RichTextField
    from django_celery_results.models import TaskResult
    from django_cte import CTEQuerySet, With
    from dynamic_preferences.models import PerInstancePreferenceModel
    ......@@ -988,6 +989,19 @@ class ExternalLinkWidget(DashboardWidget):
    verbose_name_plural = _("External link widgets")
    class StaticContentWidget(DashboardWidget):
    template = "core/dashboard_widget/static_content_widget.html"
    content = RichTextField(verbose_name=_("Content"))
    def get_context(self, request):
    return {"title": self.title, "content": self.content}
    class Meta:
    verbose_name = _("Static content widget")
    verbose_name_plural = _("Static content widgets")
    class DashboardWidgetOrder(ExtensibleModel):
    widget = models.ForeignKey(
    DashboardWidget, on_delete=models.CASCADE, verbose_name=_("Dashboard widget")
    ......
    {% load html_helpers %}
    <div class="card" style="padding: 2em">
    <div class="card-title">
    {{ title }}
    </div>
    <div class="card-text">
    {{ content|add_class_to_el:"ul, browser-default"|safe }}
    </div>
    </div>
    ......@@ -18,6 +18,14 @@ optionally with an icon or picture next to it. It therefore provides the followi
    As link title, the widget title will be used.
    Static content widget
    ^^^^^^^^^^^^^^^^^^^^
    The static content widget allows to display custom static information on the dashboard,
    It therefore provides the following additional attribute:
    * **Content**: The content of the widget. HTML can be used for formatting.
    More dashboard widgets from apps
    --------------------------------
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment