Skip to content

Commit f557415

Browse files
committed
fix module for complexblocks
1 parent f52d44e commit f557415

5 files changed

Lines changed: 26 additions & 9 deletions

File tree

streamfield/admin.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import json
2+
from importlib import import_module
23
from django.contrib import admin
34
from django.contrib.admin.options import TO_FIELD_VAR
45
from django.template.response import TemplateResponse
5-
from .settings import STREAMBLOCKS_MODELS
6+
from django.conf import settings
7+
8+
STREAMBLOCKS_APP_PATH = getattr(settings, "STREAMFIELD_STREAMBLOCKS_APP_PATH", "streamblocks")
9+
try:
10+
streamblocks_app = import_module("%s.models" % STREAMBLOCKS_APP_PATH)
11+
STREAMBLOCKS_MODELS = streamblocks_app.STREAMBLOCKS_MODELS
12+
except (AttributeError, ValueError) as e:
13+
raise Exception("""Can't find STREAMBLOCKS_MODELS: wrong "STREAMFIELD_STREAMBLOCKS_APP_PATH" or STREAMBLOCKS_MODELS don't exist.""")
614

715
class StreamBlocksAdmin(admin.ModelAdmin):
816
change_form_template = 'streamfield/admin/change_form.html'

streamfield/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.contrib.admin import ModelAdmin, site
33
from django.forms import ModelForm
44
from django.utils.functional import cached_property
5+
from django.utils.html import format_html_join
56
from django.template import loader
67
from django.utils.safestring import mark_safe
78

streamfield/settings.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,3 @@
33
from django.conf import settings
44

55
BLOCK_OPTIONS = getattr(settings, "STREAMFIELD_BLOCK_OPTIONS", {})
6-
STREAMBLOCKS_APP_PATH = getattr(settings, "STREAMFIELD_STREAMBLOCKS_APP_PATH", "streamblocks")
7-
8-
try:
9-
streamblocks_app = import_module("%s.models" % STREAMBLOCKS_APP_PATH)
10-
STREAMBLOCKS_MODELS = streamblocks_app.STREAMBLOCKS_MODELS
11-
except (AttributeError, ValueError) as e:
12-
raise Exception("""Can't find STREAMBLOCKS_MODELS: wrong "STREAMFIELD_STREAMBLOCKS_APP_PATH" or STREAMBLOCKS_MODELS don't exist.""")

streamfield/static/streamfield/css/streamfield_widget.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@
107107
font-weight: bold;
108108
}
109109

110+
.streamfield_app .block-fields svg,
111+
.streamfield_app .block-fields img
112+
{
113+
max-width: 150px;
114+
max-height: 150px;
115+
}
116+
110117
.streamfield_app .stream-model-subblock {
111118
background: #e0e7eb;
112119
padding: 10px;

streamfield/urls.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
from importlib import import_module
12
from django.urls import include, path
3+
from django.conf import settings
24

35
from . import views
4-
from .settings import STREAMBLOCKS_MODELS
6+
7+
STREAMBLOCKS_APP_PATH = getattr(settings, "STREAMFIELD_STREAMBLOCKS_APP_PATH", "streamblocks")
8+
try:
9+
streamblocks_app = import_module("%s.models" % STREAMBLOCKS_APP_PATH)
10+
STREAMBLOCKS_MODELS = streamblocks_app.STREAMBLOCKS_MODELS
11+
except (AttributeError, ValueError) as e:
12+
raise Exception("""Can't find STREAMBLOCKS_MODELS: wrong "STREAMFIELD_STREAMBLOCKS_APP_PATH" or STREAMBLOCKS_MODELS don't exist.""")
513

614
admin_instance_urls = []
715

0 commit comments

Comments
 (0)