Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephslv committed Sep 26, 2022
2 parents edd68d6 cf67c4c commit 70ccc0a
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 42 deletions.
Binary file modified agenda/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified agenda/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified agenda/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file modified agenda/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file modified agenda/migrations/__pycache__/0001_initial.cpython-310.pyc
Binary file not shown.
Binary file modified agenda/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
9 changes: 6 additions & 3 deletions agenda/templates/agenda/pages/consulta.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 29,12 @@ <h2 id="title"><span class="title">Consulte</span> a Agenda!</h2>
<input type="time" value="{{time}}" name="time" id="">
<input type="date" value="{{date}}" name="date" id="">
<select value="{{category}}" name="category" id="">
<option value="">{{category}}</option>
<option value="{{category_id}}">{{category}}</option>
{% if category != 'Serviço'%}
<option value="">Serviço</option>
{% endif %}
{% for categoria in categorias %}
{% if categoria.categoria != category %}
{% if categoria.id != category_id %}
<option value="{{categoria.id}}">{{categoria.categoria}}</option>
{% endif %}
{% endfor %}
Expand Down Expand Up @@ -68,5 71,5 @@ <h2 id="title"><span class="title">Consulte</span> a Agenda!</h2>
</div><!--container-->
</main>
</body>
<script src="{% static 'script/script.js' %}"></script>
<script src="{% static 'js/script.js' %}"></script>
</html>
82 changes: 44 additions & 38 deletions agenda/views.py
Original file line number Diff line number Diff line change
@@ -1,17 1,16 @@
from importlib.metadata import requires
from pyexpat import model
import re
from importlib.metadata import requires
from urllib import request
from django.shortcuts import render, redirect
from django.views import View

from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from .models import Agenda, Categoria
from django.http import Http404
from django.shortcuts import redirect, render
from django.views import View
from pyexpat import model

from .models import Agenda, Categoria


# views here.
Expand Down Expand Up @@ -90,43 89,49 @@ def post(self, request):
category = request.POST.get('category')
concluido = request.POST.get('verificados')
pesquisar = request.POST.get('btn-pesquisar')

if pesquisar == 'on':

concluido = True if concluido == 'on' else False

filtro = {
'0':Agenda.objects.filter(usuario = request.user, categoria__id = category, client__icontains = client, horario__icontains = time, data__icontains = date, concluido = concluido),

'1':Agenda.objects.filter(usuario = request.user, client__icontains = client, horario__icontains = time, data__icontains = date, concluido = concluido),
}

filtrar = filtro['0'] if not category is None else filtro['1']

categoria = Categoria.objects.all().order_by('-id')
return render(request, 'agenda/pages/consulta.html', context = {
'agenda' :filtrar,
'categorias':categoria,
'concluido' :concluido,
'classe' :classe,
'client' :client,
'time' :time,
'date' :date,
'category' :category,
})



if concluido is None:
concluido = pesquisar.split(' ')[1]
if concluido == 'on':
classe = 'verificados_on'
else:
classe = 'verificados_off'
if not pesquisar is None:
if pesquisar.split(' ')[0] == 'on':
conclu = True if concluido == 'on' else False
print(category)
print(date)
print(time)
print(conclu)
if category == '':
filtrar = Agenda.objects.filter(usuario = request.user, cliente__icontains = client, horario__icontains = time, data__icontains = date, concluido = conclu).order_by('-id')
else:
filtrar = Agenda.objects.filter(usuario = request.user, servico__id =category, cliente__icontains = client, horario__icontains = time, data__icontains = date, concluido = conclu).order_by('-id')

category = 'Serviço'

categoria = Categoria.objects.all().order_by('-id')
return render(request, 'agenda/pages/consulta.html', context = {
'agenda' :filtrar,
'categorias':categoria,
'concluido' :concluido,
'classe' :classe,
'client' :client,
'time' :time,
'date' :date,
'category' :category,
})

if concluido == 'on':
classe = 'verificados_on'
else:
classe = 'verificados_off'

if category == '':
category_id = ''
if category != '':
category = Categoria.objects.filter(id=category).first()
category_id = category.id
else:
category = 'Serviço'

print(category)


agenda = Agenda.objects.filter(usuario=request.user, concluido=False).order_by('-id')
categoria = Categoria.objects.all().order_by('-id')

Expand All @@ -139,6 144,7 @@ def post(self, request):
'time' :time,
'date' :date,
'category' :category,
'category_id': category_id
})

if category == '':
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified mysite/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified mysite/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified mysite/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified mysite/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion static/script/script.js → static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@ MostrarVerificados = () => {

Pesquisar = () => {
if(botaoPesquisar.value == 'off'){
botaoPesquisar.value = 'on'
botaoPesquisar.value = `on ${verificados.value}`
} else {
botaoPesquisar.value = 'off'
}
Expand Down

0 comments on commit 70ccc0a

Please sign in to comment.