예제 #1
0
파일: views.py 프로젝트: jsnhff/rhizome.org
def submit(request, object_id):
    cycle = get_object_or_404(Cycle, pk=object_id)
    user = request.user
    proposal_form = ProposalForm(initial={'author': request.user})
    today = datetime.datetime.now()

    if request.method == 'POST':
        proposal_form = ProposalForm(request.POST,
                                     request.FILES or None,
                                     initial={'author': request.user})

        if proposal_form.is_valid():
            user.first_name = request.POST['first_name']
            user.last_name = request.POST['last_name']
            user.save()

            proposal = proposal_form.save(commit=False)
            proposal.cycle = cycle
            proposal.author = user
            proposal.email = user.email
            proposal.username = user.get_full_name()

            if proposal.cycle.is_tumblr_commission:
                proposal.is_public = False
                proposal.allow_comments = False

            proposal.save()

            # verification of artist accounts for m2m is handled via the form
            cleaned_user_list = proposal_form.cleaned_data[
                'other_artists_users']

            if cleaned_user_list:
                for user in cleaned_user_list:
                    proposal.artists.add(user)

            proposal.save()

            if proposal.image:
                # create_thumbnails uses saved image
                proposal.thumbnail = create_thumbnail(proposal.image)

            if request.POST['status'] == 'preview':
                proposal.save()
                return redirect('commissions_proposal_preview',
                                proposal_id=proposal.id)

            elif request.POST['status'] == 'save':
                proposal.save()
                return HttpResponseRedirect(
                    '%s?save=True' %
                    reverse('commissions_proposal_edit', args=[proposal.id]))

            elif request.POST['status'] == 'publish':
                proposal.submitted = 1
                proposal.save()
                proposal.send_published_proposal_notification_email()
                return HttpResponseRedirect(
                    '%s?thanks=True' %
                    reverse('commissions_proposal_detail', args=[proposal.id]))
        else:
            proposal_form = ProposalForm(request.POST,
                                         request.FILES or None,
                                         initial={'author': request.user})

    if today > cycle.submission_start_date and today < cycle.submission_end_date:
        return render_to_response('commissions/submit.html', {
            'proposal_form': proposal_form,
            'cycle': cycle,
        }, RequestContext(request))
    else:
        return redirect('commissions_index')
예제 #2
0
파일: views.py 프로젝트: hgw/rhizome.org
def submit(request, object_id):
    cycle = get_object_or_404(Cycle, pk=object_id)
    user = request.user
    proposal_form = ProposalForm(initial={'author':request.user})
    today = datetime.datetime.now()

    if request.method == 'POST':
        proposal_form = ProposalForm(request.POST, request.FILES or None, initial={'author':request.user})

        if proposal_form.is_valid():
            user.first_name = request.POST['first_name']
            user.last_name = request.POST['last_name']
            user.save()

            proposal = proposal_form.save(commit=False)
            proposal.cycle = cycle
            proposal.author = user
            proposal.email = user.email
            proposal.username = user.get_full_name()

            if proposal.cycle.is_tumblr_commission:
                proposal.is_public = False
                proposal.allow_comments = False

            proposal.save()

            # verification of artist accounts for m2m is handled via the form
            cleaned_user_list = proposal_form.cleaned_data['other_artists_users']

            if cleaned_user_list:
                for user in cleaned_user_list:
                    proposal.artists.add(user)

            proposal.save()

            if proposal.image:
                # create_thumbnails uses saved image
                proposal.thumbnail = create_thumbnail(proposal.image)

            if request.POST['status'] == 'preview':
                proposal.save()
                return redirect('commissions_proposal_preview', proposal_id=proposal.id)

            elif request.POST['status'] == 'save':
                proposal.save()
                return HttpResponseRedirect('%s?save=True' % reverse('commissions_proposal_edit', args=[proposal.id]))

            elif request.POST['status'] == 'publish':
                proposal.submitted = 1
                proposal.save()
                proposal.send_published_proposal_notification_email()
                return HttpResponseRedirect('%s?thanks=True' % reverse('commissions_proposal_detail', args=[proposal.id]))
        else:
            proposal_form = ProposalForm(request.POST,request.FILES or None, initial={'author':request.user})

    if today > cycle.submission_start_date and today < cycle.submission_end_date:
        return render_to_response(
            'commissions/submit.html', {
                'proposal_form': proposal_form,
                'cycle': cycle,
            },
            RequestContext(request)
        )
    else:
        return redirect('commissions_index')
예제 #3
0
파일: views.py 프로젝트: jsnhff/rhizome.org
def proposal_edit(request, proposal_id):
    proposal = get_object_or_404(Proposal, pk=proposal_id)
    user = request.user
    proposal_form = ProposalForm(initial={'author': request.user})
    other_artists_list = None
    today = datetime.datetime.now()

    if proposal.get_artists():
        other_artists_list = ', '.join(
            ['%s' % artist.email for artist in proposal.get_artists()])

    proposal_form = ProposalForm(request.POST or None, request.FILES or None, \
            instance=proposal.id and Proposal.objects.get(id=proposal.id ), \
            initial={'other_artists_users':other_artists_list })

    if request.method == 'POST':
        proposal_form = ProposalForm(request.POST or None, request.FILES or None, \
                instance=proposal.id and Proposal.objects.get(id=proposal.id ), \
                initial={'other_artists_users':str(other_artists_list) })

        if proposal_form.is_valid():
            user.first_name = request.POST['first_name']
            user.last_name = request.POST['last_name']
            user.save()

            proposal = proposal_form.save(commit=False)

            if request.POST['status'] == 'delete':
                proposal.delete()
                return HttpResponseRedirect('%s?deleted=True' %
                                            reverse('commissions_index'))

            proposal.author = user
            proposal.email = user.email
            proposal.username = user.get_full_name()

            # verification of artist accounts for m2m is handled via the form
            cleaned_user_list = proposal_form.cleaned_data[
                'other_artists_users']

            if cleaned_user_list:
                for user in cleaned_user_list:
                    proposal.artists.add(user)

            proposal.save()

            if proposal.image:
                # create_thumbnails uses saved image
                proposal.thumbnail = create_thumbnail(proposal.image)

            if request.POST['status'] == 'preview':
                proposal.save()
                return redirect('commissions_proposal_preview',
                                proposal_id=proposal.id)

            elif request.POST['status'] == 'save':
                proposal.save()
                return HttpResponseRedirect(
                    '%s?save=True' %
                    reverse('commissions_proposal_edit', args=[proposal.id]))

            elif request.POST['status'] == 'publish':
                proposal.submitted = 1
                proposal.save()
                proposal.send_published_proposal_notification_email()
                return HttpResponseRedirect(
                    '%s?thanks=True' %
                    reverse('commissions_proposal_detail', args=[proposal.id]))
        else:
            proposal_form = ProposalForm(request.POST,
                                         request.FILES or None,
                                         initial={'author': request.user})

    if request.user == proposal.author \
        and today > proposal.cycle.submission_start_date \
        and today < proposal.cycle.submission_end_date:
        return render_to_response('commissions/submit.html', {
            'proposal_form': proposal_form,
            'cycle': proposal.cycle
        }, RequestContext(request))
    else:
        return redirect('commissions_index')
예제 #4
0
파일: views.py 프로젝트: hgw/rhizome.org
def proposal_edit(request, proposal_id):
    proposal = get_object_or_404(Proposal, pk=proposal_id)
    user = request.user
    proposal_form = ProposalForm(initial={'author':request.user})
    other_artists_list = None
    today = datetime.datetime.now()

    if proposal.get_artists():
        other_artists_list = ', '.join(['%s' % artist.email for artist in proposal.get_artists()])

    proposal_form = ProposalForm(request.POST or None, request.FILES or None, \
            instance=proposal.id and Proposal.objects.get(id=proposal.id ), \
            initial={'other_artists_users':other_artists_list })

    if request.method == 'POST':
        proposal_form = ProposalForm(request.POST or None, request.FILES or None, \
                instance=proposal.id and Proposal.objects.get(id=proposal.id ), \
                initial={'other_artists_users':str(other_artists_list) })

        if proposal_form.is_valid():
            user.first_name = request.POST['first_name']
            user.last_name = request.POST['last_name']
            user.save()

            proposal = proposal_form.save(commit=False)

            if request.POST['status'] == 'delete':
                proposal.delete()
                return HttpResponseRedirect('%s?deleted=True' % reverse('commissions_index'))

            proposal.author = user
            proposal.email = user.email
            proposal.username = user.get_full_name()

            # verification of artist accounts for m2m is handled via the form
            cleaned_user_list = proposal_form.cleaned_data['other_artists_users']

            if cleaned_user_list:
                for user in cleaned_user_list:
                    proposal.artists.add(user)

            proposal.save()

            if proposal.image:
                # create_thumbnails uses saved image
                proposal.thumbnail = create_thumbnail(proposal.image)

            if request.POST['status'] == 'preview':
                proposal.save()
                return redirect('commissions_proposal_preview', proposal_id=proposal.id)

            elif request.POST['status'] == 'save':
                proposal.save()
                return HttpResponseRedirect('%s?save=True' % reverse('commissions_proposal_edit', args=[proposal.id]))

            elif request.POST['status'] == 'publish':
                proposal.submitted = 1
                proposal.save()
                proposal.send_published_proposal_notification_email()
                return HttpResponseRedirect('%s?thanks=True' % reverse('commissions_proposal_detail', args=[proposal.id]))
        else:
            proposal_form = ProposalForm(request.POST,request.FILES or None, initial={'author':request.user})

    if request.user == proposal.author \
        and today > proposal.cycle.submission_start_date \
        and today < proposal.cycle.submission_end_date:
        return render_to_response('commissions/submit.html', {'proposal_form':proposal_form, 'cycle':proposal.cycle}, RequestContext(request))
    else:
        return redirect('commissions_index')