create emailer version 1

This commit is contained in:
msosic97
2022-04-11 15:09:06 +02:00
parent 94c4245c8a
commit 37541f19a0
4850 changed files with 715130 additions and 0 deletions

View File

View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class EmailerConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'emailer'

View File

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View 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>

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,6 @@
from django.urls import path
from . import views
urlpatterns = [
path('/', views.index),
]

View 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')