diff --git a/course/api/serializers.py b/course/api/serializers.py
index 8bcf8b9a9..ced3ca3f5 100644
--- a/course/api/serializers.py
+++ b/course/api/serializers.py
@@ -129,6 +129,7 @@ class Meta(AplusModelSerializer.Meta):
'title',
'audience',
'publish',
+ 'language',
'body',
'pin',
)
diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po
index 02ef6a4c3..149f58109 100644
--- a/locale/en/LC_MESSAGES/django.po
+++ b/locale/en/LC_MESSAGES/django.po
@@ -5374,6 +5374,10 @@ msgstr "news items"
msgid "ADD_NEWS_ITEM"
msgstr "Add news item"
+#: news/templates/news/edit.html news/templates/news/list.html
+msgid "REMOVE_SELECTED_NEWS_ITEMS"
+msgstr "Remove selected news items"
+
#: news/templates/news/list.html
msgid "NEWS"
msgstr "News"
diff --git a/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po
index 2d158b495..df79ebf48 100644
--- a/locale/fi/LC_MESSAGES/django.po
+++ b/locale/fi/LC_MESSAGES/django.po
@@ -5394,6 +5394,10 @@ msgstr "uutiset"
msgid "ADD_NEWS_ITEM"
msgstr "Lisää uutinen"
+#: news/templates/news/edit.html news/templates/news/list.html
+msgid "REMOVE_SELECTED_NEWS_ITEMS"
+msgstr "Poista valitut uutiset"
+
#: news/templates/news/list.html
msgid "NEWS"
msgstr "Uutiset"
diff --git a/news/cache.py b/news/cache.py
index 31bbd1315..fad26e045 100644
--- a/news/cache.py
+++ b/news/cache.py
@@ -18,12 +18,14 @@ def _generate_data(self, instance, data=None): # pylint: disable=arguments-diffe
'id': item.id,
'audience': item.audience,
'publish': item.publish,
+ 'language': item.language,
'title': item.title,
'body': item.body,
'pin': item.pin,
}
for item in instance.news.all()
]
+
return {
'news': news,
}
diff --git a/news/forms.py b/news/forms.py
index 7116d9c94..f4a07e02b 100644
--- a/news/forms.py
+++ b/news/forms.py
@@ -23,6 +23,7 @@ class Meta:
'pin',
'email_students',
'email_staff',
+ 'language',
'title',
'body',
]
diff --git a/news/migrations/0005_news_language.py b/news/migrations/0005_news_language.py
new file mode 100644
index 000000000..6b0593d89
--- /dev/null
+++ b/news/migrations/0005_news_language.py
@@ -0,0 +1,28 @@
+# Generated by Django 4.2.11 on 2024-03-20 07:50
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("news", "0004_auto_20210812_1536"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="news",
+ name="language",
+ field=models.CharField(
+ choices=[
+ ("-", "All"),
+ ("en", "English"),
+ ("fi", "Finnish"),
+ ("sv", "Swedish"),
+ ],
+ default="-",
+ max_length=30,
+ verbose_name="LANGUAGE",
+ ),
+ ),
+ ]
diff --git a/news/models.py b/news/models.py
index d99d16f28..713a58929 100644
--- a/news/models.py
+++ b/news/models.py
@@ -1,6 +1,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
+from aplus import settings
from course.models import CourseInstance
from lib.models import UrlMixin
@@ -21,6 +22,11 @@ class News(models.Model, UrlMixin):
verbose_name=_('LABEL_PUBLISH'),
default=timezone.now,
)
+ language = models.CharField(
+ verbose_name=_('LANGUAGE'),
+ max_length=30,
+ choices=([('-', 'All')] + settings.LANGUAGES), default='-',
+ )
title = models.CharField(
verbose_name=_('LABEL_TITLE'),
max_length=255,
@@ -39,7 +45,7 @@ class Meta:
ordering = ['course_instance', '-pin', '-publish']
def __str__(self):
- return "{} {}".format(str(self.publish), self.title)
+ return "{} {} {}".format(str(self.publish), self.title, str(self.language))
def get_url_kwargs(self):
return dict(news_id=self.id, **self.course_instance.get_url_kwargs()) # pylint: disable=use-dict-literal
diff --git a/news/templates/news/list.html b/news/templates/news/list.html
index 7cccc0546..7c81524df 100644
--- a/news/templates/news/list.html
+++ b/news/templates/news/list.html
@@ -15,14 +15,21 @@
{% translate "SELECT" %} | {% translate "PUBLISH" %} | {% translate "AUDIENCE" %} | {% translate "TITLE" %} | +{% translate "LANGUAGE" %} |
---|
diff --git a/news/templates/news/user_news.html b/news/templates/news/user_news.html index 7f405096f..568a2bd83 100644 --- a/news/templates/news/user_news.html +++ b/news/templates/news/user_news.html @@ -1,6 +1,6 @@ {% load i18n %} {% load news %} - +{% load course %} {% if news %}
+ {{ item.body|safe }} +
- {{ item.body|safe }} -
-