示例#1
0
文件: views.py 项目: kyoshino/kuma
def edit(request, slug):
    """Edit a demo"""
    submission = get_object_or_404(Submission, slug=slug)
    if not submission.allows_editing_by(request.user):
        return HttpResponseForbidden(_('access denied') + '')

    if request.method != "POST":
        form = SubmissionEditForm(
            instance=submission, request_user=request.user)
    else:
        form = SubmissionEditForm(request.POST, request.FILES,
                instance=submission, request_user=request.user)
        if form.is_valid():

            sub = form.save()

            # TODO: Process in a cronjob?
            sub.process_demo_package()
            _invalidate_submission_listing_helper_cache()

            return HttpResponseRedirect(reverse(
                    'demos.views.detail', args=(sub.slug,)))

    return render(request, 'demos/submit.html', {
        'form': form, 'submission': submission, 'edit': True})
示例#2
0
 def test_derby_after_deadline(self):
     s = save_valid_submission('hello world')
     closed_dt = datetime.date.today() - datetime.timedelta(days=32)
     s.taggit_tags.set_ns('challenge:', closed_dt.strftime('%Y:%B').lower())
     form = SubmissionEditForm(instance=s)
     assert 'demo_package' not in form.fields
     assert 'challenge_tags' not in form.fields
示例#3
0
def edit(request, slug):
    """Edit a demo"""
    submission = get_object_or_404(Submission, slug=slug)
    if not submission.allows_editing_by(request.user):
        return HttpResponseForbidden(_('access denied') + '')

    if request.method != "POST":
        form = SubmissionEditForm(instance=submission,
                                  request_user=request.user)
    else:
        form = SubmissionEditForm(request.POST,
                                  request.FILES,
                                  instance=submission,
                                  request_user=request.user)
        if form.is_valid():

            sub = form.save()

            # TODO: Process in a cronjob?
            sub.process_demo_package()
            _invalidate_submission_listing_helper_cache()

            return HttpResponseRedirect(
                reverse('demos.views.detail', args=(sub.slug, )))

    return render(request, 'demos/submit.html', {
        'form': form,
        'submission': submission,
        'edit': True
    })
示例#4
0
 def test_derby_before_deadline(self):
     s = save_valid_submission('hello world')
     s.taggit_tags.set_ns('challenge:', make_challenge_tag())
     form = SubmissionEditForm(instance=s)
     assert 'demo_package' in form.fields
     assert 'challenge_tags' in form.fields