misc: move title fields to appearance tab (#64681)
This commit is contained in:
parent
f3727f829d
commit
2b68a863ed
|
@ -146,7 +146,6 @@ class ChartNgForm(ChartFiltersMixin, forms.ModelForm):
|
|||
class Meta:
|
||||
model = ChartNgCell
|
||||
fields = (
|
||||
'title',
|
||||
'statistic',
|
||||
'time_range',
|
||||
'time_range_start',
|
||||
|
|
|
@ -23,7 +23,6 @@ class WeeklyAgendaCellForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = WeeklyAgendaCell
|
||||
fields = [
|
||||
'title',
|
||||
'agenda_type',
|
||||
'agenda_references_template',
|
||||
'agenda_categories',
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import json
|
||||
|
||||
from django import forms
|
||||
from django.core import serializers
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -47,6 +48,11 @@ class GalleryCell(CellBase):
|
|||
image.object.gallery_id = self.id
|
||||
image.save()
|
||||
|
||||
def get_default_form_class(self, fields=None):
|
||||
if fields is None:
|
||||
fields = []
|
||||
return forms.models.modelform_factory(self.__class__, fields=fields)
|
||||
|
||||
|
||||
class Image(models.Model):
|
||||
gallery = models.ForeignKey(GalleryCell, on_delete=models.CASCADE, verbose_name=_('Gallery'))
|
||||
|
|
|
@ -1187,7 +1187,7 @@ class Items(CellBase):
|
|||
return getattr(context['request'], 'user', None) and context['request'].user.is_authenticated
|
||||
|
||||
def get_default_form_class(self):
|
||||
fields = ['title', 'text']
|
||||
fields = ['text']
|
||||
if hasattr(self, 'hide_if_empty'):
|
||||
fields.append('hide_if_empty')
|
||||
widgets = {}
|
||||
|
|
|
@ -399,7 +399,6 @@ class Map(CellBase):
|
|||
|
||||
def get_default_form_class(self):
|
||||
fields = (
|
||||
'title',
|
||||
'initial_state',
|
||||
'group_markers',
|
||||
'marker_behaviour_onclick',
|
||||
|
|
|
@ -27,7 +27,7 @@ from .models import SearchCell
|
|||
class SearchCellForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = SearchCell
|
||||
fields = ('title', 'autofocus', 'input_placeholder')
|
||||
fields = ('autofocus', 'input_placeholder')
|
||||
|
||||
|
||||
class SelectWithDisabled(forms.Select):
|
||||
|
|
|
@ -54,7 +54,7 @@ class WcsCardsCellForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = WcsCardsCell
|
||||
fields = ('carddef_reference', 'custom_title', 'limit', 'only_for_user')
|
||||
fields = ('carddef_reference', 'limit', 'only_for_user')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
instance = kwargs['instance']
|
||||
|
@ -80,8 +80,6 @@ class WcsCardInfoCellForm(forms.ModelForm):
|
|||
model = WcsCardInfosCell
|
||||
fields = (
|
||||
'carddef_reference',
|
||||
'title_type',
|
||||
'custom_title',
|
||||
'related_card_path',
|
||||
'card_ids',
|
||||
'custom_schema',
|
||||
|
@ -210,7 +208,6 @@ class WcsCurrentFormsCellForm(WcsFormsMixin, forms.ModelForm):
|
|||
field_order = [
|
||||
'wcs_site',
|
||||
'categories',
|
||||
'custom_title',
|
||||
'current_forms',
|
||||
'done_forms',
|
||||
'include_drafts',
|
||||
|
@ -221,7 +218,6 @@ class WcsCurrentFormsCellForm(WcsFormsMixin, forms.ModelForm):
|
|||
model = WcsCurrentFormsCell
|
||||
fields = [
|
||||
'wcs_site',
|
||||
'custom_title',
|
||||
'current_forms',
|
||||
'done_forms',
|
||||
'include_drafts',
|
||||
|
|
|
@ -961,6 +961,7 @@ class WcsCardInfosCell(CardMixin, CellBase):
|
|||
|
||||
default_template_name = 'combo/wcs/card.html'
|
||||
manager_form_template = 'combo/wcs/manager/card-infos-cell-form.html'
|
||||
manager_appearance_template = 'combo/wcs/manager/card-infos-cell-form-appearance.html'
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Card Information Cell')
|
||||
|
@ -1375,6 +1376,9 @@ class WcsCardInfosCell(CardMixin, CellBase):
|
|||
|
||||
return WcsCardInfoCellForm
|
||||
|
||||
def get_appearance_fields(self):
|
||||
return ['title_type', 'custom_title']
|
||||
|
||||
def get_custom_schema(self):
|
||||
custom_schema = self.custom_schema or {}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
{% extends "combo/cell_appearance.html" %}
|
||||
|
||||
{% block cell-form-appearance %}
|
||||
{{ block.super }}
|
||||
<script>
|
||||
{# display/hide custom_title field #}
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-title_type').on('change', function() {
|
||||
if ($(this).val() == 'manual') {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-custom_title').parent().show();
|
||||
} else {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-custom_title').parent().hide();
|
||||
}
|
||||
});
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-title_type').change();
|
||||
|
||||
{# display/hide card_ids field #}
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-related_card_path').on('change', function() {
|
||||
if (!$(this).val()) {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-card_ids').parent().show();
|
||||
} else {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-card_ids').parent().hide();
|
||||
}
|
||||
});
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-related_card_path').change();
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -166,26 +166,4 @@
|
|||
</script>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
{# display/hide custom_title field #}
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-title_type').on('change', function() {
|
||||
if ($(this).val() == 'manual') {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-custom_title').parent().show();
|
||||
} else {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-custom_title').parent().hide();
|
||||
}
|
||||
});
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-title_type').change();
|
||||
|
||||
{# display/hide card_ids field #}
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-related_card_path').on('change', function() {
|
||||
if (!$(this).val()) {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-card_ids').parent().show();
|
||||
} else {
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-card_ids').parent().hide();
|
||||
}
|
||||
});
|
||||
$('#id_cwcs_wcscardinfoscell-{{ cell.pk }}-related_card_path').change();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -42,7 +42,7 @@ class MenuCellForm(forms.ModelForm):
|
|||
class LinkCellForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = LinkCell
|
||||
fields = ('title', 'url', 'link_page', 'anchor')
|
||||
fields = ('url', 'link_page', 'anchor')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -58,7 +58,7 @@ class LinkCellForLinkListCellForm(LinkCellForm):
|
|||
class LinkListCellForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = LinkListCell
|
||||
fields = ['title', 'limit']
|
||||
fields = ['limit']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -1146,6 +1146,7 @@ class CellBase(models.Model, metaclass=CellMeta):
|
|||
'restricted_to_unlogged',
|
||||
'template_name',
|
||||
)
|
||||
+ tuple(self.get_appearance_fields())
|
||||
]
|
||||
|
||||
def get_default_form_class(self, fields=None):
|
||||
|
@ -1161,8 +1162,15 @@ class CellBase(models.Model, metaclass=CellMeta):
|
|||
self.__class__, fields=fields, **self.manager_form_factory_kwargs
|
||||
)
|
||||
|
||||
def get_appearance_fields(self):
|
||||
return ['title', 'custom_title']
|
||||
|
||||
def get_appearance_form_class(self):
|
||||
fields = ['slug', 'extra_css_class']
|
||||
model_fields = {field.name for field in self._meta.local_concrete_fields}
|
||||
fields = [field for field in self.get_appearance_fields() if field in model_fields] + [
|
||||
'slug',
|
||||
'extra_css_class',
|
||||
]
|
||||
widgets = None
|
||||
extra_templates = settings.COMBO_CELL_TEMPLATES.get(self.get_cell_type_str())
|
||||
if extra_templates:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{% load i18n %}
|
||||
{% block cell-form-appearance %}
|
||||
{{ appearance_form.as_p }}
|
||||
{% if cell.can_have_assets %}
|
||||
<p><a rel="popup" data-selector="div#assets-listing" href="{% url 'combo-manager-slot-assets' cell_reference=cell.get_reference %}"
|
||||
>{% trans 'Assets' %}</a></p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -377,6 +377,16 @@ def test_feed_cell_validity(context):
|
|||
assert ValidityInfo.objects.exists() is False
|
||||
|
||||
|
||||
def test_manager_feed_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='example page', slug='example-page')
|
||||
FeedCell.objects.create(page=page, placeholder='content', order=1)
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_menu_cell():
|
||||
Page.objects.all().delete()
|
||||
parent = Page.objects.create(
|
||||
|
@ -840,6 +850,22 @@ def test_json_cell_validity(context):
|
|||
assert ValidityInfo.objects.exists() is False
|
||||
|
||||
|
||||
def test_manager_json_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='example page', slug='example-page')
|
||||
JsonCell.objects.create(
|
||||
page=page,
|
||||
placeholder='content',
|
||||
order=1,
|
||||
varnames_str='var1, var2, ',
|
||||
url='http://foo?varone=[var1]&vartwo=[var2]',
|
||||
)
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_config_json_cell():
|
||||
page = Page(title='example page', slug='example-page')
|
||||
page.save()
|
||||
|
|
|
@ -1690,6 +1690,18 @@ def test_chartng_cell_manager_new_api_page_variables(app, admin_user, new_api_st
|
|||
assert [x[0] for x in color_field.options] == ['red', 'green', 'blue']
|
||||
|
||||
|
||||
def test_chartng_cell_manager_new_api_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='index')
|
||||
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
||||
cell.save()
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
@with_httmock(bijoe_mock)
|
||||
def test_table_cell(app, admin_user, statistics):
|
||||
page = Page(title='One', slug='index')
|
||||
|
|
|
@ -84,6 +84,16 @@ def test_manager_weeklyagenda_cell(app, admin_user):
|
|||
assert cell.end_date_filter == '{{ end_date }}'
|
||||
|
||||
|
||||
def test_manager_weeklyagenda_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='Family', slug='family', template_name='standard')
|
||||
WeeklyAgendaCell.objects.create(page=page, placeholder='content', order=0)
|
||||
login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_weeklyagenda_cell_user_external_id(context):
|
||||
page = Page.objects.create(title='Family', slug='index', template_name='standard')
|
||||
cell = WeeklyAgendaCell.objects.create(page=page, placeholder='content', order=0, agenda_type='manual')
|
||||
|
|
|
@ -73,3 +73,16 @@ def test_adding_gallery_images(app, admin_user):
|
|||
status=404,
|
||||
)
|
||||
app.get(reverse('combo-gallery-image-order', kwargs={'gallery_pk': 0}), status=404)
|
||||
|
||||
|
||||
def test_manager_gallery_cell_tabs(app, admin_user):
|
||||
page = Page(title='Pictures', slug='test_gallery_cell', template_name='standard')
|
||||
page.save()
|
||||
cell = GalleryCell(page=page, placeholder='content', order=0)
|
||||
cell.save()
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
|
|
@ -566,6 +566,19 @@ def test_configure_tipi_cell(app, admin_user):
|
|||
assert resp.text.count('ROLDET:') == 1
|
||||
|
||||
|
||||
def test_manager_tipi_cell_tabs(app, admin_user):
|
||||
page = Page(title='tipi', slug='tipi', template_name='standard')
|
||||
page.save()
|
||||
cell = TipiPaymentFormCell(title='Test payment', page=page, placeholder='content', order=0)
|
||||
cell.save()
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id, status=200)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_configure_invoices_cell(app, admin_user, payment_backend):
|
||||
page = Page(title='xxx', slug='test', template_name='standard')
|
||||
page.save()
|
||||
|
@ -621,6 +634,19 @@ def test_configure_invoices_cell(app, admin_user, payment_backend):
|
|||
assert ActiveItems.objects.get(id=cell.id).regie == regie2.slug
|
||||
|
||||
|
||||
def test_manager_invoices_cell_tabs(app, admin_user):
|
||||
page = Page(title='xxx', slug='test', template_name='standard')
|
||||
page.save()
|
||||
cell = ActiveItems(regie='remote', page=page, placeholder='content', order=0)
|
||||
cell.save()
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id, status=200)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_payment_backend_list(app, admin_user):
|
||||
PaymentBackend.objects.create(label='label1', slug='slug1')
|
||||
PaymentBackend.objects.create(label='label2', slug='slug2')
|
||||
|
|
|
@ -2594,6 +2594,16 @@ def test_link_cell_setup():
|
|||
assert 'extra_css_class' not in form.fields
|
||||
|
||||
|
||||
def test_manager_link_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='one', template_name='standard')
|
||||
LinkCell.objects.create(order=0, placeholder='content', page=page)
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_link_cell_validation():
|
||||
form = LinkCellForm(data={'url': 'http://example.com'})
|
||||
assert form.is_valid() is True
|
||||
|
|
|
@ -311,3 +311,13 @@ def test_add_delete_layer(app, admin_user, layer, tiles_layer):
|
|||
assert resp.status_int == 302
|
||||
assert resp.location.endswith('/manage/pages/%s/#cell-%s' % (page.pk, cell.get_reference()))
|
||||
assert MapLayerOptions.objects.count() == 0
|
||||
|
||||
|
||||
def test_manager_maps_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='one', template_name='standard')
|
||||
Map.objects.create(page=page, placeholder='content', order=0, public=True, title='Map')
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
|
|
@ -851,6 +851,16 @@ def test_manager_search_cell_order(settings, app, admin_user):
|
|||
assert cell._search_services == {'data': ['search_tmpl', '_text', 'search1']}
|
||||
|
||||
|
||||
def test_manager_search_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='one', template_name='standard')
|
||||
SearchCell.objects.create(page=page, placeholder='content', order=0)
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_manager_waiting_index_message(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='one', template_name='standard')
|
||||
cell = SearchCell.objects.create(page=page, placeholder='content', order=0)
|
||||
|
|
|
@ -1594,6 +1594,18 @@ def test_manager_current_forms(mock_send, settings, app, admin_user):
|
|||
assert resp.form['c%s-wcs_site' % cells[0].get_reference()].attrs['type'] == 'hidden'
|
||||
|
||||
|
||||
def test_manager_current_forms_tabs(app, admin_user):
|
||||
page = Page(title='One', slug='one', template_name='standard')
|
||||
page.save()
|
||||
cell = WcsCurrentFormsCell.objects.create(page=page, placeholder='content', order=1)
|
||||
cell.save()
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="custom_title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="custom_title"]')
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_manager_forms_in_your_care_cell(mock_send, app, admin_user):
|
||||
page = Page(title='One', slug='one', template_name='standard')
|
||||
|
@ -1635,6 +1647,17 @@ def test_manager_cards_cell(mock_send, app, admin_user):
|
|||
assert resp.forms[0]['c%s-with_user' % cell.get_reference()].value is None
|
||||
|
||||
|
||||
def test_manager_cards_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='xxx', slug='test_cards_cell_save_cache', template_name='standard')
|
||||
WcsCardsCell.objects.create(page=page, placeholder='content', order=0)
|
||||
login(app)
|
||||
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="custom_title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="custom_title"]')
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_cards_cell_setup(mock_send):
|
||||
cell = WcsCardsCell()
|
||||
|
@ -2456,6 +2479,19 @@ def test_manager_card_cell(mock_send, app, admin_user):
|
|||
]
|
||||
|
||||
|
||||
def test_manager_card_cell_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='xxx', slug='test_cards', template_name='standard', sub_slug='foobar')
|
||||
WcsCardInfosCell.objects.create(page=page, placeholder='content', order=0)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] select[name$="title_type"]')
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="custom_title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] select[name$="title_type"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="custom_title"]')
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_card_cell_load(mock_send):
|
||||
page = Page.objects.create(title='xxx', slug='test_cards', template_name='standard')
|
||||
|
@ -4203,6 +4239,16 @@ def test_manager_add_edit_delete_list_link_item(mock_send, app, admin_user):
|
|||
assert WcsFormCell.objects.count() == 0
|
||||
|
||||
|
||||
def test_manager_link_list_tabs(app, admin_user):
|
||||
page = Page.objects.create(title='One', slug='one', template_name='standard')
|
||||
LinkListCell.objects.create(order=0, placeholder='content', page=page)
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
|
||||
assert not resp.pyquery('[data-tab-slug="general"] input[name$="title"]')
|
||||
assert resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
|
||||
|
||||
|
||||
def test_import_export_pages_with_links():
|
||||
page = Page(title='bar', slug='bar', order=1)
|
||||
page.save()
|
||||
|
|
Loading…
Reference in New Issue