Compare commits
4 Commits
89e0dfc0eb
...
480cb4afe5
Author | SHA1 | Date | |
---|---|---|---|
480cb4afe5 | |||
|
ab74e95c41 | ||
823f763c98 | |||
|
ab7a4d3b99 |
|
@ -193,3 +193,8 @@ label, button {
|
||||||
button {
|
button {
|
||||||
background: #99999 !important;
|
background: #99999 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,20 @@ class ServerAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
class MaxLengthAdminMarkdownxWidget(AdminMarkdownxWidget):
|
||||||
|
def get_context(self, name, value, attrs=None):
|
||||||
|
if name == 'teaser':
|
||||||
|
if not attrs:
|
||||||
|
attrs = {}
|
||||||
|
attrs['maxlength'] = 250
|
||||||
|
print(dir(self))
|
||||||
|
return super(MaxLengthAdminMarkdownxWidget, self).get_context(name, value, attrs)
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = (
|
||||||
|
'js/maxlength_count.js',
|
||||||
|
)
|
||||||
|
|
||||||
class GalleryAdminForm(forms.ModelForm):
|
class GalleryAdminForm(forms.ModelForm):
|
||||||
"""Users never need to enter a description on a gallery."""
|
"""Users never need to enter a description on a gallery."""
|
||||||
|
|
||||||
|
@ -58,7 +72,7 @@ class ContentAdmin(admin.ModelAdmin):
|
||||||
raw_id_fields = ['photo']
|
raw_id_fields = ['photo']
|
||||||
inlines = [ContentParentsInline, FileInline, LinkInline]
|
inlines = [ContentParentsInline, FileInline, LinkInline]
|
||||||
formfield_overrides = {
|
formfield_overrides = {
|
||||||
models.TextField: {'widget': AdminMarkdownxWidget},
|
models.TextField: {'widget': MaxLengthAdminMarkdownxWidget},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Content(models.Model):
|
||||||
if self.teaser:
|
if self.teaser:
|
||||||
value = markdownify(self.teaser)
|
value = markdownify(self.teaser)
|
||||||
elif self.header:
|
elif self.header:
|
||||||
value = ox.strip_tags(ox.decode_html(markdownify(self.header)))[:100]
|
value = ox.sanitize_html(ox.decode_html(markdownify(self.header)))
|
||||||
else:
|
else:
|
||||||
value = ''
|
value = ''
|
||||||
return mark_safe(value)
|
return mark_safe(value)
|
||||||
|
|
18
content/static/js/maxlength_count.js
Normal file
18
content/static/js/maxlength_count.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
django.jQuery(function() {
|
||||||
|
django.jQuery('textarea[maxlength]').each(function(i, textarea) {
|
||||||
|
var t = django.jQuery(textarea),
|
||||||
|
count = t.parent().find('.maxlength-count')
|
||||||
|
if (count.length == 0) {
|
||||||
|
count = django.jQuery('<div>', {'class': 'maxlength-count'} ).insertAfter(t)
|
||||||
|
t.on({
|
||||||
|
keydown: update,
|
||||||
|
change: update,
|
||||||
|
drop: update,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function update() {
|
||||||
|
var max = Math.round(t.attr('maxlength')), left = max - t.val().length
|
||||||
|
count.html(left + ' characters left. (max: ' + max + ')')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -24,7 +24,7 @@
|
||||||
<li><a href="/about">ABOUT</a></li>
|
<li><a href="/about">ABOUT</a></li>
|
||||||
{% available_content as sections %}
|
{% available_content as sections %}
|
||||||
{% for url, title in sections %}
|
{% for url, title in sections %}
|
||||||
<li><a href="{{url}}">{{title}}</a></li>
|
<li><a href="{{url}}index/">{{title}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li><a href="/contact">CONTACT</a></li>
|
<li><a href="/contact">CONTACT</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
<h4 class="sidebar-h4"> Past Events </h4>
|
<h4 class="sidebar-h4"> Past Events </h4>
|
||||||
{% include "event_preview.html" with events=past_events %}
|
{% include "event_preview.html" with events=past_events %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="index/">more</a>
|
<a href="/events/index/">All Events</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -33,6 +33,4 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
<h4 class="sidebar-h4"> Past Events </h4>
|
<h4 class="sidebar-h4"> Past Events </h4>
|
||||||
{% include "event_preview.html" with events=past_events %}
|
{% include "event_preview.html" with events=past_events %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a href="/events/index/">All Events</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% with section|lower|add:'_list' as section_list %}
|
{% with section|lower|add:'_list' as section_list %}
|
||||||
{% if has_more_content %}
|
{% if has_more_content %}
|
||||||
<a href="{% url section_list %}">more</a>
|
<a href="/{{section|lower}}/index/">All {{ section }}</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
<div class="small-6 medium-4 medium-offset-2 large-2 large-offset-2 columns">
|
<div class="small-6 medium-4 medium-offset-2 large-2 large-offset-2 columns">
|
||||||
{% if row.image_url %}
|
{% if row.image_url %}
|
||||||
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="small-6 medium-4 end columns">
|
<div class="small-6 medium-4 end columns">
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if more_content %}
|
{% if more_content %}
|
||||||
<a href="index/">more</a>
|
<a href="/{{section|lower}}/index/">All {{ section }}</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -135,6 +135,7 @@ def render_content(request, shortname, section, template, types):
|
||||||
return event(request)
|
return event(request)
|
||||||
else:
|
else:
|
||||||
return section_index(request, section)
|
return section_index(request, section)
|
||||||
|
shortname = shortname.replace(' ', '_')
|
||||||
content = get_object_or_404(Content, shortname=shortname, type__name__in=types)
|
content = get_object_or_404(Content, shortname=shortname, type__name__in=types)
|
||||||
if not content.published and not request.user.is_staff:
|
if not content.published and not request.user.is_staff:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
@ -242,9 +243,9 @@ def redirect_index(request):
|
||||||
return redirect(reverse('index'))
|
return redirect(reverse('index'))
|
||||||
|
|
||||||
def redirect_event(request):
|
def redirect_event(request):
|
||||||
shortname = request.GET.get('this')
|
shortname = request.GET.get('this').replace(' ', '_').lower()
|
||||||
if shortname:
|
if shortname:
|
||||||
content = get_object_or_404(Content, shortname=shortname)
|
content = get_object_or_404(Content, shortname__iexact=shortname)
|
||||||
return redirect(content.get_absolute_url())
|
return redirect(content.get_absolute_url())
|
||||||
id = request.GET.get('id')
|
id = request.GET.get('id')
|
||||||
if id:
|
if id:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user