Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix turnos #316

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions calendario/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ def get_appointments_list(servicio, user, **kwargs):
kw['servicio__pk'] = servicio
kw['estado__in'] = [Turno.DISPONIBLE, Turno.CANCELADO_PACIENTE, Turno.CANCELADO_ESTABLECIMIENTO]
return Turno.objects.filter(**kw)
else:
csp = user.centros_de_salud_permitidos.filter(estado=UsuarioEnCentroDeSalud.EST_ACTIVO)
centros_de_salud_permitidos = [c.centro_de_salud for c in csp]
return []
# se comento este codigo porque devuelve los turnos de todos los centros de salud
#else:
# csp = user.centros_de_salud_permitidos.filter(estado=UsuarioEnCentroDeSalud.EST_ACTIVO)
# centros_de_salud_permitidos = [c.centro_de_salud for c in csp]

return Turno.objects.filter(servicio__centro__in=centros_de_salud_permitidos, **kw)
# return Turno.objects.filter(servicio__centro__in=centros_de_salud_permitidos, **kw)


@permission_required('calendario.can_schedule_turno', raise_exception=True)
Expand Down
2 changes: 2 additions & 0 deletions profesionales/templates/profesionales/home_profesional.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ <h4>Profesional: {{ profesional }} Fecha: {{hoy|date:"d M, Y"}}</h4>
<thead>
<tr>
<th scope="col">Paciente</th>
<th scope="col">Centro</th>
<th scope="col">Inicio</th>
<th scope="col">Fin</th>
<th scope="col">Servicio</th>
Expand All @@ -37,6 +38,7 @@ <h4>Profesional: {{ profesional }} Fecha: {{hoy|date:"d M, Y"}}</h4>
{% for turno in turnos %}
<tr>
<th scope="row">{{ turno.paciente.nombres }} {{ turno.paciente.apellidos }}</th>
<td>{{ turno.servicio.centro }}</td>
<td>{{ turno.inicio|time:"H:i" }}</td>
<td>{{ turno.fin|time:"H:i" }}</td>
<td>{{ turno.servicio.especialidad.nombre }}</td>
Expand Down
9 changes: 4 additions & 5 deletions profesionales/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
hoy = datetime.now()
context['hoy'] = hoy
context['estados'] = Turno.OPCIONES_ESTADO

# sólo se muestran los turnos si está autenticado(y además debe
# estar dentro del grupo profesionales).
if self.request.user.is_authenticated:
user = self.request.user
context['user'] = user
# que solo vea SUS turnos
context['turnos'] = Turno.objects.filter(
turnos = Turno.objects.filter(
inicio__day=hoy.day,
profesional__user=user
).order_by('inicio')
).exclude(estado=Turno.DISPONIBLE).order_by('inicio')
# que solo vea SUS turnos
context['turnos'] = turnos
if hasattr(user, 'profesional'):
context['profesional'] = user.profesional
else:
Expand Down