dodawanie komentarzy
This commit is contained in:
parent
b2f2870fbe
commit
e5c92127ea
Binary file not shown.
Binary file not shown.
@ -17,7 +17,7 @@
|
||||
<!--================End Categories Banner Area =================-->
|
||||
|
||||
<!--================Register Area =================-->
|
||||
<form action="{% url 'login' %}" method="POST" enctype="multipart/form-data">
|
||||
<form action="{% url 'add_comment' user_name %}" method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.media }}
|
||||
{{ form.as_p }}
|
||||
|
@ -159,7 +159,7 @@
|
||||
<h3>Wolontariat</h3>
|
||||
</div>
|
||||
<ul>
|
||||
{% if wol_local%}
|
||||
{% if wol_local %}
|
||||
<input type="checkbox" id="wolontariat" name="wolontariat" Checked>
|
||||
{% else %}
|
||||
<input type="checkbox" id="wolontariat" name="wolontariat" >
|
||||
|
@ -162,6 +162,7 @@ def filter(request):
|
||||
'potrzebuje_local': potrzebuje_local,
|
||||
'usluga_local': usluga_local,
|
||||
'przedmiot_local': przedmiot_local,
|
||||
'wol_local': wol_local,
|
||||
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
@ -441,8 +442,10 @@ def user_profile(request, user_name):
|
||||
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
ocena = 5
|
||||
suma = 1
|
||||
|
||||
if Ocena.objects.filter(user_iden = user_prof.id).exists():
|
||||
ocena = 0
|
||||
suma = 0
|
||||
for ocena_j in oceny:
|
||||
print(ocena)
|
||||
ocena = ocena + ocena_j.ocena_jedn
|
||||
@ -450,6 +453,8 @@ def user_profile(request, user_name):
|
||||
ocena = ocena / suma
|
||||
ocena = ocena * 10
|
||||
ocena = int (ocena)
|
||||
else:
|
||||
ocena = 5
|
||||
context = {
|
||||
'all_product': all_product,
|
||||
'all_oceny': oceny,
|
||||
@ -459,12 +464,26 @@ def user_profile(request, user_name):
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
||||
def add_comment(request, user_name):
|
||||
if request.user.is_authenticated:
|
||||
User = get_user_model()
|
||||
user_prof = User.objects.filter(username=user_name).first()
|
||||
template = loader.get_template('homepage/add_comment.html')
|
||||
user_prof = User.objects.filter(email=user_name).first()
|
||||
if request.method == 'POST':
|
||||
volume_local = request.POST['volume']
|
||||
script_local = request.POST['script']
|
||||
instant = Ocena(
|
||||
user_iden = user_prof,
|
||||
comm = script_local,
|
||||
ocena_jedn = int(volume_local)*2,
|
||||
)
|
||||
instant.save()
|
||||
messages.success(request, 'Dodano komentarz')
|
||||
return redirect(user_profile, user_name)
|
||||
|
||||
context = {
|
||||
'user_name': user_name,
|
||||
|
||||
}
|
||||
template = loader.get_template('homepage/add_comment.html')
|
||||
return HttpResponse(template.render(context, request))
|
||||
else:
|
||||
return redirect(login)
|
||||
|
Loading…
Reference in New Issue
Block a user