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

View File

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

View 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),
]

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