Browse Source

HOT-FIX: ajuste no crud

- inclui leitura customizada da origem do layouts.yaml
- corrige classes css em crud/detail.html
- ajusta leitura de hook field
pull/3372/head
Leandro Roberto 4 years ago
parent
commit
db3103a433
  1. 5
      sapl/crispy_layout_mixin.py
  2. 27
      sapl/crud/base.py
  3. 6
      sapl/templates/crud/detail.html

5
sapl/crispy_layout_mixin.py

@ -190,8 +190,9 @@ class CrispyLayoutFormMixin:
return getattr(obj.model,
obj.model_set).field.model.__name__
def get_layout(self):
yaml_layout = '%s/layouts.yaml' % self.model._meta.app_config.label
def get_layout(self, yaml_layout=None):
if not yaml_layout:
yaml_layout = '%s/layouts.yaml' % self.model._meta.app_config.label
return read_layout_from_yaml(yaml_layout, self.layout_key)
def get_layout_set(self):

27
sapl/crud/base.py

@ -467,18 +467,21 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView):
break
ss = ''
if m:
ss = get_field_display(m, n[-1])[1]
ss = (
('<br>' if '<ul>' in ss else ' - ') + ss)\
if ss and j != 0 and s else ss
hook = 'hook_{}'.format(''.join(n))
if hasattr(self, hook):
hs, url = getattr(self, hook)(obj, ss, url)
s += str(hs)
else:
s += ss
try:
if m:
ss = get_field_display(m, n[-1])[1]
ss = (
('<br>' if '<ul>' in ss else ' - ') + ss)\
if ss and j != 0 and s else ss
except:
pass
finally:
hook = 'hook_{}'.format(''.join(n))
if hasattr(self, hook):
hs, url = getattr(self, hook)(obj, ss, url)
s += str(hs)
else:
s += ss
r.append((s, url))
return r

6
sapl/templates/crud/detail.html

@ -3,7 +3,7 @@
{% block base_content %}
<div class="context-actions clearfix">
<div class="d-flex context-actions justify-content-between align-items-center">
{% block actions %}
{% block sub_actions %}
@ -35,7 +35,7 @@
{% block extra_actions %}
{% endblock extra_actions %}
<div class="editons float-right">
<div class="editons">
{% block editions %}
{% if view.update_url or view.delete_url %}
<div class="actions btn-group" role="group">
@ -84,7 +84,7 @@
src="https://www.youtube.com/embed/{{ column.text|youtube_id }}"
frameborder="0"></iframe>
{% elif column.text|facebook_url %}
<div class="fb-video" data-href="{{ column.text|safe }}"
<div class="fb-video" data-href="{{ column.text|safe }}"
data-width="420" data-show-text="false">
</div>
{% elif column.text|url %}

Loading…
Cancel
Save