general: rename cell template_name attribute to default_template_name (#55792)

This commit is contained in:
Frédéric Péters 2021-07-23 12:37:23 +02:00
parent 22ce180d68
commit f823e6cbba
14 changed files with 43 additions and 43 deletions

View File

@ -44,7 +44,7 @@ class BookingCalendar(CellBase):
)
days_displayed = models.PositiveSmallIntegerField(_('Number of days to display'), default=7)
template_name = 'calendar/booking_calendar_cell.html'
default_template_name = 'calendar/booking_calendar_cell.html'
class Meta:
verbose_name = _('Booking Calendar')

View File

@ -53,7 +53,7 @@ class Gauge(CellBase):
jsonp_data_source = models.BooleanField(_('Use JSONP to get data'), default=True)
max_value = models.PositiveIntegerField(_('Max Value'), blank=True, null=True)
template_name = 'combo/gauge-cell.html'
default_template_name = 'combo/gauge-cell.html'
class Media:
js = ('js/gauge.min.js', 'js/combo.gauge.js')
@ -84,7 +84,7 @@ class Gauge(CellBase):
@register_cell_class
class ChartCell(CellBase):
template_name = 'combo/dataviz-chart.html'
default_template_name = 'combo/dataviz-chart.html'
title = models.CharField(_('Title'), max_length=150, blank=True, null=True)
url = models.URLField(_('URL'), max_length=250, blank=True, null=True)

View File

@ -24,7 +24,7 @@ from .utils import get_family, is_family_enabled
@register_cell_class
class FamilyInfosCell(CellBase):
template_name = 'family/infos.html'
default_template_name = 'family/infos.html'
user_dependant = True
class Meta:

View File

@ -32,7 +32,7 @@ logger = logging.getLogger(__name__)
@register_cell_class
class RecentDocumentsCell(CellBase):
template_name = 'combo/fargo/recent-documents-cell.html'
default_template_name = 'combo/fargo/recent-documents-cell.html'
fargo_site = models.CharField(_('Site'), max_length=50, blank=True)
user_dependant = True

View File

@ -29,7 +29,7 @@ from combo.data.models import CellBase
@register_cell_class
class GalleryCell(CellBase):
title = models.CharField(_('Title'), max_length=50, blank=True, null=True)
template_name = 'combo/gallerycell.html'
default_template_name = 'combo/gallerycell.html'
manager_form_template = 'combo/gallery_manager.html'
class Meta:

View File

@ -37,7 +37,7 @@ class LatestPageUpdatesCell(CellBase):
)
limit = models.PositiveSmallIntegerField(_('Maximum number of entries'), default=10)
template_name = 'combo/latest-page-updates-cell.html'
default_template_name = 'combo/latest-page-updates-cell.html'
exclude_from_search = True
class Meta:

View File

@ -1157,7 +1157,7 @@ class Items(CellBase):
text = RichTextField(_('Text'), blank=True, null=True)
user_dependant = True
template_name = 'lingo/combo/items.html'
default_template_name = 'lingo/combo/items.html'
loading_message = _('Loading invoices...')
class Meta:
@ -1262,7 +1262,7 @@ class ActiveItems(Items):
@register_cell_class
class SelfDeclaredInvoicePayment(Items):
user_dependant = False
template_name = 'lingo/combo/self-declared-invoice-payment.html'
default_template_name = 'lingo/combo/self-declared-invoice-payment.html'
class Meta:
verbose_name = _('Self declared invoice payment')
@ -1313,7 +1313,7 @@ class TipiPaymentFormCell(CellBase):
'ROLDET', max_length=13, blank=True, help_text=_('Default value to be used in form')
)
test_mode = models.BooleanField(_('Test mode'), default=False)
template_name = 'lingo/tipi_form.html'
default_template_name = 'lingo/tipi_form.html'
class Meta:
verbose_name = _('TIPI Payment Form')

View File

@ -368,7 +368,7 @@ class Map(CellBase):
)
layers = models.ManyToManyField(MapLayer, through='MapLayerOptions', verbose_name=_('Layers'), blank=True)
template_name = 'maps/map_cell.html'
default_template_name = 'maps/map_cell.html'
manager_form_template = 'maps/map_cell_form.html'
class Meta:

View File

@ -48,7 +48,7 @@ def get_root_page_and_children(service_slug):
@register_cell_class
class SearchCell(CellBase):
template_name = 'combo/search-cell.html'
default_template_name = 'combo/search-cell.html'
manager_form_template = 'combo/manager/search-cell-form.html'
exclude_from_search = True

View File

@ -69,7 +69,7 @@ class WcsFormCell(CellBase):
cached_url = models.URLField(_('URL'))
cached_json = JSONField(blank=True, default=dict)
template_name = 'combo/wcs/form.html'
default_template_name = 'combo/wcs/form.html'
add_as_link_label = _('add a form link')
add_link_label = _('New form link')
edit_link_label = _('Edit form link')
@ -251,7 +251,7 @@ class WcsCommonCategoryCell(CellBase):
@register_cell_class
class WcsCategoryCell(WcsCommonCategoryCell):
template_name = 'combo/wcs/category.html'
default_template_name = 'combo/wcs/category.html'
class Meta:
verbose_name = _('Category Link')
@ -483,7 +483,7 @@ class WcsCurrentFormsCell(CategoriesValidityMixin, CategoriesFilteringMixin, Wcs
return url
@property
def template_name(self):
def default_template_name(self):
if self.current_forms and self.done_forms:
return 'combo/wcs/user_all_forms.html'
if self.done_forms:
@ -546,7 +546,7 @@ class WcsCurrentFormsCell(CategoriesValidityMixin, CategoriesFilteringMixin, Wcs
@register_cell_class
class WcsCurrentDraftsCell(CategoriesValidityMixin, CategoriesFilteringMixin, WcsUserDataBaseCell):
variable_name = 'current_drafts'
template_name = 'combo/wcs/current_drafts.html'
default_template_name = 'combo/wcs/current_drafts.html'
loading_message = _('Loading drafts...')
categories = JSONField(_('Categories'), blank=True, default=dict)
@ -615,7 +615,7 @@ class WcsFormsOfCategoryCell(WcsCommonCategoryCell, WcsBlurpMixin):
verbose_name = _('Forms of Category')
variable_name = 'forms'
template_name = 'combo/wcs/forms_of_category.html'
default_template_name = 'combo/wcs/forms_of_category.html'
cache_duration = 600
def get_default_form_class(self):
@ -720,7 +720,7 @@ class WcsCareFormsCell(CategoriesValidityMixin, CategoriesFilteringMixin, WcsDat
api_url = '/api/forms/?limit=10'
variable_name = 'care_forms'
template_name = 'combo/wcs/care_forms.html'
default_template_name = 'combo/wcs/care_forms.html'
cache_duration = 120
user_dependant = True
@ -752,7 +752,7 @@ class WcsCareFormsCell(CategoriesValidityMixin, CategoriesFilteringMixin, WcsDat
class CategoriesCell(WcsDataBaseCell):
api_url = '/api/categories/?full=on'
variable_name = 'form_categories'
template_name = 'combo/wcs/form_categories.html'
default_template_name = 'combo/wcs/form_categories.html'
cache_duration = 600
class Meta:
@ -783,7 +783,7 @@ class WcsCardsCell(CardMixin, WcsBlurpMixin, CellBase):
only_for_user = models.BooleanField(_('Limit to cards linked to the logged-in user'), default=False)
without_user = models.BooleanField(_('Ignore the logged-in user'), default=False)
template_name = 'combo/wcs/cards.html'
default_template_name = 'combo/wcs/cards.html'
variable_name = 'cards'
class Meta:
@ -902,7 +902,7 @@ class WcsCardInfosCell(CardMixin, CellBase):
is_enabled = classmethod(is_wcs_enabled)
template_name = 'combo/wcs/card.html'
default_template_name = 'combo/wcs/card.html'
manager_form_template = 'combo/wcs/manager/card-infos-cell-form.html'
class Meta:
@ -1005,7 +1005,7 @@ class WcsCardInfosCell(CardMixin, CellBase):
class TrackingCodeInputCell(CellBase):
is_enabled = classmethod(is_wcs_enabled)
wcs_site = models.CharField(_('Site'), max_length=50, blank=True)
template_name = 'combo/wcs/tracking_code_input.html'
default_template_name = 'combo/wcs/tracking_code_input.html'
class Meta:
verbose_name = _('Tracking Code Input')
@ -1032,7 +1032,7 @@ class TrackingCodeInputCell(CellBase):
class BackofficeSubmissionCell(CategoriesValidityMixin, CategoriesFilteringMixin, WcsDataBaseCell):
api_url = '/api/formdefs/?backoffice-submission=on'
variable_name = 'all_formdefs'
template_name = 'combo/wcs/backoffice_submission.html'
default_template_name = 'combo/wcs/backoffice_submission.html'
cache_duration = 600
user_dependant = True

View File

@ -725,7 +725,7 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
visible = True
user_dependant = False
template_name = None
default_template_name = None
# get_badge(self, context); set to None so cell types can be skipped easily
get_badge = None
@ -1117,9 +1117,9 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
context.update(self.get_cell_extra_context(context))
template_names = ['combo/' + self._meta.model_name + '.html']
base_template_name = self._meta.model_name + '.html'
if self.template_name:
base_template_name = os.path.basename(self.template_name)
template_names.append(self.template_name)
if self.default_template_name:
base_template_name = os.path.basename(self.default_template_name)
template_names.append(self.default_template_name)
if self.slug:
template_names.append('combo/cells/%s/%s' % (self.slug, base_template_name))
template_names.reverse()
@ -1189,7 +1189,7 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
class TextCell(CellBase):
text = RichTextField(_('Text'), blank=True, null=True)
template_name = 'combo/text-cell.html'
default_template_name = 'combo/text-cell.html'
class Meta:
verbose_name = _('Text')
@ -1299,7 +1299,7 @@ class MenuCell(CellBase):
verbose_name=_('Root Page'),
)
template_name = 'combo/menu-cell.html'
default_template_name = 'combo/menu-cell.html'
exclude_from_search = True
class Meta:
@ -1338,7 +1338,7 @@ class LinkCell(CellBase):
)
anchor = models.CharField(_('Anchor'), max_length=150, blank=True)
template_name = 'combo/link-cell.html'
default_template_name = 'combo/link-cell.html'
add_as_link_label = _('add a link')
add_link_label = _('New link')
edit_link_label = _('Edit link')
@ -1456,7 +1456,7 @@ class LinkListCell(CellBase):
title = models.CharField(_('Title'), max_length=150, blank=True)
limit = models.PositiveSmallIntegerField(_('Limit'), null=True, blank=True)
template_name = 'combo/link-list-cell.html'
default_template_name = 'combo/link-list-cell.html'
manager_form_template = 'combo/manager/link-list-cell-form.html'
children_placeholder_prefix = '_linkslist:'
exclude_from_search = True
@ -1559,7 +1559,7 @@ class FeedCell(CellBase):
limit = models.PositiveSmallIntegerField(_('Maximum number of entries'), null=True, blank=True)
manager_form_factory_kwargs = {'field_classes': {'url': TemplatableURLField}}
template_name = 'combo/feed-cell.html'
default_template_name = 'combo/feed-cell.html'
invalid_reason_codes = {
'data_url_not_defined': _('No URL set'),
@ -1845,7 +1845,7 @@ class JsonCellBase(CellBase):
context['synchronous'] = synchronous
@property
def template_name(self):
def default_template_name(self):
json_content = self._json_content
if json_content is None:
return 'combo/json-error-cell.html'
@ -2040,7 +2040,7 @@ class ConfigJsonCell(JsonCellBase):
return settings.JSON_CELL_TYPES[self.key].get('additional-data')
@property
def template_name(self):
def default_template_name(self):
return settings.JSON_CELL_TYPES[self.key].get('template-name', 'combo/json/%s.html' % self.key)
@property

View File

@ -33,7 +33,7 @@ class Profile(models.Model):
@register_cell_class
class ProfileCell(JsonCellBase):
template_name = 'combo/profile.html'
default_template_name = 'combo/profile.html'
first_data_key = 'profile'
cache_duration = None

View File

@ -437,19 +437,19 @@ def test_json_cell():
cell.save()
cell._json_content = None
assert cell.template_name == 'combo/json-error-cell.html'
assert cell.default_template_name == 'combo/json-error-cell.html'
cell._json_content = {}
assert cell.template_name == 'combo/json-cell.html'
assert cell.default_template_name == 'combo/json-cell.html'
cell._json_content = {'data': []}
assert cell.template_name == 'combo/json-cell.html'
assert cell.default_template_name == 'combo/json-cell.html'
cell._json_content = {'data': [{'url': 'xxx', 'text': 'xxx'}]}
assert cell.template_name == 'combo/json-list-cell.html'
assert cell.default_template_name == 'combo/json-list-cell.html'
cell._json_content = {'data': [{'foo': 'xxx', 'bar': 'xxx'}]}
assert cell.template_name == 'combo/json-cell.html'
assert cell.default_template_name == 'combo/json-cell.html'
with mock.patch('combo.utils.requests.get') as requests_get:
data = {'data': [{'url': 'xxx', 'text': 'xxx'}]}
@ -678,7 +678,7 @@ def test_config_json_cell():
cell.parameters = {'blah': 'plop'}
assert cell.get_label() == 'Foobar'
assert cell.url == 'http://test/'
assert cell.template_name == 'combo/json/foobar.html'
assert cell.default_template_name == 'combo/json/foobar.html'
assert cell.css_class_names.split() == ['config-json-cell', 'configjsoncell', 'foobar']
with mock.patch('combo.utils.requests.get') as requests_get:
@ -700,7 +700,7 @@ def test_config_json_cell():
cell.parameters = {'blah': 'plop'}
assert cell.get_label() == 'Foobar'
assert cell.url == 'http://test/'
assert cell.template_name == 'combo/json/foobar.html'
assert cell.default_template_name == 'combo/json/foobar.html'
assert cell.cache_duration == 10

View File

@ -217,7 +217,7 @@ def test_tipi_cell():
cell.save()
assert cell.control_protocol == 'pesv2'
assert cell.url == 'https://www.payfip.gouv.fr/tpa/paiement.web'
assert cell.template_name == 'lingo/tipi_form.html'
assert cell.default_template_name == 'lingo/tipi_form.html'
html = cell.render({})
assert "<h2>TIPI Payment</h2>" in html
assert "Community identifier" not in html