Skip to content
Merged
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
2 changes: 1 addition & 1 deletion studygroups/models/device_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def check_user_device_allocation(user, date):

# Find any learning circles in the device allocation time period
study_groups = StudyGroup.objects.active().filter(
facilitator__user=user,
created_by=user,
start_date__gte=device_allocation.start_date,
start_date__lt=device_allocation.cutoff_date,
)
Expand Down
19 changes: 13 additions & 6 deletions studygroups/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,22 @@ def get(self, request):

courses = Course.objects.active().filter(archived=False)

# include_unlisted must be != false and the query must be scoped
# by user to avoid filtering out unlisted courses
if request.GET.get('include_unlisted', "false") == "false" or 'user' not in request.GET:
# return only courses that is not unlisted
# if the user is part of a team, include unlisted courses from the team
# unlisted courses are only included
if request.GET.get('include_unlisted') == True and 'user' in request.GET:
# if specifically requested and scoped by user - users can see their own unlisted courses
pass
elif 'course_id' in request.GET:
# if selected by id
# TODO maybe we want to check for more that just course_id in request to show unlisted courses?
pass
else:
if request.user.is_authenticated:
# if the user is part of a team, include unlisted courses from the team
team_query = TeamMembership.objects.active().filter(user=request.user).values('team')
team_ids = TeamMembership.objects.active().filter(team__in=team_query).values('user')
courses = courses.filter(Q(unlisted=False) | Q(unlisted=True, created_by__in=team_ids))
else:
# otherwise return only listed courses
courses = courses.filter(unlisted=False)

# TODO this doesn't exclude drafts
Expand Down Expand Up @@ -868,7 +874,8 @@ def post(self, request, *args, **kwargs):

# if part of digital detroit project
if study_group.show_device_agreement():
devices = check_user_device_allocation(request.user, study_group.start_date)
# TODO use creator as user
devices = check_user_device_allocation(study_group.created_by, study_group.start_date)
max_limit = study_group.signup_limit + devices
signup_limit = data.get('signup_limit', None)
if signup_limit is None or signup_limit > max_limit:
Expand Down
2 changes: 1 addition & 1 deletion studygroups/views/facilitate.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def get_context_data(self, **kwargs):
context['reminders_edited'] = True
messages.warning(self.request, _('You have edited meeting reminders for meetings in the future. Update the learning circle description or venue information will cause the reminders to be regenerated and your updates to be lost'))
if self.object.team and self.object.team.page_slug == 'digital-detroit':
context['max_signups'] = self.object.signup_limit + check_user_device_allocation(self.request.user, datetime.datetime.today())
context['max_signups'] = self.object.signup_limit + check_user_device_allocation(self.object.created_by, datetime.datetime.today())

return context

Expand Down
Loading