Merge pull request #15952 from edx/McKenzieW/learner-1994
Added language field to certificate template
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
"""
|
||||
django admin pages for certificates models
|
||||
"""
|
||||
from operator import itemgetter
|
||||
|
||||
from config_models.admin import ConfigurationModelAdmin
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
|
||||
from certificates.models import (
|
||||
@@ -28,6 +31,12 @@ class CertificateTemplateForm(forms.ModelForm):
|
||||
self.fields['organization_id'] = forms.TypedChoiceField(
|
||||
choices=org_choices, required=False, coerce=int, empty_value=None
|
||||
)
|
||||
languages = settings.CERTIFICATE_TEMPLATE_LANGUAGES.items()
|
||||
lang_choices = sorted(languages, key=itemgetter(1))
|
||||
lang_choices.insert(0, (None, 'All Languages'))
|
||||
self.fields['language'] = forms.ChoiceField(
|
||||
choices=lang_choices, required=False
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
model = CertificateTemplate
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('certificates', '0009_certificategenerationcoursesetting_language_self_generation'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='certificatetemplate',
|
||||
name='language',
|
||||
field=models.CharField(help_text='Only certificates for courses in the selected language will be rendered using this template. Course language is determined by the first two letters of the language code.', max_length=2, null=True, blank=True),
|
||||
),
|
||||
]
|
||||
@@ -1050,6 +1050,12 @@ class CertificateTemplate(TimeStampedModel):
|
||||
help_text=_(u'On/Off switch.'),
|
||||
default=False,
|
||||
)
|
||||
language = models.CharField(
|
||||
max_length=2,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=u'Only certificates for courses in the selected language will be rendered using this template. Course language is determined by the first two letters of the language code.'
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s' % (self.name, )
|
||||
|
||||
@@ -329,6 +329,7 @@ TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE)
|
||||
|
||||
# Translation overrides
|
||||
LANGUAGES = ENV_TOKENS.get('LANGUAGES', LANGUAGES)
|
||||
CERTIFICATE_TEMPLATE_LANGUAGES = ENV_TOKENS.get('CERTIFICATE_TEMPLATE_LANGUAGES', CERTIFICATE_TEMPLATE_LANGUAGES)
|
||||
LANGUAGE_DICT = dict(LANGUAGES)
|
||||
LANGUAGE_CODE = ENV_TOKENS.get('LANGUAGE_CODE', LANGUAGE_CODE)
|
||||
LANGUAGE_COOKIE = ENV_TOKENS.get('LANGUAGE_COOKIE', LANGUAGE_COOKIE)
|
||||
|
||||
@@ -996,6 +996,9 @@ LANGUAGES = (
|
||||
|
||||
LANGUAGE_DICT = dict(LANGUAGES)
|
||||
|
||||
# Languages supported for custom course certificate templates
|
||||
CERTIFICATE_TEMPLATE_LANGUAGES = {}
|
||||
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user