Ejemplo n.º 1
0
def create(request):
    success = False
    try:
        if request.method == "POST":
            form = EventForm(request.POST)
            if form.is_valid():
                try:
                    #                    party = Party.objects.get(slug=request.party)
                    #                    schedule = Schedule.objects.get(party=party)
                    event = form.save(commit=False)
                    party = Party.objects.get(slug=request.party)
                    event.save()
                # schedule.events.add(event)
                except Exception as e:
                    print e
                success = True
                return admin(request, event.pk, True, "Event created", party=request.party)

        else:
            form = EventForm()

        return render_to_response(
            "events_createform.html", {"form": form, "success": success}, context_instance=RequestContext(request)
        )
    except Exception as e:
        pass
    party = Party.objects.get(slug=party)
    return render_to_response("schedule_index.html", {"party": party}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
Archivo: views.py Proyecto: 3241966/PMS
def create(request):
    success = False
    try:
        if request.method == 'POST':
            form = EventForm(request.POST)
            if form.is_valid():
                try:
#                    party = Party.objects.get(slug=request.party)
#                    schedule = Schedule.objects.get(party=party)
                    event = form.save(commit=False)
#                    import pdb
#                    pdb.set_trace()
                    event.original_time = event.time
                    party = Party.objects.get(slug=request.party)
                    event.save()
                   # schedule.events.add(event)
                except Exception as e:
                    print e
                success = True
                return admin(request, event.pk, True, 'Event created',
                party=request.party)
        else:
            form = EventForm()

        return render_to_response(
            "events_createform.html",
            {'form': form,
             'success': success},
            context_instance=RequestContext(request))
    except Exception as e:
        pass
    party = Party.objects.get(slug=party)
    return render_to_response('schedule_index.html', {'party':party},context_instance=RequestContext(request))
Ejemplo n.º 3
0
Archivo: views.py Proyecto: 3241966/PMS
def admin(request, event, success=False, status=None):
    """
    Basic handling of event objects-
    """
    try:
        event = Event.objects.get(pk=event)
    except Event.DoesNotExist:
        return HttpResponseNotFound
    if request.method == 'POST' and not success:
        form = EventForm(request.POST,instance=event)
        if form.is_valid():
            form.save()
            success=True
            status='Event updated'
    else:
        form = EventForm(instance=event)

    return render_to_response("events_adminform.html",{'form':form,'success':success,'event' :event, 'status':status},context_instance=RequestContext(request))