Merge branch 'feature-ohlhafv-mail' into 'develop'
Feature ohlhafv mail See merge request vtmk/web2.0!103
This commit is contained in:
Binary file not shown.
+519
-504
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+526
-507
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
{% load i18n %}
|
||||
{% trans "Moikka" %} {{ challenge.victim }},
|
||||
|
||||
{{ challenge.challenger }} {% trans "on haastanut sinut oluenjuontimittelöön" %} {{ challenge.get_series_display }} {% trans "-sarjassa" %}!
|
||||
|
||||
{% trans "Muistattehan vahvistaa haasteen paikan päällä Smökissä torstaina 15.3" %}.
|
||||
|
||||
{% trans "Käy kurkkaamassa muutkin haasteet osoitteessa" %} {{ url }}
|
||||
@@ -8,6 +8,8 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import permission_required, login_required
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
import logging
|
||||
import requests
|
||||
@@ -16,6 +18,7 @@ from dealer.git import git
|
||||
from ohlhafv.models import OhlhafvChallenge
|
||||
from ohlhafv.forms import OhlhafvForm
|
||||
from ohlhafv.tables import OhlhafvTable
|
||||
from webapp.utils import send_email
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@@ -32,6 +35,21 @@ def ohlhafv_submit(request, *args, **kwargs):
|
||||
form = OhlhafvForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
challenge = form.instance
|
||||
email = form.cleaned_data.get('victim_email', '')
|
||||
|
||||
url = 'https://sika.sahkoinsinoorikilta.fi/ohlhafv/list'
|
||||
subject = _('Sinut on haastettu Øhlhäfviin!')
|
||||
|
||||
message = render_to_string(
|
||||
'ohlhafv:email.html', {
|
||||
'challenge': challenge,
|
||||
'url': url,
|
||||
}
|
||||
)
|
||||
send_email(email, subject, message)
|
||||
logging.debug(
|
||||
'Sent ohlhafv email to recipient <{}>'.format(email))
|
||||
else:
|
||||
pass
|
||||
return HttpResponseRedirect('/ohlhafv/list/')
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.core.mail import send_mail
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def month_from_now():
|
||||
|
||||
Reference in New Issue
Block a user