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

Add link and external field to step blocks. This makes it possible to #5217

Merged
merged 5 commits into from
Sep 6, 2022
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
4 changes: 2 additions & 2 deletions bluebottle/cms/content_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class Media(object):
"all": ('admin/css/forms-nested.css', )
}
js = (
'admin/js/inlines-nested.js',
'admin/js/jquery.init.js',
'admin/js/inlines-nested.min.js',
'js/csrf.js',
'adminsortable/js/jquery-ui-django-admin.min.js',
'adminsortable/js/admin.sortable.stacked.inlines.js'
)


Expand Down
18 changes: 18 additions & 0 deletions bluebottle/cms/migrations/0069_step_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2022-08-29 09:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cms', '0068_auto_20220121_1448'),
]

operations = [
migrations.AddField(
model_name='step',
name='link',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
23 changes: 23 additions & 0 deletions bluebottle/cms/migrations/0070_auto_20220829_1600.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.24 on 2022-08-29 14:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cms', '0069_step_link'),
]

operations = [
migrations.AddField(
model_name='step',
name='external',
field=models.BooleanField(default=False, help_text='Open the link in a new browser tab', verbose_name='Open in new tab'),
),
migrations.AlterField(
model_name='step',
name='link',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Link'),
),
]
14 changes: 14 additions & 0 deletions bluebottle/cms/migrations/0071_merge_20220906_0730.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.24 on 2022-09-06 05:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('cms', '0070_homepagestatisticscontent_year'),
('cms', '0070_auto_20220829_1600'),
]

operations = [
]
4 changes: 4 additions & 0 deletions bluebottle/cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ class Step(SortableMixin, models.Model):
)
header = models.CharField(_("Header"), max_length=100)
text = models.CharField(_("Text"), max_length=400, null=True, blank=True)
link = models.CharField(_("Link"), max_length=100, blank=True, null=True)
external = models.BooleanField(_("Open in new tab"), default=False, blank=False,
help_text=_('Open the link in a new browser tab'))

sequence = models.PositiveIntegerField(default=0, editable=False, db_index=True)

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion bluebottle/cms/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class StepSerializer(serializers.ModelSerializer):

class Meta(object):
model = Step
fields = ('id', 'image', 'header', 'text', )
fields = ('id', 'image', 'header', 'text', 'link', 'external')


class StepsContentSerializer(serializers.ModelSerializer):
Expand Down
6 changes: 6 additions & 0 deletions bluebottle/cms/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
'text': 'Go!',
'image': '',
'header': 'First',
'link': None,
'external': False,
'sequence': 1
},
'app': 'cms'
Expand All @@ -51,6 +53,8 @@
'text': 'Go!',
'image': '',
'header': 'Second',
'link': None,
'external': False,
'sequence': 2
},
'app': 'cms'
Expand All @@ -60,6 +64,8 @@
'text': 'Go!',
'image': '',
'header': 'Third',
'link': None,
'external': False,
'sequence': 3
},
'app': 'cms'
Expand Down
1 change: 1 addition & 0 deletions bluebottle/utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def __init__(self, allowed_mimetypes=None, message=None, code=None):

def __call__(self, value):
try:
value.file.seek(0)
gannetson marked this conversation as resolved.
Show resolved Hide resolved
mimetype = mime.from_buffer(value.file.read(3084))
except FileNotFoundError:
return
Expand Down