Commit f174c15c authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch '541-add-language-to-summary-data' into 'master'

Add language to summary data

Closes #541

See merge request !1060
parents 884bf8d3 02ff4694
......@@ -25,11 +25,11 @@ class CourseAdmin(TranslatedModelAdmin):
@admin.register(models.Exam)
class ExamAdmin(TranslatedModelAdmin):
list_display = ('type', 'course', 'exam_date', 'uploader',
'accepted', 'download_count')
'accepted', 'language', 'download_count')
readonly_fields = ('download_count',)
list_filter = ('accepted', 'exam_date', 'type',)
list_filter = ('accepted', 'exam_date', 'type', 'language')
search_fields = ('name', 'uploader__first_name', 'uploader__last_name',
'course__name_nl', 'course__name_en',)
'course__name_nl', 'course__name_en')
actions = ['accept', 'reject', 'reset_download_count', 'download_csv']
def accept(self, request, queryset):
......@@ -68,9 +68,10 @@ class ExamAdmin(TranslatedModelAdmin):
@admin.register(models.Summary)
class SummaryAdmin(TranslatedModelAdmin):
list_display = ('name', 'course', 'uploader', 'accepted', 'download_count')
list_display = ('name', 'course', 'uploader', 'accepted', 'language',
'download_count')
readonly_fields = ('download_count',)
list_filter = ('accepted',)
list_filter = ('accepted', 'language')
search_fields = ('name', 'uploader__first_name', 'uploader__last_name',
'course__name_nl', 'course__name_en',)
actions = ['accept', 'reject', 'reset_download_count', 'download_csv']
......
# Generated by Django 2.1.4 on 2018-12-19 20:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('education', '0008_auto_20180516_1935'),
]
operations = [
migrations.AddField(
model_name='exam',
name='language',
field=models.CharField(choices=[('en', 'English'), ('nl', 'Dutch')], max_length=2, null=True),
),
migrations.AddField(
model_name='summary',
name='language',
field=models.CharField(choices=[('en', 'English'), ('nl', 'Dutch')], max_length=2, null=True),
),
]
......@@ -5,6 +5,7 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from members.models import Member
from thaliawebsite.settings import settings
from utils.snippets import datetime_to_lectureyear
from utils.translation import ModelTranslateMeta, MultilingualField
......@@ -138,6 +139,13 @@ class Exam(models.Model, metaclass=ModelTranslateMeta):
on_delete=models.CASCADE,
)
language = models.CharField(
max_length=2,
choices=settings.LANGUAGES,
blank=False,
null=True
)
download_count = models.IntegerField(
verbose_name=_('amount of downloads'),
default=0,
......@@ -204,6 +212,13 @@ class Summary(models.Model, metaclass=ModelTranslateMeta):
'the file for inspection.')
)
language = models.CharField(
max_length=2,
choices=settings.LANGUAGES,
blank=False,
null=True
)
download_count = models.IntegerField(
verbose_name=_('amount of downloads'),
default=0,
......
img.lang-flag {
vertical-align: middle;
width: 20px;
}
{% extends 'education/base.html' %}
{% load i18n %}
{% load i18n static %}
{% block title %}{{ course.name }} — {% trans "Course" %} —
{{ block.super }}{% endblock %}
......@@ -61,7 +61,12 @@
{% for item in data.exams %}
<li>
<a href="{% url 'education:exam' item.id %}"
target="_blank">{{ item.name }}</a>
target="_blank">
{{ item.name }}
{% if item.language != '' %}
<img class="lang-flag" src="{% static 'img/flags/'|add:item.language|add:'.svg' %}"/>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
......@@ -75,6 +80,9 @@
<a href="{% url 'education:summary' item.id %}"
target="_blank">
{{ item.name }}
{% if item.language != '' %}
<img class="lang-flag" src="{% static 'img/flags/'|add:item.language|add:'.svg' %}"/>
{% endif %}
</a>
</li>
{% endfor %}
......
......@@ -64,6 +64,7 @@ def course(request, id):
items[summary.year]['summaries'].append({
"year": summary.year,
"name": f'{ _("Summary") } { summary.name }',
"language": summary.language,
"id": summary.id
})
for exam in course.exam_set.filter(accepted=True):
......@@ -75,6 +76,7 @@ def course(request, id):
"type": "exam",
"year": exam.year, "name":
f"{ exam.get_type_display() } { exam.name }",
"language": exam.language,
"id": exam.id
})
......
......@@ -22,6 +22,7 @@
@import "../../members/static/members/css/style.scss";
@import "../../thabloid/static/thabloid/css/style.scss";
@import "../../pizzas/static/pizzas/css/style.scss";
@import "../../education/static/education/css/style.scss";
@import "./fontawesome/fontawesome.scss";
@import "./fontawesome/solid.scss";
......
......@@ -79,7 +79,7 @@
<a href="#lang" data-next="{{ redirect_to }}" data-lang="en"
data-href="{% url 'set_language' %}"
class="btn btn-link" id="language-switcher"><img
src="{% static 'img/flags/gb.svg' %}"/></a>
src="{% static 'img/flags/en.svg' %}"/></a>
{% else %}
<a href="#lang" data-next="{{ redirect_to }}" data-lang="nl"
data-href="{% url 'set_language' %}"
......
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