Commit 247c7fea authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Automatically fill slugs

parent cc18b9bf
......@@ -798,7 +798,7 @@ class ProfessorMessage(models.Model):
except EmailTemplate.DoesNotExist:
et = EmailTemplate(name="professor-message", subject="{{subject}}", template="{{message|safe}}")
if settings.MULTILINGUAL_EMAIL_SEND:
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']
......
......@@ -86,6 +86,18 @@ class CourseViewSet(viewsets.ModelViewSet):
def post(self, request, **kwargs):
course = self.get_object()
from django.conf import settings
if settings.I18N_SUPPORT:
update_slug = request.data.get('slug', '')
if not course.slug_en:
course.slug_en = update_slug
if not course.slug_es:
course.slug_es = update_slug
if not course.slug_pt_br:
course.slug_pt_br = update_slug
serializer = CourseSerializer(course, request.data)
if serializer.is_valid():
......
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