예제 #1
0
def event_edit(request, event_id):
    user = check_undergraduate(request.user.username)
    if not user:# or not request.is_ajax() or not user.officer_at:
        return HttpResponseForbidden()
        
    event = get_object_or_404(Event, event_id=event_id, club=user.officer_at)
    if request.method == 'POST':
        event_form = EventForm(request.POST, request.FILES, instance=event)
        if event_form.is_valid():
            event = event_form.save()
            return render_to_response('pam/event.html', {'event': event, 'user': user})
    
    event_form = EventForm(instance=event)
    return render_to_response('pam/event_add.html', {'user': user, 'event': event, 'event_form': event_form})
예제 #2
0
def event_add(request):
    user = check_undergraduate(request.user.username)
    if not user:# or not request.is_ajax() or not user.officer_at:
        return HttpResponseForbidden()
    
    event_form = EventForm()
    if request.method == 'POST':
        event_form = EventForm(request.POST, request.FILES)
        if event_form.is_valid():
            event = event_form.save(commit=False)
            event.club = user.officer_at
            event.save()
            return render_to_response('pam/event.html', {'event': event, 'user': user})

    return render_to_response('pam/event_add.html', {'user': user, 'event_form': event_form})
예제 #3
0
def event_edit(request, event_id):
    user = check_undergraduate(request.user.username)
    if not user:  # or not request.is_ajax() or not user.officer_at:
        return HttpResponseForbidden()

    event = get_object_or_404(Event, event_id=event_id, club=user.officer_at)
    if request.method == 'POST':
        event_form = EventForm(request.POST, request.FILES, instance=event)
        if event_form.is_valid():
            event = event_form.save()
            return render_to_response('pam/event.html', {
                'event': event,
                'user': user
            })

    event_form = EventForm(instance=event)
    return render_to_response('pam/event_add.html', {
        'user': user,
        'event': event,
        'event_form': event_form
    })
예제 #4
0
def event_add(request):
    user = check_undergraduate(request.user.username)
    if not user:  # or not request.is_ajax() or not user.officer_at:
        return HttpResponseForbidden()

    event_form = EventForm()
    if request.method == 'POST':
        event_form = EventForm(request.POST, request.FILES)
        if event_form.is_valid():
            event = event_form.save(commit=False)
            event.club = user.officer_at
            event.save()
            return render_to_response('pam/event.html', {
                'event': event,
                'user': user
            })

    return render_to_response('pam/event_add.html', {
        'user': user,
        'event_form': event_form
    })