datatracker/ietf/meeting/migrations/0003_populate_session_has_onsite_tool.py
Jennifer Richards 09ff9c6ced
refactor: Tie Meetecho resources to Session pk (#5281)
* feat: Use session.id to specify session for api_set_session_video_url

* feat: Use session.id to specify session for api_upload_bluesheet

* refactor: Add audio/video stream and onsite tool URLs to Session model

* refactor: Get onsite tool/stream URLs for agenda from Session

* refactor: Use Session methods for onsite tool/stream a few more places

* refactor: Move hard-coded meetecho URLs into settings.py

* feat: Add has_onsite_flag to Session

* chore: Set has_onsite_tool for sessions that had meetecho UrlResources

* fix: Only show onsite tool URLs when Session.has_onsite_tool is True

* test: Update test_api_upload_bluesheet to test deprecated version

* fix: Fix test failure in api_upload_bluesheet view

* test: Add test of new api_upload_bluesheet view

* style: Apply Black style to test_api_upload_bluesheet

* fix: Fix test failures in api_upload_bluesheet()

* test: Update test_api_set_session_video_url to test deprecated version

* fix: Fix test failure in api_set_session_video_url view

* test: Add test of new api_set_session_video_url view

* style: Apply Black styling to new test

* fix: Fix test failures in api_set_session_video_url view

* test: Fix test_meeting_agenda; set has_onsite_tool in SessionFactory

* feat: Add has_onsite_tool to Session list in admin

* feat: Add has_onsite_tool flag to SessionDetailsForm

* feat: Add has_onsite_tool flag to sreq

* feat: Show has_onsite_tool flag on secr view for a submitted request

* feat: Only prompt for has_onsite_tool in sreq for non-wg type groups

* fix: Clean up styling of sreq view a bit

* chore: Renumber migrations
2023-04-23 18:15:01 -05:00

34 lines
1.1 KiB
Python

# Generated by Django 2.2.28 on 2023-03-07 16:54
from django.db import migrations
def forward(apps, schema_editor):
Session = apps.get_model('meeting', 'Session')
Meeting = apps.get_model('meeting', 'Meeting')
Room = apps.get_model('meeting', 'Room')
full_meetings = Meeting.objects.filter(type_id='ietf', schedule__isnull=False)
schedules = {m.schedule for m in full_meetings} | {m.schedule.base for m in full_meetings if m.schedule.base}
rooms_with_meetecho = Room.objects.filter(urlresource__name_id__in=['meetecho', 'meetecho_onsite']).distinct()
sessions_with_meetecho = Session.objects.filter(
timeslotassignments__schedule__in=schedules,
timeslotassignments__timeslot__location__in=rooms_with_meetecho,
).distinct()
sessions_with_meetecho.update(has_onsite_tool=True)
def reverse(apps, schema_editor):
Session = apps.get_model('meeting', 'Session')
Session.objects.all().update(has_onsite_tool=False)
class Migration(migrations.Migration):
dependencies = [
('meeting', '0002_session_has_onsite_tool'),
]
operations = [
migrations.RunPython(forward, reverse),
]