def setUp(self): super(TestMeetingCreateFormView, self).setUp() Conference.remove() self.user = AuthUserFactory() self.request = RequestFactory().post('/fake_path') self.view = MeetingCreateFormView mod_data = dict(data) mod_data.update({'admins': self.user.emails.first().address}) self.form = MeetingForm(data=mod_data) self.form.is_valid() self.url = reverse('meetings:create')
def dispatch(self, request, *args, **kwargs): endpoint = kwargs.get('endpoint') try: self.conf = Conference.get_by_endpoint(endpoint, active=False) except ConferenceError: raise Http404( 'Meeting with endpoint "{}" not found'.format(endpoint)) return super(MeetingFormView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): endpoint = kwargs.get('endpoint') try: self.conf = Conference.get_by_endpoint(endpoint, active=False) except ConferenceError: raise Http404('Meeting with endpoint "{}" not found'.format( endpoint )) return super(MeetingFormView, self).dispatch(request, *args, **kwargs)
def form_valid(self, form): custom_fields, data = get_custom_fields(form.cleaned_data) endpoint = data.pop('endpoint') self.kwargs.setdefault('endpoint', endpoint) # Form validation already checks emails for existence admin_users = get_admin_users(data.pop('admins')) # Note - Mongo was OK with having this in the payload, but Postgres is not # This edit variable was unused in the past, but keeping it in case we want to use it in the future. data.pop('edit') # Form validation already catches if a conference endpoint exists new_conf = Conference(endpoint=endpoint, **data) new_conf.save() new_conf.admins = admin_users new_conf.field_names.update(custom_fields) new_conf.save() return super(MeetingCreateFormView, self).form_valid(form)
def form_valid(self, form): custom_fields, data = get_custom_fields(form.cleaned_data) endpoint = data.pop('endpoint') self.kwargs.setdefault('endpoint', endpoint) # Form validation already checks emails for existence admin_users = get_admin_users(data.pop('admins')) # Note - Mongo was OK with having this in the payload, but Postgres is not # This edit variable was unused in the past, but keeping it in case we want to use it in the future. data.pop('edit') # Form validation already catches if a conference endpoint exists new_conf = Conference( endpoint=endpoint, **data ) new_conf.save() new_conf.admins = admin_users new_conf.field_names.update(custom_fields) new_conf.save() return super(MeetingCreateFormView, self).form_valid(form)
def get_queryset(self): return Conference.find()
def setUp(self): super(TestMeetingListView, self).setUp() Conference.remove() ConferenceFactory() ConferenceFactory() ConferenceFactory()