예제 #1
0
def create_event(request):
    
    form = EventForm()
    
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            new_event = form.save()
            attendee = Attendee(user = request.user, event = new_event, is_managing=True)
            attendee.save()
            return redirect('detail', event_id=new_event.pk)
        
    context = {
               'form' : form,
               'button_label' : 'Create Event'
    }
    return render(request, 'eventsAtEPAM/create.html', context)
예제 #2
0
def edit_event(request, event_id):
    
    event = get_object_or_404(Events, pk=event_id)
    if request.method == 'POST':
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            new_event = form.save()
            return redirect('detail', event_id=new_event.pk)
        else:
            form = EventForm()
        
    else:
        form = EventForm(instance=event)
        
    context = {
    'form' : form,
    'button_label' : 'Save changes'
    }
    return render(request, 'eventsAtEPAM/create.html', context)
예제 #3
0
def edit_event(request, event_id):

    event = get_object_or_404(Events, pk=event_id)
    if request.method == 'POST':
        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            new_event = form.save()
            return redirect('detail', event_id=new_event.pk)
        else:
            form = EventForm()

    else:
        form = EventForm(instance=event)

    context = {'form': form, 'button_label': 'Save changes'}
    return render(request, 'eventsAtEPAM/create.html', context)
예제 #4
0
def create_event(request):

    form = EventForm()

    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            new_event = form.save()
            attendee = Attendee(user=request.user,
                                event=new_event,
                                is_managing=True)
            attendee.save()
            return redirect('detail', event_id=new_event.pk)

    context = {'form': form, 'button_label': 'Create Event'}
    return render(request, 'eventsAtEPAM/create.html', context)