예제 #1
0
def neo_create(request):
    if request.method == 'POST':
        form = NeoForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.user = request.user
            form.save()
            return redirect('/dashboard/')
    else:
        form = NeoForm()
    return render(request, 'neo_edit_or_create.html', {'form': form})
예제 #2
0
파일: views.py 프로젝트: axilleas/anapneo
def neo_create(request):
    if request.method == 'POST':
        form = NeoForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.user = request.user
            form.save()
            return redirect('/dashboard/')
    else:
        form = NeoForm()
    return render(request, 'neo_edit_or_create.html', {'form': form})
예제 #3
0
파일: views.py 프로젝트: axilleas/anapneo
def neo_edit(request, u_id):
    try:
        obj = Neo.objects.get_or_create(id=u_id, user=request.user)
        if request.method == 'POST':
            form = NeoForm(request.POST, instance=obj)
            if form.is_valid():
                f = form.save(commit=False)
                f.user = request.user
                form.save()
                return redirect('/dashboard/')
        else:
            form = NeoForm()
        return render(request, 'neo_edit_or_create.html', {'form': form})

    except Neo.DoesNotExist:
        return redirect('/dashboard/')
예제 #4
0
def neo_edit(request, u_id):
    try:
        obj = Neo.objects.get_or_create(id=u_id, user=request.user)
        if request.method == 'POST':
            form = NeoForm(request.POST, instance=obj)
            if form.is_valid():
                f = form.save(commit=False)
                f.user = request.user
                form.save()
                return redirect('/dashboard/')
        else:
            form = NeoForm()
        return render(request, 'neo_edit_or_create.html', {'form': form})

    except Neo.DoesNotExist:
        return redirect('/dashboard/')
예제 #5
0
파일: views.py 프로젝트: achronop/anapneo
def neo_edit(request, no):
    me = UserProfile.objects.get(user=request.user)
    try:
        obj = Neo.objects.get_or_create(no=no, user=request.user)
        if request.method == 'POST':
            form = NeoForm(request.POST, instance=obj)
            if form.is_valid():
                f = form.save(commit=False)
                f.user = request.user
                form.save()
                return redirect('/dashboard/')
        else:
            form = NeoForm()
        return render(request, 'neo_edit_or_create.html', {'form': form, 'me': me})

    except Neo.DoesNotExist:
        return redirect('/dashboard/')
예제 #6
0
파일: views.py 프로젝트: johngian/anapneo
def neo_create(request):
    if request.method == 'POST':
        form = NeoForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.user = request.user
            curdate = datetime.now()
            latest_no = Neo.objects.filter(created__year=curdate.strftime("%Y"),
                        created__month=curdate.strftime("%m"),
                        created__day=curdate.strftime("%d")).count()
            new_no = latest_no + 1
            tmpid = "%03d" % ( new_no )
            f.no = str(curdate.strftime("%Y%m%d")) + tmpid
            form.save()
            return redirect('/dashboard/')
    else:
        form = NeoForm()
    return render(request, 'neo_edit_or_create.html', {'form': form})
예제 #7
0
def neo_create(request):
    if request.method == 'POST':
        form = NeoForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.user = request.user
            curdate = datetime.now()
            latest_no = Neo.objects.filter(
                created__year=curdate.strftime("%Y"),
                created__month=curdate.strftime("%m"),
                created__day=curdate.strftime("%d")).count()
            new_no = latest_no + 1
            tmpid = "%03d" % (new_no)
            f.no = str(curdate.strftime("%Y%m%d")) + tmpid
            form.save()
            return redirect('/dashboard/')
    else:
        form = NeoForm()
    return render(request, 'neo_edit_or_create.html', {'form': form})
예제 #8
0
def neo_edit(request, no):
    me = UserProfile.objects.get(user=request.user)
    try:
        obj = Neo.objects.get_or_create(no=no, user=request.user)
        if request.method == 'POST':
            form = NeoForm(request.POST, instance=obj)
            if form.is_valid():
                f = form.save(commit=False)
                f.user = request.user
                form.save()
                return redirect('/dashboard/')
        else:
            form = NeoForm()
        return render(request, 'neo_edit_or_create.html', {
            'form': form,
            'me': me
        })

    except Neo.DoesNotExist:
        return redirect('/dashboard/')