Commit 288ae948 by McKenzie Welter

Added language field to certificate template

parent 51beb277
""" """
django admin pages for certificates models django admin pages for certificates models
""" """
from operator import itemgetter
from config_models.admin import ConfigurationModelAdmin from config_models.admin import ConfigurationModelAdmin
from django import forms from django import forms
from django.conf import settings
from django.contrib import admin from django.contrib import admin
from certificates.models import ( from certificates.models import (
...@@ -28,6 +31,12 @@ class CertificateTemplateForm(forms.ModelForm): ...@@ -28,6 +31,12 @@ class CertificateTemplateForm(forms.ModelForm):
self.fields['organization_id'] = forms.TypedChoiceField( self.fields['organization_id'] = forms.TypedChoiceField(
choices=org_choices, required=False, coerce=int, empty_value=None 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): class Meta(object):
model = CertificateTemplate model = CertificateTemplate
......
# -*- 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): ...@@ -1050,6 +1050,12 @@ class CertificateTemplate(TimeStampedModel):
help_text=_(u'On/Off switch.'), help_text=_(u'On/Off switch.'),
default=False, 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): def __unicode__(self):
return u'%s' % (self.name, ) return u'%s' % (self.name, )
......
...@@ -329,6 +329,7 @@ TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE) ...@@ -329,6 +329,7 @@ TIME_ZONE = ENV_TOKENS.get('TIME_ZONE', TIME_ZONE)
# Translation overrides # Translation overrides
LANGUAGES = ENV_TOKENS.get('LANGUAGES', LANGUAGES) LANGUAGES = ENV_TOKENS.get('LANGUAGES', LANGUAGES)
CERTIFICATE_TEMPLATE_LANGUAGES = ENV_TOKENS.get('CERTIFICATE_TEMPLATE_LANGUAGES', CERTIFICATE_TEMPLATE_LANGUAGES)
LANGUAGE_DICT = dict(LANGUAGES) LANGUAGE_DICT = dict(LANGUAGES)
LANGUAGE_CODE = ENV_TOKENS.get('LANGUAGE_CODE', LANGUAGE_CODE) LANGUAGE_CODE = ENV_TOKENS.get('LANGUAGE_CODE', LANGUAGE_CODE)
LANGUAGE_COOKIE = ENV_TOKENS.get('LANGUAGE_COOKIE', LANGUAGE_COOKIE) LANGUAGE_COOKIE = ENV_TOKENS.get('LANGUAGE_COOKIE', LANGUAGE_COOKIE)
......
...@@ -996,6 +996,9 @@ LANGUAGES = ( ...@@ -996,6 +996,9 @@ LANGUAGES = (
LANGUAGE_DICT = dict(LANGUAGES) LANGUAGE_DICT = dict(LANGUAGES)
# Languages supported for custom course certificate templates
CERTIFICATE_TEMPLATE_LANGUAGES = {}
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
......
Markdown is supported
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