create emailer version 1
This commit is contained in:
0
kivi_cars/emailer/__init__.py
Normal file
0
kivi_cars/emailer/__init__.py
Normal file
3
kivi_cars/emailer/admin.py
Normal file
3
kivi_cars/emailer/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
kivi_cars/emailer/apps.py
Normal file
6
kivi_cars/emailer/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class EmailerConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'emailer'
|
||||
0
kivi_cars/emailer/migrations/__init__.py
Normal file
0
kivi_cars/emailer/migrations/__init__.py
Normal file
3
kivi_cars/emailer/models.py
Normal file
3
kivi_cars/emailer/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
19
kivi_cars/emailer/templates/mailer/form.html
Normal file
19
kivi_cars/emailer/templates/mailer/form.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Form</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<h1> Welcome to our form, please fill it!</h1>
|
||||
</h1>
|
||||
Email <br>
|
||||
<input type="email" name="email">
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
3
kivi_cars/emailer/tests.py
Normal file
3
kivi_cars/emailer/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
6
kivi_cars/emailer/urls.py
Normal file
6
kivi_cars/emailer/urls.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('/', views.index),
|
||||
]
|
||||
42
kivi_cars/emailer/views.py
Normal file
42
kivi_cars/emailer/views.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from django.core.mail import send_mail
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def index(request):
|
||||
if request.method == "POST":
|
||||
message = """Zdravo
|
||||
Naručili ste da Vam javimo ako se nekretnina sa navedenim uslovima pojavi u oglasima:
|
||||
|
||||
Tip : Auto
|
||||
Vrsta oglasa: Prodaja
|
||||
Cijena: 5000 do 35000 KM
|
||||
|
||||
U međuvremenu pogledajte neke od nedavno objavljenih nekretnina koje odgovaraju Vašim uslovima pretrage :
|
||||
|
||||
|
||||
|
||||
Molimo vas recite svojim prijateljima za Kivi - što više korisnika budemo imali, moći ćemo više agencija uključiti i više nekretnina imati u bazi. Hvala!
|
||||
|
||||
Trenutno ste prijavljeni da obavještenja o novim nekretninama primate odmah .
|
||||
Ako želite prestati dobijati obavještenja za ovu pretragu, odjavite ovdje
|
||||
Ako želite pogledati ili promijeniti uslove za ovu pretragu, pogledajte ovdje
|
||||
|
||||
Vaš,
|
||||
Kivi tim
|
||||
"""
|
||||
|
||||
subject = "Kivi-Cars - novi zahtjev za pretragu"
|
||||
email = request.POST.get('email')
|
||||
|
||||
print(subject, email)
|
||||
|
||||
# function to send mail
|
||||
send_mail(subject, message, 'saburlymailer@gmail.com', [email])
|
||||
|
||||
return HttpResponse('Success, check your email!')
|
||||
|
||||
return render(request, 'mailer/form.html')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user