Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandor4b committed Jun 7, 2024
2 parents 731fa0a + 26c5af9 commit 9e9ee4d
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 77 deletions.
3 changes: 1 addition & 2 deletions app_client/static/css/app_client/rating.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@
margin-bottom: 20px;
}

.starErrorContainer span {
.error-message {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
color: var(--red-600);
margin-top: 16px;
Expand Down
86 changes: 63 additions & 23 deletions app_client/templates/RequestOrder/rateservice.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,31 @@
{% if rating %}
<input type="hidden" name="edit_rating">
{% endif %}
<input type="hidden" name="attendance" id="attendance" value="{{ rating.attendance }}">
<input type="hidden" name="service" id="service" value="{{ rating.service }}">
<input type="hidden" name="time" id="time" value="{{ rating.time }}">

{% if rating.attendance %}
<input type="hidden" name="attendance" id="attendance" value="{{ rating.attendance }}">
{% elif rating.attendance and attendance %}
<input type="hidden" name="attendance" id="attendance" value="{{ attendance }}">
{% else %}
<input type="hidden" name="attendance" id="attendance" value="{{ attendance }}">
{% endif %}

{% if rating.service %}
<input type="hidden" name="service" id="service" value="{{ rating.service }}">
{% elif rating.service and service %}
<input type="hidden" name="service" id="service" value="{{ service }}">
{% else %}
<input type="hidden" name="service" id="service" value="{{ service }}">
{% endif %}

{% if rating.time %}
<input type="hidden" name="time" id="time" value="{{ rating.time }}">
{% elif rating.time and time %}
<input type="hidden" name="time" id="time" value="{{ time }}">
{% else %}
<input type="hidden" name="time" id="time" value="{{ time }}">
{% endif %}


<h1>Avaliação de serviço</h1>

Expand All @@ -26,7 +48,8 @@ <h1>Avaliação de serviço</h1>
<label>Atendimento:</label>
<div class="starErrorContainer">
<div class="ratingAttendance">
{% if rating.attendance >= 1 %}
{{ rating.attendance }}
{% if rating.attendance >= 1 or attendance >= 1 %}
<button type="button" class="attendance active">
{% else %}
<button type="button" class="attendance">
Expand All @@ -41,7 +64,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.attendance >= 2 %}
{% if rating.attendance >= 2 or attendance >= 2 %}
<button type="button" class="attendance active">
{% else %}
<button type="button" class="attendance">
Expand All @@ -56,7 +79,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.attendance >= 3 %}
{% if rating.attendance >= 3 or attendance >= 3 %}
<button type="button" class="attendance active">
{% else %}
<button type="button" class="attendance">
Expand All @@ -71,7 +94,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.attendance >= 4 %}
{% if rating.attendance >= 4 or attendance >= 4 %}
<button type="button" class="attendance active">
{% else %}
<button type="button" class="attendance">
Expand All @@ -86,7 +109,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.attendance >= 5 %}
{% if rating.attendance >= 5 or attendance >= 5 %}
<button type="button" class="attendance active">
{% else %}
<button type="button" class="attendance">
Expand All @@ -105,7 +128,7 @@ <h1>Avaliação de serviço</h1>

{% for error in errors %}
{% if error.field == 'attendance' %}
<span>
<span class="error-message">
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
Expand All @@ -118,7 +141,7 @@ <h1>Avaliação de serviço</h1>
<label>Serviço:</label>
<div class="starErrorContainer">
<div class="ratingService">
{% if rating.service >= 1 %}
{% if rating.service >= 1 or service >= 1 %}
<button type="button" class="service active">
{% else %}
<button type="button" class="service">
Expand All @@ -133,7 +156,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.service >= 2 %}
{% if rating.service >= 2 or service >= 2 %}
<button type="button" class="service active">
{% else %}
<button type="button" class="service">
Expand All @@ -148,7 +171,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.service >= 3 %}
{% if rating.service >= 3 or service >= 3 %}
<button type="button" class="service active">
{% else %}
<button type="button" class="service">
Expand All @@ -163,7 +186,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.service >= 4 %}
{% if rating.service >= 4 or service >= 4 %}
<button type="button" class="service active">
{% else %}
<button type="button" class="service">
Expand All @@ -178,7 +201,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.service >= 5 %}
{% if rating.service >= 5 or service >= 5 %}
<button type="button" class="service active">
{% else %}
<button type="button" class="service">
Expand All @@ -197,7 +220,7 @@ <h1>Avaliação de serviço</h1>

{% for error in errors %}
{% if error.field == 'service' %}
<span>
<span class="error-message">
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
Expand All @@ -210,7 +233,7 @@ <h1>Avaliação de serviço</h1>
<label>Tempo:</label>
<div class="starErrorContainer">
<div class="ratingTime">
{% if rating.time >= 1 %}
{% if rating.time >= 1 or time >= 1 %}
<button type="button" class="time active">
{% else %}
<button type="button" class="time">
Expand All @@ -225,7 +248,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.time >= 2 %}
{% if rating.time >= 2 or time >= 2 %}
<button type="button" class="time active">
{% else %}
<button type="button" class="time">
Expand All @@ -240,7 +263,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.time >= 3 %}
{% if rating.time >= 3 or time >= 3 %}
<button type="button" class="time active">
{% else %}
<button type="button" class="time">
Expand All @@ -255,7 +278,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.time >= 4 %}
{% if rating.time >= 4 or time >= 4 %}
<button type="button" class="time active">
{% else %}
<button type="button" class="time">
Expand All @@ -270,7 +293,7 @@ <h1>Avaliação de serviço</h1>
C22.602,0.567,25.338,0.567,26.285,2.486z"/>
</svg>
</button>
{% if rating.time >= 5 %}
{% if rating.time >= 5 or time >= 5 %}
<button type="button" class="time active">
{% else %}
<button type="button" class="time">
Expand All @@ -290,7 +313,7 @@ <h1>Avaliação de serviço</h1>

{% for error in errors %}
{% if error.field == 'time' %}
<span>
<span class="error-message">
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
Expand All @@ -299,8 +322,25 @@ <h1>Avaliação de serviço</h1>
</div>
</div>

<label for="notes">Comentários adicionais:</label>
<textarea type="text" id="notes" name="notes">{{ rating.notes }}</textarea>
<div class="textareaContainer">
<label for="notes">Comentários adicionais:</label>
{% if rating.notes %}
<textarea type="text" id="notes" name="notes">{{ rating.notes }}</textarea>
{% elif review_notes and rating.notes %}
<textarea type="text" id="notes" name="notes">{{ review_notes }}</textarea>
{% else %}
<textarea type="text" id="notes" name="notes">{{ review_notes }}</textarea>
{% endif %}

{% for error in errors %}
{% if error.field == 'review_notes' %}
<span class="error-message">
<i data-lucide="octagon-alert"></i>
{{ error.message }}
</span>
{% endif %}
{% endfor %}
</div>
</section>

<button type="submit" class="rating-submit">Avaliar</button>
Expand Down
2 changes: 1 addition & 1 deletion app_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def rating_treatment(attendance, service, time, review_notes):
if len(str(review_notes)) > 200:
errors.append({
'field': 'review_notes',
'message' : 'Este campo não pode ser maior que 200 caractéres!'
'message' : 'O seu comentário não pode ultrapassar 200 caracteres!'
})

return errors
Expand Down
32 changes: 23 additions & 9 deletions app_client/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import re
from datetime import date, timedelta, datetime
from datetime import date, datetime, timedelta

from django.shortcuts import render, redirect
from django.contrib import messages
Expand Down Expand Up @@ -245,14 +245,21 @@ def post(self, request, id):
time = request.POST.get('time')
notes = request.POST.get('notes')

ctx = {
'attendance': int(attendance),
'service': int(service),
'time': int(time),
'review_notes': notes,
}

errors = rating_treatment(attendance=attendance, service=service, time=time, review_notes=notes)

if len(errors) > 0:
order = OrderRequest.objects.get(id=id)
ctx = {
"order": order,
"errors": errors
}
ctx["order"] = order
ctx["errors"] = errors
for error in errors:
ctx.pop(error['field'], None)
return render(request, 'RequestOrder/rateservice.html', ctx)
else:
rating.attendance = attendance
Expand All @@ -268,14 +275,21 @@ def post(self, request, id):
time = request.POST.get('time')
review_notes = request.POST.get('notes')

ctx = {
'attendance': int(attendance),
'service': int(service),
'time': int(time),
'review_notes': review_notes,
}

errors = rating_treatment(attendance=attendance, service=service, time=time, review_notes=review_notes)

if len(errors) > 0:
order = OrderRequest.objects.filter(id=id).first()
ctx = {
"order": order,
"errors": errors
}
ctx["order"] = order
ctx["errors"] = errors
for error in errors:
ctx.pop(error['field'], None)
return render(request, 'RequestOrder/rateservice.html', ctx)
else:
rating = ServiceRating(attendance = attendance, time = time, service = service, notes = review_notes, os_id = id)
Expand Down
39 changes: 0 additions & 39 deletions cypress/e2e/ConvertOrderRequest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,4 @@ describe('HomePage', () => {
cy.get('#detailed_problem_description').invoke('text').should('have.string', "O compressor queimou")
cy.get('#necessary_parts').invoke('text').should('have.string', "1x Compressor Tecumseh 1/4 HP 60Hz 110V")
})
it('Campos Vazios', () => {
cy.exec('python manage.py migrate')
cy.DeleteAndCreateAdm()
cy.visit('/')
cy.on("uncaught:exception", (e, runnable) => {
console.log("error", e);
console.log("runnable", runnable);
console.log("error", e.message);
return false;
});

cy.CreateClient("Luan Kato", "[email protected]")
cy.CreateSolicitation()
cy.visit('/')
cy.ClientLogout()
cy.CreateAdmin()
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('.scheduleDateContainer > input').invoke('removeAttr', 'type').type('2024-06-18')
cy.get('.content > form > button').click()
cy.get('#status').select('Aguardando orçamento')
cy.get('.content > form > button').click()
cy.get('.budgetContainer > input').type('50')
cy.get('.content > form > button').click()
cy.get('.logout > button').click()
cy.GoToClient("[email protected]")
cy.get('.view > button').click()
cy.get('.yes')
cy.get('.waitingForm > form > button').click()
cy.ClientLogout()
cy.ChangeToAdmin()
cy.get(':nth-child(1) > a').click()
cy.get(':nth-child(6) > a').click()
cy.get('#detailed_problem_description').type(' ')
cy.get('#necessary_parts').type(' ')
cy.get('.works > button').click()


})
})
Loading

0 comments on commit 9e9ee4d

Please sign in to comment.