Commit 3fbe0cdb authored by Fernando Ribeiro's avatar Fernando Ribeiro
Browse files

#Feat: Add fields groups and default_class to ProfessorMessage model

parent 2a33019e
......@@ -648,8 +648,33 @@ class ProfessorMessage(models.Model):
verbose_name=_('Course'),
null=True,
)
groups = models.ManyToManyField(
Group,
verbose_name=_('groups'),
blank=True,
help_text=_('The Groups that can have access to this forum. If empty, there are no group restrictions.'),
related_name="courses",
)
default_class = models.ManyToManyField(
'Class',
models.SET_NULL,
verbose_name=_('Default Class'),
related_name='default_course',
null=True,
blank=True,
)
def send(self):
# bcc = list with all destinataries
# batch = bcc.split( constant )
# for each batch ->
# send message
# save status
# if it goes wrong
# split batch by 2 and try it again (binary search)
# check if everything is sent
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)]
try:
et = EmailTemplate.objects.get(name='professor-message')
......
......@@ -123,6 +123,7 @@ class ProfessorMessageSerializer(serializers.ModelSerializer):
course_slug = serializers.SerializerMethodField(read_only=True)
course_name = serializers.SerializerMethodField(read_only=True)
is_read = serializers.SerializerMethodField(read_only=True)
groups = self.context['request'].data.get('groups', None)
class Meta:
model = ProfessorMessage
......
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