summaryrefslogtreecommitdiff
path: root/workshop_app/views.py
diff options
context:
space:
mode:
authorankitjavalkar2019-09-25 15:46:43 +0530
committerankitjavalkar2019-09-25 15:46:43 +0530
commit194ee67048b80655f3da6be1f5018fdc278ffc58 (patch)
tree4cc8b2f6db31171cb5009da00e9082dc3d7f6229 /workshop_app/views.py
parent432998c8df215cf24512bc2e50e47ee6fdf952d0 (diff)
downloadworkshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.tar.gz
workshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.tar.bz2
workshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.zip
Multiple Changes:
- Add teams - Fix bug that causes todays booked workshops to disappear from queue - Add a graph to display viz for accepted workshops in a team - Remove unnecessary loops
Diffstat (limited to 'workshop_app/views.py')
-rw-r--r--workshop_app/views.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/workshop_app/views.py b/workshop_app/views.py
index bdb5580..772615b 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -10,6 +10,7 @@ from .models import (
BookedWorkshop, ProposeWorkshopDate,
Testimonial, ProfileComments
)
+from teams.models import Team
from datetime import datetime, date
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.decorators import login_required
@@ -658,26 +659,36 @@ def my_workshops(request):
today = datetime.today().date()
workshop_occurence_list = RequestedWorkshop.objects.filter(
requested_workshop_instructor=user.id,
- requested_workshop_date__gt=today,
+ requested_workshop_date__gte=today,
).order_by('-requested_workshop_date')
- for w in workshop_occurence_list:
- workshops.append(w)
proposed_workshop = ProposeWorkshopDate.objects.filter(
proposed_workshop_instructor=user.id,
- proposed_workshop_date__gt=today,
+ proposed_workshop_date__gte=today,
).order_by('-proposed_workshop_date')
- for p in proposed_workshop:
- workshops.append(p)
proposed_workshop_pending = ProposeWorkshopDate.objects.filter(
status='Pending'
).order_by('-proposed_workshop_date')
- for p in proposed_workshop_pending:
- workshops.append(p)
+
+ workshops = list(workshop_occurence_list) + list(proposed_workshop) + list(proposed_workshop_pending)
+
+ # team_members = list(set(user.profile.team_set.all().values_list('members', flat=True)))
+ teams = Team.objects.filter(members=user.profile)
+ team_workshops = []
+
+ if teams:
+ team_members = Profile.objects.filter(team__in=teams).exclude(id=user.profile.id).distinct()
+ team_member_ids = team_members.values_list('user__id')
+ team_workshops = ProposeWorkshopDate.objects.filter(
+ proposed_workshop_date__gte=today,
+ proposed_workshop_instructor_id__in=team_member_ids,
+ )
+ print(team_workshops)
return render(request, 'workshop_app/my_workshops.html',
{ "workshops" :workshops,
+ "team_workshops": team_workshops,
"today": today})
else:
@@ -685,14 +696,12 @@ def my_workshops(request):
workshop_occurence_list = RequestedWorkshop.objects.filter(
requested_workshop_coordinator=user.id
).order_by('-requested_workshop_date')
- for w in workshop_occurence_list:
- workshops.append(w)
proposed_workshop = ProposeWorkshopDate.objects.filter(
proposed_workshop_coordinator=user.id
).order_by('-proposed_workshop_date')
- for p in proposed_workshop:
- workshops.append(p)
+
+ workshops = list(workshop_occurence_list) + list(proposed_workshop) + list(proposed_workshop_pending)
return render(request, 'workshop_app/my_workshops.html',
{"workshops": workshops})