Skip to content

Commit

Permalink
Merge pull request #1062 from p2pu/lc-co-facilitators
Browse files Browse the repository at this point in the history
Multiple facilitators
  • Loading branch information
dirkcuys authored Aug 23, 2022
2 parents c0d3f4f + 056e869 commit 32bc2c1
Show file tree
Hide file tree
Showing 71 changed files with 962 additions and 691 deletions.
11 changes: 9 additions & 2 deletions custom_registration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from studygroups.models import TeamMembership
from studygroups.models import Profile
from studygroups.forms import TeamMembershipForm
from studygroups.models.learningcircle import StudyGroup
from uxhelpers.utils import json_response
from api import schema
from .models import create_user
Expand Down Expand Up @@ -309,8 +310,14 @@ def delete(self, request, *args, **kwargs):
user.username = random_username
user.save()

# delete any active or future learning circles
user.studygroup_set.update(deleted_at=timezone.now())
for lc in StudyGroup.objects.active().filter(facilitator__user=user):
if lc.facilitator_set.count() == 1:
lc.deleted_at = timezone.now()

if lc.facilitator_set.count() > 1:
lc.facilitator_set.filter(user=user).delete()

lc.save()

# delete profile data
profile = user.profile
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: '3'
services:
postgres:
image: postgres:11
ports:
- 5432:5432
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
Expand Down
46 changes: 42 additions & 4 deletions e2e/fixtures/test_studygroups.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"longitude" : "-87.650050",
"language" : "en",
"place_id" : "",
"facilitator": 1,
"created_by": 1,
"venue_name": "Harold Washington",
"venue_address": "123 Street",
"venue_details": "3rd floor",
Expand All @@ -45,6 +45,16 @@
"model": "studygroups.studygroup",
"pk": 1
},
{
"fields": {
"added_at": "2015-03-23T15:18:39.462Z",
"user": 1,
"study_group": 1
},
"model": "studygroups.facilitator",
"pk": 1
},

{
"fields": {
"created_at": "2015-03-23T15:19:04.318Z",
Expand All @@ -57,7 +67,7 @@
"end_date": "2015-03-23",
"duration": 120,
"timezone": "US/Central",
"facilitator": 1,
"created_by": 1,
"venue_name": "Harold Washington",
"venue_address": "123 Street",
"venue_details": "3rd floor",
Expand All @@ -71,6 +81,16 @@
"model": "studygroups.studygroup",
"pk": 2
},
{
"fields": {
"added_at": "2015-03-23T15:18:39.462Z",
"user": 1,
"study_group": 2
},
"model": "studygroups.facilitator",
"pk": 2
},

{
"fields": {
"created_at": "2015-03-25T14:35:02.227Z",
Expand All @@ -83,7 +103,7 @@
"end_date": "2015-03-23",
"duration": 120,
"timezone": "US/Central",
"facilitator": 1,
"created_by": 1,
"venue_name": "Harold Washington",
"venue_address": "123 Street",
"venue_details": "3rd floor",
Expand All @@ -97,6 +117,15 @@
"model": "studygroups.studygroup",
"pk": 3
},
{
"fields": {
"added_at": "2015-03-23T15:18:39.462Z",
"user": 1,
"study_group": 3
},
"model": "studygroups.facilitator",
"pk": 3
},
{
"fields": {
"created_at": "2015-03-25T15:55:44.525Z",
Expand All @@ -109,7 +138,7 @@
"end_date": "2015-03-23",
"duration": 120,
"timezone": "US/Central",
"facilitator": 1,
"created_by": 1,
"venue_name": "Harold Washington",
"venue_address": "123 Street",
"venue_details": "3rd floor",
Expand All @@ -122,5 +151,14 @@
},
"model": "studygroups.studygroup",
"pk": 4
},
{
"fields": {
"added_at": "2015-03-23T15:18:39.462Z",
"user": 1,
"study_group": 4
},
"model": "studygroups.facilitator",
"pk": 4
}
]
4 changes: 2 additions & 2 deletions e2e/tests/test_learning_circle_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_save_draft_learning_circle(self):
self.wait.until(expected_conditions.url_changes('%s%s' % (self.live_server_url, '/en/studygroup/create/')))

saved_studygroup = StudyGroup.objects.filter(draft=True).last()
self.assertEqual(saved_studygroup.facilitator, facilitator)
self.assertEqual(saved_studygroup.created_by, facilitator)
self.assertTrue(expected_conditions.url_to_be('{}/en/studygroup/{}/'.format(self.live_server_url, saved_studygroup.id)))


Expand Down Expand Up @@ -196,7 +196,7 @@ def test_publish_learning_circle(self):
self.wait.until(expected_conditions.url_changes('%s%s' % (self.live_server_url, '/en/studygroup/create/')))

published_studygroup = StudyGroup.objects.published().last()
self.assertEqual(published_studygroup.facilitator, facilitator)
self.assertEqual(published_studygroup.created_by, facilitator)
self.assertTrue(expected_conditions.url_to_be('{}/en/studygroup/{}/'.format(self.live_server_url, published_studygroup.id)))


4 changes: 3 additions & 1 deletion e2e/tests/test_learning_circle_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from studygroups.models import Course
from studygroups.models import StudyGroup
from studygroups.models import Meeting
from studygroups.models import Facilitator
from custom_registration.models import create_user

from datetime import timedelta, time
Expand Down Expand Up @@ -56,8 +57,9 @@ def tearDownClass(cls):
def setUp(self):
self.facilitator = create_user('[email protected]', 'bowie', 'wowie', 'password')
sg = StudyGroup.objects.get(pk=1)
sg.facilitator = self.facilitator
sg.created_by = self.facilitator
sg.save()
Facilitator.objects.create(study_group=sg, user=self.facilitator)
self.study_group = sg
meeting_date = timezone.now() - timedelta(days=2)
meeting = Meeting.objects.create(study_group=sg, meeting_date=meeting_date.date(), meeting_time=time(18, 0))
Expand Down
4 changes: 4 additions & 0 deletions frontend/components/create-learning-circle-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ export default class CreateLearningCirclePage extends React.Component {
...this.props.learningCircle,
meetings: meetings
},
team: this.props.team,
showModal: false,
showHelp: window.screen.width > DESKTOP_BREAKPOINT,
user: this.props.user,
userId: this.props.userId,
errors: {},
alert: { show: false },
isSaving: false,
Expand Down Expand Up @@ -290,7 +292,9 @@ export default class CreateLearningCirclePage extends React.Component {
currentTab={this.state.currentTab}
allTabs={this.allTabs}
changeTab={this.changeTab}
userId={this.props.userId}
learningCircle={this.state.learningCircle}
team={this.state.team}
errors={this.state.errors}
onCancel={this.onCancel}
onSubmitForm={this.onSubmitForm}
Expand Down
2 changes: 0 additions & 2 deletions frontend/components/dashboard/FacilitatorDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import Notification from './Notification';
import DiscourseTable from './DiscourseTable';
import CoursesTable from './CoursesTable';
import MemberLearningCirclesTable from './MemberLearningCirclesTable';
import UpcomingLearningCirclesTable from './UpcomingLearningCirclesTable';
import CurrentLearningCirclesTable from './CurrentLearningCirclesTable';
import ActiveLearningCirclesTable from './ActiveLearningCirclesTable';
import CompletedLearningCirclesTable from './CompletedLearningCirclesTable';
import UpcomingMeetings from './UpcomingMeetings';
import RecommendedResources from "./RecommendedResources";
import GlobalSuccesses from "./GlobalSuccesses";
import InstagramFeed from "./InstagramFeed";
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/TeamInvitationsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class TeamMembersTable extends Component {
if (this.state.teamMembers.length === 0) {
return(
<div className="py-2">
<div>You don't have any team members.</div>
<div>You don't have any pending invitations.</div>
</div>
)
}
Expand Down
149 changes: 0 additions & 149 deletions frontend/components/dashboard/UpcomingLearningCirclesTable.jsx

This file was deleted.

Loading

0 comments on commit 32bc2c1

Please sign in to comment.