def create_event(self, event_data): name = event_data.find("title").text organiser = Organiser.objects.create( name=name, slug=event_data.find("acronym").text) event = Event( name=name, organiser=organiser, slug=event_data.find("acronym").text, date_from=dt.datetime.strptime( event_data.find("start").text, "%Y-%m-%d").date(), date_to=dt.datetime.strptime( event_data.find("end").text, "%Y-%m-%d").date(), ) event.save() Team.objects.create( name=name + " Organisers", organiser=organiser, all_events=True, can_create_events=True, can_change_teams=True, can_change_organiser_settings=True, can_change_event_settings=True, can_change_submissions=True, ) return event
def handle(self, *args, **options): from pretalx.schedule.utils import process_frab path = options.get('path') tree = ET.parse(path) root = tree.getroot() event_data = root.find('conference') event = Event.objects.filter( slug__iexact=event_data.find('acronym').text).first() if not event: event = Event( name=event_data.find('title').text, slug=event_data.find('acronym').text, date_from=datetime.strptime( event_data.find('start').text, '%Y-%m-%d').date(), date_to=datetime.strptime( event_data.find('end').text, '%Y-%m-%d').date(), ) event.save() for user in User.objects.filter(is_administrator=True): EventPermission.objects.get_or_create(event=event, user=user, is_orga=True) self.stdout.write(self.style.SUCCESS(process_frab(root, event)))
def handle(self, *args, **options): from pretalx.schedule.utils import process_frab path = options.get('path') tree = ET.parse(path) root = tree.getroot() event_data = root.find('conference') event = Event.objects.filter( slug__iexact=event_data.find('acronym').text).first() if not event: name = event_data.find('title').text organiser = Organiser.objects.create(name=name) event = Event( name=name, organiser=organiser, slug=event_data.find('acronym').text, date_from=datetime.strptime( event_data.find('start').text, '%Y-%m-%d').date(), date_to=datetime.strptime( event_data.find('end').text, '%Y-%m-%d').date(), ) event.save() Team.objects.create( name=name + ' Organisers', organiser=organiser, all_events=True, can_create_events=True, can_change_teams=True, can_change_organiser_settings=True, can_change_event_settings=True, can_change_submissions=True, ) team = event.organiser.teams.filter( can_create_events=True, can_change_teams=True, can_change_organiser_settings=True, can_change_event_settings=True, can_change_submissions=True, ).first() if not team: team = Team.objects.create( name=str(event.name) + ' Organisers', organiser=organiser, all_events=True, can_create_events=True, can_change_teams=True, can_change_organiser_settings=True, can_change_event_settings=True, can_change_submissions=True, ) for user in User.objects.filter(is_administrator=True): team.members.add(user) team.save() self.stdout.write(self.style.SUCCESS(process_frab(root, event)))
def create_event(self, event_data): name = event_data.find('title').text organiser = Organiser.objects.create(name=name) event = Event( name=name, organiser=organiser, slug=event_data.find('acronym').text, date_from=datetime.strptime(event_data.find('start').text, '%Y-%m-%d').date(), date_to=datetime.strptime(event_data.find('end').text, '%Y-%m-%d').date(), ) event.save() Team.objects.create( name=name + ' Organisers', organiser=organiser, all_events=True, can_create_events=True, can_change_teams=True, can_change_organiser_settings=True, can_change_event_settings=True, can_change_submissions=True, ) return event
def test_event_model_slug_blacklist_validation(slug): with pytest.raises(ValidationError): Event( name='Event', slug=slug, is_public=True, email='*****@*****.**', locale_array='en,de', locale='en', date_from=datetime.date.today(), date_to=datetime.date.today() ).clean_fields()
def create_event(self, event_data): name = event_data.find("title").text organiser = Organiser.objects.create( name=name, slug=event_data.find("acronym").text) event = Event( name=name, organiser=organiser, slug=event_data.find("acronym").text, date_from=dt.datetime.strptime( event_data.find("start").text, "%Y-%m-%d").date(), date_to=dt.datetime.strptime( event_data.find("end").text, "%Y-%m-%d").date(), ) event.save() self.create_team(name + " Organisers", organiser) return event
def test_event_model_slug_permitted_validation(slug): with pytest.raises(ValidationError): Event( name="Event", slug=slug, is_public=True, email="*****@*****.**", locale_array="en,de", locale="en", date_from=dt.date.today(), date_to=dt.date.today(), ).clean_fields()
def handle(self, *args, **options): path = options.get('path') tree = ET.parse(path) root = tree.getroot() event_data = root.find('conference') event = Event.objects.filter( slug__iexact=event_data.find('acronym').text).first() if not event: event = Event( name=event_data.find('title').text, slug=event_data.find('acronym').text, date_from=datetime.strptime( event_data.find('start').text, '%Y-%m-%d').date(), date_to=datetime.strptime( event_data.find('end').text, '%Y-%m-%d').date(), ) event.save() for user in User.objects.filter(is_superuser=True): EventPermission.objects.get_or_create(event=event, user=user, is_orga=True) for day in root.findall('day'): for rm in day.findall('room'): room, _ = Room.objects.get_or_create(event=event, name=rm.attrib['name']) for talk in rm.findall('event'): self._create_talk(talk=talk, room=room, event=event) schedule_version = root.find('version').text event.wip_schedule.freeze(schedule_version, notify_speakers=False) event.schedules.get(version=schedule_version).talks.update( is_visible=True) self.stdout.write( self.style.SUCCESS( f'Successfully imported "{event.name}" schedule version "{schedule_version}".' ))
def handle(self, *args, **options): path = options.get('path') tree = ET.parse(path) root = tree.getroot() event_data = root.find('conference') event = Event( name=event_data.find('title').text, slug=event_data.find('acronym').text, date_from=datetime.strptime( event_data.find('start').text, '%Y-%m-%d').date(), date_to=datetime.strptime(event_data.find('end').text, '%Y-%m-%d').date(), ) event.save() for user in User.objects.filter(is_superuser=True): EventPermission.objects.create(event=event, user=user, is_orga=True) for day in root.findall('day'): for rm in day.findall('room'): room, _ = Room.objects.get_or_create(event=event, name=rm.attrib['name']) for talk in rm.findall('event'): date = talk.find('date').text start = parse(date + ' ' + talk.find('start').text) try: end = parse(date + ' ' + talk.find('end').text) except AttributeError: hours, minutes = talk.find('duration').text.split(':') duration = timedelta(hours=int(hours), minutes=int(minutes)) end = start + duration sub_type = SubmissionType.objects.filter( event=event, name=talk.find('type').text).first() if not sub_type: sub_type = SubmissionType(name=talk.find('type').text or 'default', event=event) sub_type.save() sub = Submission.objects.create( event=event, code=talk.attrib['id'], submission_type=sub_type, title=talk.find('title').text, description=talk.find('description').text, abstract=talk.find('abstract').text, content_locale=talk.find('language').text or 'en', do_not_record=talk.find('recording').find( 'optout').text == 'true', state=SubmissionStates.CONFIRMED, ) for person in talk.find('persons').findall('person'): user = User.objects.filter(nick=person.text).first() if not user: user = User(nick=person.text, name=person.text, email=f'{person.text}@localhost') user.save() SpeakerProfile.objects.create(user=user, event=event) sub.speakers.add(user) TalkSlot.objects.create(submission=sub, schedule=event.wip_schedule, room=room, is_visible=True, start=start, end=end) schedule_version = root.find('version').text event.wip_schedule.freeze(schedule_version) event.schedules.get(version=schedule_version).talks.update( is_visible=True)