Commit 7857a9e0 authored by Luuk Scholten's avatar Luuk Scholten
Browse files

Merge branch '384-add-linkify-to-anouncements' into 'master'

Add HTMLField for announcements

Closes #384 and #385

See merge request !484
parents 0a3e2216 dc83a6f2
from django.contrib import admin
from django.template.defaultfilters import striptags
from thaliawebsite.templatetags.bleach_tags import bleach
from utils.translation import TranslatedModelAdmin
from .models import Announcement
......@@ -7,7 +9,12 @@ from .models import Announcement
@admin.register(Announcement)
class AnnouncementAdmin(TranslatedModelAdmin):
list_display = ('content', 'since', 'until', 'visible')
list_display = ('content_html', 'since', 'until', 'visible')
def content_html(self, obj):
# Both bleach and striptags.
# First to convert HTML entities and second to strip all HTML
return bleach(striptags(obj.content))
def visible(self, obj):
return obj.is_visible
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-17 17:25
from __future__ import unicode_literals
from django.db import migrations
import tinymce.models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0002_auto_20170402_1339'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='content_en',
field=tinymce.models.HTMLField(help_text='The content of the announcement; what text to display.', max_length=500, verbose_name='Content (EN)'),
),
migrations.AlterField(
model_name='announcement',
name='content_nl',
field=tinymce.models.HTMLField(help_text='The content of the announcement; what text to display.', max_length=500, verbose_name='Content (NL)'),
),
]
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from tinymce.models import HTMLField
from utils.translation import ModelTranslateMeta, MultilingualField
class Announcement(models.Model, metaclass=ModelTranslateMeta):
content = MultilingualField(
models.CharField,
HTMLField,
verbose_name=_('Content'),
help_text=_('The content of the announcement; what text to display.'),
blank=False,
......
......@@ -9,4 +9,20 @@
.close {
color: #FFFFFF;
}
p {
display: inline;
margin-left: 5px;
}
a {
color: white;
text-decoration: underline;
}
a:hover {
color: #F0F0EE;
text-decoration: underline;
cursor: pointer;
}
}
{% load bleach_tags %}
{% for announcement in announcements %}
<div class='announcement'>
<i class="fa fa-{{ announcement.icon }}"></i> {{ announcement.content }}
<i class="fa fa-{{ announcement.icon }}"></i> {{ announcement.content|bleach }}
{% if announcement.closeable %}
<button type="button" class="close" aria-label="Close" data-announcement-id="{{ announcement.pk }}">
<span aria-hidden="true">&times;</span>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment