Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
3fbe0cdb
Commit
3fbe0cdb
authored
Jun 07, 2020
by
Fernando Ribeiro
Browse files
#Feat: Add fields groups and default_class to ProfessorMessage model
parent
2a33019e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
courses/models.py
courses/models.py
+25
-0
courses/serializers.py
courses/serializers.py
+1
-0
No files found.
courses/models.py
View file @
3fbe0cdb
...
...
@@ -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'
)
...
...
courses/serializers.py
View file @
3fbe0cdb
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment