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')
|
||||
|
||||
|
||||
0
kivi_cars/kivi_cars/__init__.py
Normal file
0
kivi_cars/kivi_cars/__init__.py
Normal file
16
kivi_cars/kivi_cars/asgi.py
Normal file
16
kivi_cars/kivi_cars/asgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for kivi_cars project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kivi_cars.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
22
kivi_cars/kivi_cars/urls.py
Normal file
22
kivi_cars/kivi_cars/urls.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""kivi_cars URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('emailer', include('emailer.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
16
kivi_cars/kivi_cars/wsgi.py
Normal file
16
kivi_cars/kivi_cars/wsgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for kivi_cars project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kivi_cars.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
22
kivi_cars/manage.py
Normal file
22
kivi_cars/manage.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kivi_cars.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user