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, return getattr(obj.model,
obj.model_set).field.model.__name__ obj.model_set).field.model.__name__
def get_layout(self): def get_layout(self, yaml_layout=None):
yaml_layout = '%s/layouts.yaml' % self.model._meta.app_config.label 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) return read_layout_from_yaml(yaml_layout, self.layout_key)
def get_layout_set(self): def get_layout_set(self):

27
sapl/crud/base.py

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

6
sapl/templates/crud/detail.html

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

Loading…
Cancel
Save