Skip to content
Snippets Groups Projects
Verified Commit fd920750 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add option to set the size of dashboard widgets

parent 0debfe0b
No related branches found
No related tags found
1 merge request!410Sizing of dashboard widgets
Pipeline #4970 passed
# Generated by Django 3.1.4 on 2020-12-20 15:55
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('core', '0005_timestamped_activity_notification'),
]
operations = [
migrations.AddField(
model_name='dashboardwidget',
name='size_l',
field=models.PositiveSmallIntegerField(default=6, help_text='> 992 px, 12 columns', validators=[django.core.validators.MaxValueValidator(12)], verbose_name='Size on desktop devices'),
),
migrations.AddField(
model_name='dashboardwidget',
name='size_m',
field=models.PositiveSmallIntegerField(default=12, help_text='> 600 px, 12 columns', validators=[django.core.validators.MaxValueValidator(12)], verbose_name='Size on tablet devices'),
),
migrations.AddField(
model_name='dashboardwidget',
name='size_s',
field=models.PositiveSmallIntegerField(default=12, help_text='<= 600 px, 12 columns', validators=[django.core.validators.MaxValueValidator(12)], verbose_name='Size on mobile devices'),
),
migrations.AddField(
model_name='dashboardwidget',
name='size_xl',
field=models.PositiveSmallIntegerField(default=4, help_text='> 1200 px>, 12 columns', validators=[django.core.validators.MaxValueValidator(12)], verbose_name='Size on large desktop devices'),
),
]
......@@ -9,6 +9,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator
from django.db import models, transaction
from django.db.models import QuerySet
from django.forms.widgets import Media
......@@ -681,6 +682,31 @@ class DashboardWidget(PolymorphicModel, PureDjangoModel):
title = models.CharField(max_length=150, verbose_name=_("Widget Title"))
active = models.BooleanField(verbose_name=_("Activate Widget"))
size_s = models.PositiveSmallIntegerField(
verbose_name=_("Size on mobile devices"),
help_text=_("<= 600 px, 12 columns"),
validators=[MaxValueValidator(12)],
default=12,
)
size_m = models.PositiveSmallIntegerField(
verbose_name=_("Size on tablet devices"),
help_text=_("> 600 px, 12 columns"),
validators=[MaxValueValidator(12)],
default=12,
)
size_l = models.PositiveSmallIntegerField(
verbose_name=_("Size on desktop devices"),
help_text=_("> 992 px, 12 columns"),
validators=[MaxValueValidator(12)],
default=6,
)
size_xl = models.PositiveSmallIntegerField(
verbose_name=_("Size on large desktop devices"),
help_text=_("> 1200 px>, 12 columns"),
validators=[MaxValueValidator(12)],
default=4,
)
def get_context(self):
"""Get the context dictionary to pass to the widget template."""
raise NotImplementedError("A widget subclass needs to implement the get_context method.")
......
......@@ -31,7 +31,7 @@
<div class="row" id="live_load">
{% for widget in widgets %}
<div class="col s12 m12 l6 xl4">
<div class="col s{{ widget.size_s }} m{{ widget.size_m }} l{{ widget.size_l }} xl{{ widget.size_xl }}">
{% include_widget widget %}
</div>
{% endfor %}
......
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