Compare commits

...

4 Commits

Author SHA1 Message Date
j
480cb4afe5 Merge remote-tracking branch 'camp/master' 2018-08-21 14:23:19 +02:00
root
ab74e95c41 more cleanups 2018-08-21 12:23:09 +00:00
j
823f763c98 teaser maxlength 2018-08-21 14:22:29 +02:00
root
ab7a4d3b99 cleanups 2018-08-21 10:47:35 +00:00
12 changed files with 57 additions and 10 deletions

View File

@ -193,3 +193,8 @@ label, button {
button {
background: #99999 !important;
}
p {
line-height: 1.3;
}

View File

@ -39,6 +39,20 @@ class ServerAdmin(admin.ModelAdmin):
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):
"""Users never need to enter a description on a gallery."""
@ -58,7 +72,7 @@ class ContentAdmin(admin.ModelAdmin):
raw_id_fields = ['photo']
inlines = [ContentParentsInline, FileInline, LinkInline]
formfield_overrides = {
models.TextField: {'widget': AdminMarkdownxWidget},
models.TextField: {'widget': MaxLengthAdminMarkdownxWidget},
}

View File

@ -114,7 +114,7 @@ class Content(models.Model):
if self.teaser:
value = markdownify(self.teaser)
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:
value = ''
return mark_safe(value)

View 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 + ')')
}
});
});

View File

@ -24,7 +24,7 @@
<li><a href="/about">ABOUT</a></li>
{% available_content as sections %}
{% for url, title in sections %}
<li><a href="{{url}}">{{title}}</a></li>
<li><a href="{{url}}index/">{{title}}</a></li>
{% endfor %}
<li><a href="/contact">CONTACT</a></li>
</ul>

View File

@ -16,7 +16,9 @@
<h4 class="sidebar-h4"> Past Events </h4>
{% include "event_preview.html" with events=past_events %}
{% endif %}
<a href="index/">more</a>
<a href="/events/index/">All Events</a>
<br>
<br>
</div>
</div>
{% endblock %}

View File

@ -33,6 +33,4 @@
</div>
{% endif %}
{% endfor %}
<br>
<br>
</div>

View File

@ -26,6 +26,9 @@
<h4 class="sidebar-h4"> Past Events </h4>
{% include "event_preview.html" with events=past_events %}
{% endif %}
<a href="/events/index/">All Events</a>
<br>
<br>
</div>
{% endblock %}

View File

@ -8,7 +8,9 @@
{% endfor %}
{% with section|lower|add:'_list' as section_list %}
{% if has_more_content %}
<a href="{% url section_list %}">more</a>
<a href="/{{section|lower}}/index/">All {{ section }}</a>
<br>
<br>
{% endif %}
{% endwith %}
</div>

View File

@ -27,6 +27,8 @@
<div class="small-6 medium-4 medium-offset-2 large-2 large-offset-2 columns">
{% if row.image_url %}
<a href="{{ row.get_absolute_url }}"> <img src="{{ row.image_url }}"> </a>
{% else %}
&nbsp;
{% endif %}
</div>
<div class="small-6 medium-4 end columns">

View File

@ -21,7 +21,9 @@
</div>
{% endfor %}
{% if more_content %}
<a href="index/">more</a>
<a href="/{{section|lower}}/index/">All {{ section }}</a>
<br>
<br>
{% endif %}
</div>
{% endif %}

View File

@ -135,6 +135,7 @@ def render_content(request, shortname, section, template, types):
return event(request)
else:
return section_index(request, section)
shortname = shortname.replace(' ', '_')
content = get_object_or_404(Content, shortname=shortname, type__name__in=types)
if not content.published and not request.user.is_staff:
raise Http404
@ -242,9 +243,9 @@ def redirect_index(request):
return redirect(reverse('index'))
def redirect_event(request):
shortname = request.GET.get('this')
shortname = request.GET.get('this').replace(' ', '_').lower()
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())
id = request.GET.get('id')
if id: