-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from nossas/feature/ds-block-imagebackground
Feature/ds block imagebackground
- Loading branch information
Showing
15 changed files
with
414 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
83 changes: 83 additions & 0 deletions
83
app/contrib/ds/admin_style/templates/admin/filer/widgets/admin_file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{% load i18n filer_admin_tags static %} | ||
|
||
{% spaceless %} | ||
<div class="filer-widget"> | ||
<div class="clearfix"></div> | ||
|
||
<div class="dz-preview dz-file-preview hidden js-filer-dropzone-template"> | ||
<span class="filerFile"> | ||
<div class="dz-thumbnail"><img class="quiet" data-dz-thumbnail></div> | ||
<span data-dz-name class="dz-name"></span> | ||
<span class="filerClearer fa fa-close filer-icon filer-icon-remove-selection" title="{% translate 'Clear' %}" | ||
data-dz-remove data-no-icon-file="{% static 'filer/icons/file-unknown.svg' %}"></span> | ||
<div class="dz-progress js-filer-dropzone-progress"><span class="dz-upload" data-dz-uploadprogress></span></div> | ||
</span> | ||
</div> | ||
|
||
<div class="js-filer-dropzone filer-dropzone{% if object %} js-object-attached{% endif %}" | ||
data-url="{% url 'admin:filer-ajax_upload' %}" | ||
data-max-files="1" | ||
{% if max_filesize %}}data-max-filesize="{{ max_filesize|safe }}"{% endif %}> | ||
<div class="z-index-fix"></div> | ||
<div class="dz-default dz-message js-filer-dropzone-message{% if object %} hidden{% endif %}"> | ||
<span class="icon filer-icon filer-icon-arrow-down fa fa-arrow-down"></span><span>{% translate "or drop your file here" %}</span> | ||
</div> | ||
|
||
<span class="filerFile js-file-selector"> | ||
<div class="file-edit-area"> | ||
<div class="file-object-file"> | ||
{% if object %} | ||
{% if object.file.exists %} | ||
<a href="{{ object.url }}" target="_blank">{% file_icon object size='80x80' %}</a> | ||
<div class="file-desc-object"> | ||
<span class="description_text">{{ object.label }}</span> | ||
{% else %} | ||
<div class="file-desc-object"> | ||
{% file_icon object %} | ||
<span class="description_text">{% translate 'File is missing' %}</span> | ||
{% endif %} | ||
{% else %} | ||
<img class="thumbnail_img hidden quiet" alt="{% translate 'no file selected' %}"> | ||
<span class="description_text"></span> | ||
{% endif %} | ||
|
||
<a class="filerClearer {% if not object %}hidden{% endif %}" title="{% translate 'Clear' %}" | ||
data-no-icon-file="{% static 'filer/icons/file-unknown.svg' %}" href="#"> | ||
<span class="fa fa-close filer-icon filer-icon-remove-selection"></span> | ||
</a> | ||
{% if object %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="file-controls"> | ||
<a href="{{ change_url }}?_edit_from_widget=1" class="js-related-edit related-lookup {% if object %}related-lookup-change{% endif %} edit" id="{{ id }}_change" | ||
title="{% translate 'Edit' %}"> | ||
<span class="edit-file"><span class="fa fa-pencil cms-icon cms-icon-settings"></span></span> | ||
</a> | ||
|
||
<a href="{{ lookup_url }}" class="js-related-lookup related-lookup {% if object %}related-lookup-change{% endif %} lookup" id="{{ id }}_lookup" | ||
title="{% translate 'Lookup' %}"> | ||
<span class="choose-file"><span class="fa fa-search cms-icon cms-icon-search"></span>{% translate 'Choose File' %}</span> | ||
<span class="replace-file"><span class="fa fa-search cms-icon cms-icon-search"></span></span> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<br> | ||
|
||
<div class="hidden">{{ hidden_input }}</div> | ||
<script type="text/javascript" id="{{id}}_javascript"> | ||
django.jQuery(document).ready(function(){ | ||
var plus = django.jQuery('#add_{{ id }}'); | ||
if (plus.length){ | ||
plus.remove(); | ||
} | ||
// Delete this javascript once loaded to avoid the "add new" link duplicates it | ||
django.jQuery('#{{id}}_javascript').remove(); | ||
}); | ||
</script> | ||
</span> | ||
</div> | ||
</div> | ||
{% endspaceless %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/contrib/ds/blocks/migrations/0006_block_background_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.2 on 2024-05-10 20:44 | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
import django.db.models.deletion | ||
import filer.fields.image | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.FILER_IMAGE_MODEL), | ||
('blocks', '0005_alter_block_options_alter_block_element_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='block', | ||
name='background_image', | ||
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.FILER_IMAGE_MODEL, verbose_name='Imagem de fundo'), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
app/contrib/ds/blocks/migrations/0007_block_background_size.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2024-05-15 20:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('blocks', '0006_block_background_image'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='block', | ||
name='background_size', | ||
field=models.CharField(choices=[('contain', 'Contain'), ('cover', 'Cover'), ('initial', 'Initial')], default='contain', max_length=8), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
app/contrib/ds/blocks/migrations/0008_alter_block_background_size.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2 on 2024-05-16 14:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('blocks', '0007_block_background_size'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='block', | ||
name='background_size', | ||
field=models.CharField(choices=[('contain', 'Contain'), ('cover', 'Cover'), ('initial', 'Initial')], default='cover', max_length=8), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from django import forms | ||
|
||
from contrib.ds.blocks.forms import BlockForm, BlockTemplateForm | ||
|
||
|
||
base_fields = [ | ||
"template", | ||
"element", | ||
"layout", | ||
"is_container", | ||
"background_image", | ||
"background_size", | ||
] | ||
|
||
|
||
def test_fields_block_tempalte_form(): | ||
assert base_fields == BlockTemplateForm.Meta.untangled_fields | ||
|
||
|
||
def test_fields_block_form(): | ||
assert base_fields == BlockForm.Meta.untangled_fields | ||
|
||
|
||
def test_template_hidden_on_block_form(): | ||
form = BlockForm() | ||
assert isinstance(form.fields["template"].widget, forms.HiddenInput) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.