def edit_or_update(request, event): if request.method == "POST": ef, vf, lf = _process_create_post_data(request.POST) if ef.is_valid() and vf.is_valid(): new_event = ef.instance new_event.organiser_email = event.organiser_email new_event.verified = event.verified new_event.official = event.official new_event.campaign = event.campaign new_event.source = event.source new_event.source_id = event.source_id new_venue = vf.instance vf.add_geo_data_to(new_venue) models.EventAndVenueUpdater.update(event, new_event, event.venue, new_venue) return http.HttpResponseRedirect( reverse('event', kwargs={'event_hash': event.hash})) else: ef = forms.EventForm(instance=event) vf = forms.VenueForm(instance=event.venue) lf = forms.PrivacyAndLegalForm() return _render_event_creation_form(request, ef, vf, lf, template='events/edit.html', event=event)
def test_that_create_event_and_venue_does_that_given_valid_data(self): event_kind = models.EventKind(name = "Test", slug = "test", description = "Test") event_kind.save() self.data['event-kind'] = str(event_kind.id) ef = forms.EventForm(self.data) vf = forms.VenueForm(self.data) mock_user = Mock() mock_user.email = '*****@*****.**' event, venue = views._create_event_and_venue(mock_user, ef, vf) ok_(event.id is not None) ok_(venue.id is not None) eq_(venue.location.y, 51.0) eq_(venue, event.venue)
def setUp(self): self.ef = forms.EventForm() self.vf = forms.VenueForm() self.request = rf.get('/events/new') self.fieldsets = ( forms.Fieldset(self.ef, ('kind', )), forms.Fieldset(self.ef, ('name', 'event_url', 'description', 'public')), forms.Fieldset(self.ef, ( 'start', 'end', )), forms.Fieldset(self.vf, self.vf.fields), ) context = { 'event_form': self.ef, 'venue_form': self.vf, 'fieldsets': self.fieldsets } self.result = jingo.render(self.request, 'events/new.html', context) self.html = html_context(self.result.content)
def setUp(self): self.f = forms.EventForm()
def new(request): return _render_event_creation_form(request, forms.EventForm(), forms.VenueForm(), forms.PrivacyAndLegalForm())
def _process_create_post_data(data): event_form = forms.EventForm(data) venue_form = forms.VenueForm(data) privacy_and_legal_form = forms.PrivacyAndLegalForm(data) return (event_form, venue_form, privacy_and_legal_form)