Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Paweljong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
AlekSIS-App-Paweljong
Commits
d24d07e1
Verified
Commit
d24d07e1
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
IMplement sending of info mailing
parent
bc1202d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!9
Resolve "Info mailing"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/paweljong/models.py
+36
-2
36 additions, 2 deletions
aleksis/apps/paweljong/models.py
aleksis/apps/paweljong/templates/templated_email/info_mailing.email
+3
-0
3 additions, 0 deletions
...ps/paweljong/templates/templated_email/info_mailing.email
with
39 additions
and
2 deletions
aleksis/apps/paweljong/models.py
+
36
−
2
View file @
d24d07e1
...
...
@@ -8,10 +8,11 @@ from django.utils.translation import gettext_lazy as _
from
ckeditor.fields
import
RichTextField
from
django_iban.fields
import
IBANField
from
templated_email
import
send_templated_mail
from
aleksis.core.mixins
import
ExtensibleModel
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.util.core_helpers
import
generate_random_code
from
aleksis.core.util.core_helpers
import
generate_random_code
,
get_site_preferences
class
Terms
(
ExtensibleModel
):
...
...
@@ -26,12 +27,45 @@ class Terms(ExtensibleModel):
class
InfoMailing
(
ExtensibleModel
):
subject
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
"
subject
"
))
text
=
RichTextField
(
verbose_name
=
_
(
"
Text
"
))
reply_to
=
models
.
EmailField
(
verbose_name
=
_
(
"
Request replies to
"
),
blank
=
True
)
send_to_person
=
models
.
BooleanField
(
verbose_name
=
_
(
"
Send to registered person
"
),
default
=
True
)
send_to_guardians
=
models
.
BooleanField
(
verbose_name
=
_
(
"
Send to guardians
"
),
default
=
False
)
sent_to
=
models
.
ManyToManyField
(
Person
,
verbose_name
=
_
(
"
Sent to persons
"
),
related_name
=
"
received_info_mailings
"
,
editable
=
False
,
blank
=
True
)
def
__str__
(
self
)
->
str
:
return
self
.
subject
def
send
(
self
):
sent_to
=
self
.
sent_to
.
all
()
for
event
in
self
.
events
.
all
():
for
registration
in
event
.
registrations
:
if
registration
.
person
in
sent_to
:
continue
subject
=
self
.
subject
.
format
(
event
=
event
,
registration
=
registration
,
person
=
registration
.
person
)
body
=
self
.
text
.
format
(
event
=
event
,
registration
=
registration
,
person
=
registration
.
person
)
if
self
.
send_to_person
:
to
=
[
registration
.
person
.
email
]
if
self
.
send_to_guardians
:
cc
=
registration
.
person
.
guardians
.
values_list
(
"
email
"
,
flat
=
True
).
all
()
else
:
cc
=
[]
elif
self
.
send_to_guardians
:
to
=
registration
.
person
.
guardians
.
values_list
(
"
email
"
,
flat
=
True
).
all
()
cc
=
[]
sender
=
self
.
sender
or
get_site_preferences
()[
"
mail__address
"
]
reply_to
=
self
.
reply_to
or
sender
context
=
{
"
subject
"
:
subject
,
"
body
"
:
body
}
send_templated_email
(
template_name
=
"
info_mailing
"
,
context
=
context
,
from_email
=
sender
,
recipient_list
=
to
,
cc
=
cc
)
self
.
sent_to
.
add
(
self
.
registration
.
person
)
class
Event
(
ExtensibleModel
):
# Event details
...
...
@@ -153,7 +187,7 @@ class Voucher(ExtensibleModel):
class
EventRegistration
(
ExtensibleModel
):
event
=
models
.
ForeignKey
(
Event
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"
Event
"
))
event
=
models
.
ForeignKey
(
Event
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"
Event
"
)
,
related_name
=
"
registrations
"
)
person
=
models
.
ForeignKey
(
Person
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"
Person
"
))
date_registered
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
_
(
"
Registration date
"
))
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/paweljong/templates/templated_email/info_mailing.email
0 → 100644
+
3
−
0
View file @
d24d07e1
{% block subject %}{{ subject }}{% endblock %}
{% block html %}{{ body|safe }}{% endblock %}
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