summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-09-02 09:38:33 -0600
committerluxagraf <sng@luxagraf.net>2018-09-02 09:38:33 -0600
commit140ee80f0fe1d1d48f67612c1389ca7c2fc94f71 (patch)
tree3d9a783baec079cdf6f82593dcbb5110ca63b88a
parent6925c8dcaf006b6d80c005672d7e2738f7af8b12 (diff)
changed admin featured image widget
-rw-r--r--app/jrnl/admin.py4
-rw-r--r--app/jrnl/templates/horizontal_select.html2
-rw-r--r--app/utils/static/image-loader.js6
-rw-r--r--app/utils/widgets.py1
4 files changed, 8 insertions, 5 deletions
diff --git a/app/jrnl/admin.py b/app/jrnl/admin.py
index e77b931..ac950df 100644
--- a/app/jrnl/admin.py
+++ b/app/jrnl/admin.py
@@ -15,7 +15,7 @@ class EntryAdmin(OSMGeoAdmin):
form = LGEntryForm
def render_change_form(self, request, context, *args, **kwargs):
- context['adminform'].form.fields['featured_image'].queryset = LuxImage.objects.all()[:50]
+ context['adminform'].form.fields['featured_image'].queryset = LuxImage.objects.all()[:200]
return super(EntryAdmin, self).render_change_form(request, context, *args, **kwargs)
def formfield_for_dbfield(self, db_field, **kwargs):
@@ -52,13 +52,13 @@ class EntryAdmin(OSMGeoAdmin):
'meta_description',
'template_name',
'enable_comments',
+ 'featured_image',
),
}),
('Extra', {
'fields': (
'field_notes',
'books',
- 'featured_image',
),
'classes': (
'collapse',
diff --git a/app/jrnl/templates/horizontal_select.html b/app/jrnl/templates/horizontal_select.html
index 4b0a2a1..61dcfd8 100644
--- a/app/jrnl/templates/horizontal_select.html
+++ b/app/jrnl/templates/horizontal_select.html
@@ -6,7 +6,7 @@
<ul{% if id %} id="{{ id }}_{{ index }}"{% endif %}>
{% endif %}
{% for option in options %}
- <li data-imageid="{{option.value}}">{% include option.template_name with widget=option %}</li>
+ <li data-imageid="{{option.value}}" data-loopcounter="{{forloop.parentloop.counter}}">{% include option.template_name with widget=option %}</li>
{% endfor %}
{% if group %}
</ul>
diff --git a/app/utils/static/image-loader.js b/app/utils/static/image-loader.js
index 2b0a281..0139f10 100644
--- a/app/utils/static/image-loader.js
+++ b/app/utils/static/image-loader.js
@@ -7,7 +7,10 @@ function add_images(){
if (featured_image) {
featured_image.querySelectorAll('li').forEach(function(element) {
- var cur = element.dataset.imageid
+ var cur = element.dataset.imageid;
+ var loop = element.dataset.loopcounter;
+ console.log(loop);
+ if (loop <= 100) {
if (cur != "") {
var request = new XMLHttpRequest();
request.open('GET', '/photos/luximage/data/admin/tn/'+cur+'/', true);
@@ -29,6 +32,7 @@ function add_images(){
};
request.send();
}
+ }
});
}
diff --git a/app/utils/widgets.py b/app/utils/widgets.py
index c038252..f4a7a4a 100644
--- a/app/utils/widgets.py
+++ b/app/utils/widgets.py
@@ -94,7 +94,6 @@ class ImageRadioSelect(forms.RadioSelect):
template_name = 'horizontal_select.html'
-
class AdminImageWidget(AdminFileWidget):
"""
A FileField Widget that displays an image instead of a file path