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
13 changes: 7 additions & 6 deletions frontend/components/learning_circle_form/FinalizeSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React, { useState } from 'react'
import { TextareaWithLabel, SelectWithLabel, InputWithLabel, SwitchWithLabels } from 'p2pu-components'

const SignupLimit = (props) => {

let maxSignups = null;
let defaultLimit = 20;
if (window.maxSignups){
// maxSignups indicates if there is a hard limit set, iow
// you can toggle unlimited signups if it isn't null
let maxSignups = null
let defaultLimit = 20
if (window.maxSignups !== undefined){
maxSignups = window.maxSignups
defaultLimit = maxSignups
}
Expand All @@ -20,7 +21,7 @@ const SignupLimit = (props) => {

return (
<>
{ !maxSignups &&
{ (maxSignups === null) &&
<SwitchWithLabels
label={'Do you want to limit the number of signups?'}
trueLabel='Yes'
Expand All @@ -30,7 +31,7 @@ const SignupLimit = (props) => {
value={props.learningCircle.signup_limit !== undefined}
/>
}
{ (props.learningCircle.signup_limit !== undefined || maxSignups) &&
{ (props.learningCircle.signup_limit !== undefined || maxSignups !== null) &&
<InputWithLabel
label={'What is the maximum number of signups?'}
type='number'
Expand Down
2 changes: 1 addition & 1 deletion media/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class Image(models.Model):
uploader_uri = models.CharField(max_length=256)

def __str__(self):
return self.image_file
return str(self.image_file)
18 changes: 18 additions & 0 deletions studygroups/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
from .models import StudyGroup
from .models import Course
from .models import get_study_group_organizers
from .models import TeamMembership
from .models import DeviceAllocation

from .utils import html_body_to_text
from .utils import use_language

from advice.models import Advice

import pytz
import datetime

@receiver(post_save, sender=Application)
def handle_new_application(sender, instance, created, **kwargs):
Expand Down Expand Up @@ -107,3 +110,18 @@ def handle_new_study_group_creation(sender, instance, created, **kwargs):
)
notification.attach_alternative(html_body, 'text/html')
notification.send()


@receiver(post_save, sender=TeamMembership)
def handle_new_team_membership(sender, instance, created, **kwargs):
if not created:
return

team_membership = instance
if team_membership.team.page_slug == 'digital-detroit':
DeviceAllocation.objects.create(
user=team_membership.user,
start_date=datetime.date(2026,2,1),
cutoff_date=datetime.date(2026,7,1),
amount=10,
)
5 changes: 5 additions & 0 deletions studygroups/tests/test_device_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def setUp(self):


def test_create_study_group_with_limit(self):
self.assertEquals(1, DeviceAllocation.objects.count())
DeviceAllocation.objects.all().delete()
c = Client()
c.login(username='bob@example.net', password='password')
data = {
Expand Down Expand Up @@ -119,6 +121,9 @@ def test_create_study_group_with_limit(self):


def test_update_learning_circle(self):
self.assertEquals(1, DeviceAllocation.objects.count())
DeviceAllocation.objects.all().delete()

self.facilitator.profile.email_confirmed_at = timezone.now()
self.facilitator.profile.save()

Expand Down
2 changes: 1 addition & 1 deletion templates/studygroups/studygroup_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
window.team = team;
window.currentUserId = {% if user.id %}{{user.id|safe}}{% else %}undefined{% endif %};
window.teamCourseList = {% if team_course_list %}true{% else %}false{% endif %};
{% if max_signups %}window.maxSignups = {{max_signups}};{% endif %}
{% if max_signups is None %}{% else %}window.maxSignups = {{max_signups}};{% endif %}
</script>
{% if object.pk %}
<script>
Expand Down