-
-
Notifications
You must be signed in to change notification settings - Fork 661
Source test commands for local dev use #2880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,4 @@ __pycache__ | |
| .DS_Store | ||
| .envrc | ||
| .state/ | ||
| scripts/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,282 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import datetime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.conf import settings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.core.management.base import BaseCommand, CommandError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from django.utils import timezone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from events.models import Calendar, Event, EventCategory, EventLocation, OccurringRule, RecurringRule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from dateutil.rrule import WEEKLY, MONTHLY, YEARLY, DAILY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class Command(BaseCommand): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| help = 'Creates test events for the events app (development only)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def add_arguments(self, parser): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser.add_argument( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '--force', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| action='store_true', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| help='Force execution even in non-DEBUG mode (use with extreme caution)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def handle(self, *args, **options): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Production safety check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not settings.DEBUG and not options['force']: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise CommandError( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "This command cannot be run in production (DEBUG=False). " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "This command creates test data and should only be used in development environments." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create main calendar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| main_calendar, created = Calendar.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='python-events', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'name': 'Python Events', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'description': 'Main Python community events calendar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.stdout.write(f"Main calendar {'created' if created else 'already exists'}: {main_calendar}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create additional calendars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| user_group_calendar, _ = Calendar.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='user-group-events', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'name': 'User Group Events', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'description': 'Python user group meetups and events', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conference_calendar, _ = Calendar.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='conferences', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'name': 'Python Conferences', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'description': 'Major Python conferences worldwide', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create categories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| meetup_category, _ = EventCategory.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='meetup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| calendar=main_calendar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={'name': 'Meetup'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conference_category, _ = EventCategory.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='conference', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| calendar=main_calendar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={'name': 'Conference'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workshop_category, _ = EventCategory.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='workshop', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| calendar=main_calendar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaults={'name': 'Workshop'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sprint_category, _ = EventCategory.objects.get_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slug='sprint', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| calendar=main_calendar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+74
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| calendar=main_calendar, | |
| defaults={'name': 'Meetup'} | |
| ) | |
| conference_category, _ = EventCategory.objects.get_or_create( | |
| slug='conference', | |
| calendar=main_calendar, | |
| defaults={'name': 'Conference'} | |
| ) | |
| workshop_category, _ = EventCategory.objects.get_or_create( | |
| slug='workshop', | |
| calendar=main_calendar, | |
| defaults={'name': 'Workshop'} | |
| ) | |
| sprint_category, _ = EventCategory.objects.get_or_create( | |
| slug='sprint', | |
| calendar=main_calendar, | |
| calendar=user_group_calendar, | |
| defaults={'name': 'Meetup'} | |
| ) | |
| conference_category, _ = EventCategory.objects.get_or_create( | |
| slug='conference', | |
| calendar=conference_calendar, | |
| defaults={'name': 'Conference'} | |
| ) | |
| workshop_category, _ = EventCategory.objects.get_or_create( | |
| slug='workshop', | |
| calendar=conference_calendar, | |
| defaults={'name': 'Workshop'} | |
| ) | |
| sprint_category, _ = EventCategory.objects.get_or_create( | |
| slug='sprint', | |
| calendar=conference_calendar, |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locations are created with calendar=main_calendar, but are then used as venues for events in other calendars (e.g., conference_calendar). Since location views filter by calendar_slug + pk, this makes location pages for those calendars inconsistent. Consider creating separate EventLocation rows per calendar (or ensure events only use locations from their own calendar).
Uh oh!
There was an error while loading. Please reload this page.