This commit is contained in:
Jędrzej Klepacki 2021-01-15 20:14:34 +01:00
parent f6d68449b2
commit d2def4ec0b
10 changed files with 197 additions and 5 deletions

View File

@ -12,7 +12,7 @@
</tr> </tr>
{% for offer in all_Notificationoffer %} {% for offer in all_Notificationoffer %}
<tr> <tr>
<th><a href="/homepage/offer_details/{{offer.user_iden.id}}">{{offer.id}}</a></th> <th><a href="/homepage/offer_details/{{offer.user_iden.id}}">{{offer.user_iden.title}}</a></th>
<th>{{offer.text}}</th> <th>{{offer.text}}</th>
<th>{{offer.date}}</th> <th>{{offer.date}}</th>
<th><a href="DeleteOffer/{{offer.user_iden.id}}">Usuń</a></th> <th><a href="DeleteOffer/{{offer.user_iden.id}}">Usuń</a></th>

View File

@ -46,7 +46,11 @@
</div> </div>
<div class="contact_form_inner"> <div class="contact_form_inner">
<h3>Wyślij wiadomość</h3> <h3>Wyślij wiadomość</h3>
<form class="contact_us_form row" action="contact_process.php" method="post" id="contactForm" novalidate="novalidate"> <form action="{% url 'contact' %}" method="POST" enctype="multipart/form-data" class="contact_us_form row">
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<input type="text" class="form-control" id="name" name="name" placeholder="Imię i nazwisko"> <input type="text" class="form-control" id="name" name="name" placeholder="Imię i nazwisko">
</div> </div>
@ -57,7 +61,7 @@
<textarea class="form-control" name="message" id="message" rows="1" placeholder="Napisz wiadomość..."></textarea> <textarea class="form-control" name="message" id="message" rows="1" placeholder="Napisz wiadomość..."></textarea>
</div> </div>
<div class="form-group col-lg-12"> <div class="form-group col-lg-12">
<button type="submit" value="submit" class="btn update_btn form-control">Wyślij wiadomość</button> <input type="submit" class="btn update_btn form-control" value="Wyślij wiadomość"></input>
</div> </div>
</form> </form>
</div> </div>

View File

@ -0,0 +1,59 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!DOCTYPE html>
<html lang="en">
<body>
<!--================Categories Banner Area =================-->
<section class="solid_banner_area">
<div class="container">
<div class="solid_banner_inner">
<h3>Zgłoś Oferte:</h3>
<h5>{{ offer.title }}</h5>
<h6>Użytkownika: <strong>{{ offer.user_iden }}</strong></h6>
</div>
</div>
</section>
<!--================End Categories Banner Area =================-->
<!--================Register Area =================-->
<form action="{% url 'offer_note' offer.id %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<input type="hidden" name="email" value="">
<input type="hidden" name="password" value="">
<section class="track_area p_100">
<div class="container">
<div class="track_inner">
<form class="track_form row">
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-10 col-md-8 col-lg-6">
<label for="name">Treść zgłoszenia: <span>*</span></label>
<textarea class="form-control" id="order" rows="3" name="script"></textarea>
</div>
</div>
</div>
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-10 col-md-8 col-lg-6">
<input type="submit" class="btn btn-primary update_btn" value="Dodaj Komentarz">
</div>
</div>
</div>
</form>
</div>
</div>
</section>
</form>
<!--================End Track Area =================-->
<!--================End Register Area =================-->
</body>
</html>
{% endblock %}

View File

@ -155,6 +155,9 @@
</div> </div>
</section> </section>
{% endif %} {% endif %}
<div class="col-lg-8">
<a href="/homepage/offer_note/{{offer.id}}"><button type="button" class="btn btn-danger pull-right">Zgłoś Oferte</button></a>
</div>
<script> <script>
function openCity(evt, cityName) { function openCity(evt, cityName) {
// Declare all variables // Declare all variables

View File

@ -0,0 +1,58 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!DOCTYPE html>
<html lang="en">
<body>
<!--================Categories Banner Area =================-->
<section class="solid_banner_area">
<div class="container">
<div class="solid_banner_inner">
<h3>Zgłoś Użytkownika:</h3>
<h5>{{ User_prof }}</h5>
</div>
</div>
</section>
<!--================End Categories Banner Area =================-->
<!--================Register Area =================-->
<form action="{% url 'user_note' User_prof.email %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<input type="hidden" name="email" value="">
<input type="hidden" name="password" value="">
<section class="track_area p_100">
<div class="container">
<div class="track_inner">
<form class="track_form row">
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-10 col-md-8 col-lg-6">
<label for="name">Treść zgłoszenia: <span>*</span></label>
<textarea class="form-control" id="order" rows="3" name="script"></textarea>
</div>
</div>
</div>
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-10 col-md-8 col-lg-6">
<input type="submit" class="btn btn-primary update_btn" value="Dodaj Komentarz">
</div>
</div>
</div>
</form>
</div>
</div>
</section>
</form>
<!--================End Track Area =================-->
<!--================End Register Area =================-->
</body>
</html>
{% endblock %}

View File

@ -188,6 +188,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-lg-8">
<a href="/homepage/user_note/{{name}}"><button type="button" class="btn btn-danger pull-right">Zgłoś Użytkownika</button></a>
</div>
</section> </section>
<!--================End Categories Product Area =================--> <!--================End Categories Product Area =================-->
</body> </body>

View File

@ -33,4 +33,7 @@ urlpatterns = [
path('user_profile/<str:user_name>', views.user_profile, name='user_profile'), path('user_profile/<str:user_name>', views.user_profile, name='user_profile'),
path('user_profile/<str:user_name>/add_comment', views.add_comment, name='add_comment'), path('user_profile/<str:user_name>/add_comment', views.add_comment, name='add_comment'),
path('offer_note/<int:offer_id>', views.offer_note, name='offer_note'),
path('user_note/<str:user_id>', views.user_note, name='user_note'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -10,6 +10,7 @@ from django.utils import timezone
from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.clickjacking import xframe_options_exempt
from django.db.models import Q from django.db.models import Q
from .models import Product, TYPE_T, TYPE_O, Places, Ocena, chat from .models import Product, TYPE_T, TYPE_O, Places, Ocena, chat
from control.models import Notificationuser, Notificationoffer, Usermessage, Vipuser
from django.utils import timezone from django.utils import timezone
from datetime import timedelta from datetime import timedelta
@ -83,6 +84,22 @@ def index_offer(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def contact(request): def contact(request):
if request.method == 'POST':
name = request.POST['name']
email = request.POST['email']
message = request.POST['message']
if name == "" and email == "" and message == "":
messages.error(request,'Pola tekstowe nie mogą być puste!')
return redirect('contact')
mess = Usermessage(
active = True,
name = name,
email = email,
text = message,
date = timezone.now()
)
mess.save()
messages.success(request, 'Wysłano wiadomość, dziękujemy!')
return render(request , 'homepage/contact.html') return render(request , 'homepage/contact.html')
def about(request): def about(request):
@ -623,3 +640,48 @@ def chating(request, offer_id, au_id, ad_id):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
else: else:
return redirect(login) return redirect(login)
def offer_note(request, offer_id):
offer = Product.objects.get(id = offer_id)
if request.method == 'POST':
text = request.POST['script']
if text == "":
messages.error(request,'Pola tekstowe nie mogą być puste!')
return redirect('offer_note', offer_id)
mess = Notificationoffer(
active = True,
user_iden = offer,
text = text,
date = timezone.now()
)
mess.save()
messages.success(request, 'Dziękujemy za zgłoszenie')
return redirect('offer', offer_id)
context = {
'offer': offer,
}
template = loader.get_template('homepage/offer_note.html')
return HttpResponse(template.render(context, request))
def user_note(request, user_id):
User = get_user_model()
get_user = User.objects.get(email = user_id)
if request.method == 'POST':
text = request.POST['script']
if text == "":
messages.error(request,'Pola tekstowe nie mogą być puste!')
return redirect('user_note', user_id)
mess = Notificationuser(
active = True,
user_iden = get_user,
text = text,
date = timezone.now()
)
mess.save()
messages.success(request, 'Dziękujemy za zgłoszenie')
return redirect('user_profile', user_id)
context = {
'User_prof': get_user,
}
template = loader.get_template('homepage/user_note.html')
return HttpResponse(template.render(context, request))