예제 #1
0
def delete_schedule(request, schedule_id):
    try:
        cs = ContactSchedules.objects.get(id=schedule_id, user=request.user)
        cs.delete()
        messages.success(request, 'schedule deleted')
        return HttpResponseRedirect(reverse('dashboard'))
    except Exception, e:
        return general_error(request, title='Error Deleting Schedule', message=e.message, redirect='contacts.views.dashboard')
예제 #2
0
def delete_contact(request, contact_id):
    try:
        c = Contact.active.get(id=contact_id, user=request.user)

        if request.method == 'POST':
            c.delete()

            messages.success(request, 'contact deleted')
            return HttpResponseRedirect(reverse('dashboard'))
        else:
            return render_to_response('contacts/delete_contact.html', {'dashboard_active':'active', 'contact':c},
                                      context_instance=RequestContext(request))
    except Exception, e:
        return general_error(request, title='Error Deleting Contact', message=e.message, redirect='contacts.views.dashboard')
예제 #3
0
def new_schedule(request):
    try:
        if request.method == 'POST':
            form = NewScheduleForm(data=request.POST)
            if form.is_valid():
                new_schedule = form.save(commit=False)
                new_schedule.user = request.user
                new_schedule.save()
                messages.success(request, 'new schedule added')
                return HttpResponseRedirect(reverse('dashboard'))
        else:
            form = NewScheduleForm(request.user)

            return render_to_response('contacts/new_schedule.html', {'dashboard_active':'active', 'form':form},
                                    context_instance=RequestContext(request))
    except Exception, e:
        return general_error(request, title='Error Creating Schedule', message=e.message, redirect='contacts.views.dashboard')
예제 #4
0
def edit_schedule(request, schedule_id):
    try:
        if request.method == 'POST':
            form = NewScheduleForm(data=request.POST)
            if form.is_valid():
                cs = form.save(commit=False)
                cs.id = schedule_id
                cs.user_id = request.user.id
                cs.save()

                messages.success(request, "schedule edited")
                return HttpResponseRedirect(reverse('dashboard'))
        else:
            cs = ContactSchedules.objects.get(id=schedule_id, user=request.user)
            form = NewScheduleForm(instance=cs)

            return render_to_response('contacts/edit_schedule.html', {'dashboard_active':'active', 'form':form, 'schedule':cs},
                                        context_instance=RequestContext(request))
    except Exception, e:
        return general_error(request, title='Error Editing Schedule', message=e.message, redirect='contacts.views.dashboard')