Exemplo n.º 1
0
def copy(request, authentication_key, template_name='events/create/copy_event.html'):
    if request.method == 'POST':
        form = CreateEventForm(account=request.account, data=request.POST, by_admin=request.user.is_staff)
        if form.is_valid():
            event_obj = event_service.save_event(request.user, request.POST, form)
            event_service.send_event_details_email(event_obj)

            success_url = reverse('event_created', kwargs={ 'slug': event_obj.slug })

            return HttpResponseRedirect(success_url)
    else:
        basic_event = Event.events.get(authentication_key__exact=authentication_key)   

        event = Event(
            name=basic_event.name, 
            description=basic_event.description,
            price=basic_event.price,
            website=basic_event.website,
            tickets=basic_event.tickets,
            owner=basic_event.owner,
            venue_account_owner=basic_event.venue_account_owner
        )

        form = CreateEventForm(
            account=request.account, 
            instance=event, 
            initial=event_service.prepare_initial_event_data_for_copy(basic_event),
            by_admin=request.user.is_staff
        )

    return render_to_response(template_name, {
            'form': form,
            'posting': True
        }, context_instance=RequestContext(request))    
Exemplo n.º 2
0
def create(request, success_url=None, template_name='events/create/create_event.html'):
    if request.method == 'POST':
        form = CreateEventForm(account=request.account, data=request.POST)
        if form.is_valid():
            try:
                event = event_service.save_event(request.user, request.POST, form)

                event_service.send_event_details_email(event)

                if success_url is None:
                    success_url = reverse('event_created', kwargs={ 'slug': event.slug })

                return HttpResponseRedirect(success_url)

            except:
                form._errors['__all__'] = ErrorList(["Unhandled exception. Please inform administrator."])

    else:
        form = CreateEventForm(account=request.account, initial={
            "venue_account_owner": request.current_venue_account
        })


    context = RequestContext(request)
    return render_to_response(template_name, {
            'form': form,
            'posting': True,
            'location': request.user_location["user_location_lat_lon"],
        }, context_instance=context)
Exemplo n.º 3
0
def create(request,
           success_url=None,
           template_name='events/create/create_event.html'):
    if request.method == 'POST':
        form = CreateEventForm(account=request.account,
                               data=request.POST,
                               by_admin=request.user.is_staff)
        if form.is_valid():
            try:
                event = event_service.save_event(request.user, request.POST,
                                                 form)
                event_service.send_event_details_email(event)
            except Exception:
                response = HttpResponseServerError()
                transaction.rollback()
                return response
            else:
                if success_url is None:
                    success_url = reverse('event_created',
                                          kwargs={'slug': event.slug})

                response = HttpResponseRedirect(success_url)
                transaction.commit()
                return response

            # except:
            #     form._errors['__all__'] = ErrorList(["Unhandled exception. Please inform administrator."])

    else:
        form = CreateEventForm(
            account=request.account,
            initial={"venue_account_owner": request.current_venue_account},
            by_admin=request.user.is_staff)

    context = RequestContext(request)
    response = render_to_response(
        template_name, {
            'form': form,
            'posting': True,
            'location': request.user_location["user_location_lat_lon"],
        },
        context_instance=context)

    transaction.commit()  # unavoidable action
    return response
Exemplo n.º 4
0
def copy(request,
         authentication_key,
         template_name='events/create/copy_event.html'):
    if request.method == 'POST':
        form = CreateEventForm(account=request.account,
                               data=request.POST,
                               by_admin=request.user.is_staff)
        if form.is_valid():
            event_obj = event_service.save_event(request.user, request.POST,
                                                 form)
            event_service.send_event_details_email(event_obj)

            success_url = reverse('event_created',
                                  kwargs={'slug': event_obj.slug})

            return HttpResponseRedirect(success_url)
    else:
        basic_event = Event.events.get(
            authentication_key__exact=authentication_key)

        event = Event(name=basic_event.name,
                      description=basic_event.description,
                      price=basic_event.price,
                      website=basic_event.website,
                      tickets=basic_event.tickets,
                      owner=basic_event.owner,
                      venue_account_owner=basic_event.venue_account_owner)

        form = CreateEventForm(
            account=request.account,
            instance=event,
            initial=event_service.prepare_initial_event_data_for_copy(
                basic_event),
            by_admin=request.user.is_staff)

    return render_to_response(template_name, {
        'form': form,
        'posting': True
    },
                              context_instance=RequestContext(request))