Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
dd0f5827
Verified
Commit
dd0f5827
authored
Feb 03, 2018
by
Sébastiaan Versteeg
Browse files
Add automatic response to mailinglists
parent
af14f498
Changes
4
Hide whitespace changes
Inline
Side-by-side
website/mailinglists/api/serializers.py
View file @
dd0f5827
...
...
@@ -6,7 +6,8 @@ from mailinglists.models import MailingList
class
MailingListSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
MailingList
fields
=
(
'names'
,
'prefix'
,
'archived'
,
'moderated'
,
'addresses'
)
fields
=
(
'names'
,
'prefix'
,
'archived'
,
'moderated'
,
'addresses'
,
'autoresponse_enabled'
,
'autoresponse_text'
)
names
=
serializers
.
SerializerMethodField
(
'_names'
)
addresses
=
serializers
.
SerializerMethodField
(
'_addresses'
)
...
...
website/mailinglists/migrations/0012_auto_20180203_2304.py
0 → 100644
View file @
dd0f5827
# Generated by Django 2.0.2 on 2018-02-03 22:04
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'mailinglists'
,
'0011_auto_20171013_1419'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'mailinglist'
,
name
=
'autoresponse_enabled'
,
field
=
models
.
BooleanField
(
default
=
False
,
help_text
=
'Indicate whether emails will get an automatic response.'
,
verbose_name
=
'Automatic response enabled'
),
),
migrations
.
AddField
(
model_name
=
'mailinglist'
,
name
=
'autoresponse_text'
,
field
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'Autoresponse text'
),
),
]
website/mailinglists/models.py
View file @
dd0f5827
...
...
@@ -54,6 +54,18 @@ class MailingList(models.Model):
blank
=
True
,
)
autoresponse_enabled
=
models
.
BooleanField
(
verbose_name
=
_
(
"Automatic response enabled"
),
default
=
False
,
help_text
=
_
(
'Indicate whether emails will get an automatic response.'
)
)
autoresponse_text
=
models
.
TextField
(
verbose_name
=
_
(
"Autoresponse text"
),
null
=
True
,
blank
=
True
,
)
def
all_addresses
(
self
):
for
member
in
self
.
members
.
all
():
yield
member
.
email
...
...
@@ -78,6 +90,11 @@ class MailingList(models.Model):
}
})
if
not
self
.
autoresponse_text
and
self
.
autoresponse_enabled
:
raise
ValidationError
({
'autoresponse_text'
:
_
(
'Enter a text for the auto response.'
)
})
def
__str__
(
self
):
return
self
.
name
...
...
website/mailinglists/tests/test_models.py
View file @
dd0f5827
...
...
@@ -31,6 +31,15 @@ class MailingListTest(TestCase):
listalias
.
alias
=
"mailalias"
listalias
.
clean
()
def
test_autoresponse_has_text
(
self
):
self
.
mailinglist
.
autoresponse_enabled
=
True
with
self
.
assertRaises
(
ValidationError
):
self
.
mailinglist
.
clean
()
self
.
mailinglist
.
autoresponse_text
=
"Hello World"
self
.
mailinglist
.
clean
()
class
ListAliasTest
(
TestCase
):
"""Tests list aliases"""
...
...
Write
Preview
Supports
Markdown
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