Commit e002f970 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Merge branch 'develop' into 'master'

Change language priority

See merge request !65
parents 723afc54 28c20c5b
......@@ -101,6 +101,15 @@ class CourseCertificationViewSet(viewsets.ModelViewSet):
if not self.request.GET.get('user', False):
queryset = queryset.filter(course_student__user=self.request.user)
cert = queryset.first()
cs = cert.course_student
# Change receipt into certificate
if cs.get_current_class().user_can_certificate and cs.course_finished or \
cs.get_current_class().user_can_certificate_even_without_progress:
cert.type = 'certificate'
cert.save()
return queryset
......@@ -221,7 +230,7 @@ class CourseCertificationDetailView(DetailView):
certificate.course_student.finish_date.day,
certificate.course_student.finish_date.month,
certificate.course_student.finish_date.year
)
) if certificate.course_student.finish_date else 'xx/xx/xxxx'
workspace = context['cert_template'].workspace
w_name = workspace.name if workspace else ''
......
# Generated by Django 2.2.24 on 2021-06-29 13:48
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('courses', '0027_auto_20210514_0809'),
]
operations = [
migrations.AlterField(
model_name='course',
name='lang',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, choices=[('es', 'Spanish'), ('pt-br', 'Portuguese'), ('en', 'English')], default=('es', 'Spanish'), max_length=64), blank=True, null=True, size=None),
),
]
......@@ -799,15 +799,9 @@ class ProfessorMessage(models.Model):
et = EmailTemplate(name="professor-message", subject="{{subject}}", template="{{message|safe}}")
if settings.I18N_SUPPORT:
bcc_en = [u.email for u in self.users.all() if u.is_active and re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", u.email) and u.preferred_language == 'en']
bcc_es = [u.email for u in self.users.all() if u.is_active and re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", u.email) and u.preferred_language == 'es']
bcc_pt_br = [u.email for u in self.users.all() if u.is_active and re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", u.email) and u.preferred_language == 'pt-br']
subject_en = self.subject_en or self.subject
message_en = self.message_en or self.message
subject_en = Template(et.subject).render(Context({'subject': subject_en}))
message_en = Template(et.template).render(Context({'message': message_en}))
self.send_emails(bcc_en, message_en, subject_en, email_batch_size)
bcc_en = [u.email for u in self.users.all() if u.is_active and re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", u.email) and u.preferred_language == 'en']
subject_es = self.subject_es or self.subject
message_es = self.message_es or self.message
......@@ -820,6 +814,12 @@ class ProfessorMessage(models.Model):
subject_pt_br = Template(et.subject).render(Context({'subject': subject_pt_br}))
message_pt_br = Template(et.template).render(Context({'message': message_pt_br}))
self.send_emails(bcc_pt_br, message_pt_br, subject_pt_br, email_batch_size)
subject_en = self.subject_en or self.subject
message_en = self.message_en or self.message
subject_en = Template(et.subject).render(Context({'subject': subject_en}))
message_en = Template(et.template).render(Context({'message': message_en}))
self.send_emails(bcc_en, message_en, subject_en, email_batch_size)
else:
bcc = [u.email for u in self.users.all() if u.is_active and re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", u.email)]
subject = Template(et.subject).render(Context({'subject': self.subject}))
......
......@@ -72,7 +72,7 @@ class CourseSerializer(serializers.ModelSerializer):
return {}
def get_ct_id(self, obj):
ct = CertificateTemplate.objects.filter(course=obj).first()
ct = CertificateTemplate.objects.filter(course=obj, document_type='certificate').first()
if ct:
return ct.id
return None
......
......@@ -70,7 +70,7 @@ class CourseViewSet(viewsets.ModelViewSet):
#)
from django.utils.translation import get_language
current_language = get_language()
query = Q(Q(status='published', lang__contains=[current_language]) | Q(groups__in=self.request.user.groups.all()))
query = Q(status='published', lang__contains=[current_language])
if (CourseProfessor.objects.filter(user=self.request.user, role='coordinator').exists()):
query.add(Q(
......
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