Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIF
AKPlanning
Commits
64ca9fd5
Commit
64ca9fd5
authored
2 years ago
by
Nadja Geisler
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature-mails' into 'main'
Introduce sending of mails Closes
#116
and
#117
See merge request
!116
parents
780f6b34
4a78bf7d
No related branches found
No related tags found
1 merge request
!116
Introduce sending of mails
Pipeline
#81893
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
AKPlanning/settings.py
+4
-0
4 additions, 0 deletions
AKPlanning/settings.py
AKPlanning/settings_production.py
+4
-0
4 additions, 0 deletions
AKPlanning/settings_production.py
AKSubmission/models.py
+42
-1
42 additions, 1 deletion
AKSubmission/models.py
with
50 additions
and
1 deletion
AKPlanning/settings.py
+
4
−
0
View file @
64ca9fd5
...
...
@@ -218,4 +218,8 @@ CSP_IMG_SRC = ("'self'", "data:")
CSP_FRAME_SRC
=
(
"'
self
'"
,
)
CSP_FONT_SRC
=
(
"'
self
'"
,
"
data:
"
,
"
fonts.gstatic.com
"
)
# Emails
SEND_MAILS
=
True
EMAIL_BACKEND
=
'
django.core.mail.backends.console.EmailBackend
'
include
(
optional
(
"
settings/*.py
"
))
This diff is collapsed.
Click to expand it.
AKPlanning/settings_production.py
+
4
−
0
View file @
64ca9fd5
...
...
@@ -35,4 +35,8 @@ DATABASES = {
}
}
### EMAILS ###
SEND_MAILS
=
True
EMAIL_BACKEND
=
'
django.core.mail.backends.smtp.EmailBackend
'
# TODO: caching
This diff is collapsed.
Click to expand it.
AKSubmission/models.py
+
42
−
1
View file @
64ca9fd5
# Create your models here.
from
django.apps
import
apps
from
django.conf
import
settings
from
django.core.mail
import
EmailMessage
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
django.urls
import
reverse_lazy
from
AKModel.models
import
AKOrgaMessage
,
AKSlot
@receiver
(
post_save
,
sender
=
AKOrgaMessage
)
def
orga_message_saved_handler
(
sender
,
instance
:
AKOrgaMessage
,
created
,
**
kwargs
):
# React to newly created Orga message by sending an email
if
created
and
settings
.
SEND_MAILS
:
host
=
'
https://
'
+
settings
.
ALLOWED_HOSTS
[
0
]
if
len
(
settings
.
ALLOWED_HOSTS
)
>
0
else
'
http://127.0.0.1:8000
'
url
=
f
"
{
host
}{
reverse_lazy
(
'
submit
:
ak_detail
'
, kwargs=
{
'
pk
'
:
instance
.
ak
.
pk
,
'
event_slug
'
:
instance
.
ak
.
event
.
slug
}
)
}
"
mail
=
EmailMessage
(
f
"
[AKPlanning] New message for AK
'
{
instance
.
ak
}
'
(
{
instance
.
ak
.
event
}
)
"
,
f
"
{
instance
.
text
}
\n\n
{
url
}
"
,
settings
.
DEFAULT_FROM_EMAIL
,
[
instance
.
ak
.
event
.
contact_email
]
)
mail
.
send
(
fail_silently
=
True
)
@receiver
(
post_save
,
sender
=
AKSlot
)
def
slot_created_handler
(
sender
,
instance
:
AKSlot
,
created
,
**
kwargs
):
# React to slots that are created after the plan was already published by sending an email
if
created
and
settings
.
SEND_MAILS
and
apps
.
is_installed
(
"
AKPlan
"
)
and
not
instance
.
event
.
plan_hidden
and
instance
.
room
is
None
and
instance
.
start
is
None
:
host
=
'
https://
'
+
settings
.
ALLOWED_HOSTS
[
0
]
if
len
(
settings
.
ALLOWED_HOSTS
)
>
0
else
'
http://127.0.0.1:8000
'
url
=
f
"
{
host
}{
reverse_lazy
(
'
submit
:
ak_detail
'
, kwargs=
{
'
pk
'
:
instance
.
ak
.
pk
,
'
event_slug
'
:
instance
.
ak
.
event
.
slug
}
)
}
"
mail
=
EmailMessage
(
f
"
[AKPlanning] New slot for AK
'
{
instance
.
ak
}
'
(
{
instance
.
ak
.
event
}
) added
"
,
f
"
New slot requested.
\n\n
AK:
{
instance
.
ak
}
\n
Duration:
{
instance
.
duration
}
\n\n
{
url
}
"
,
settings
.
DEFAULT_FROM_EMAIL
,
[
instance
.
ak
.
event
.
contact_email
]
)
mail
.
send
(
fail_silently
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment