def submit(request): if request.method == 'POST': form = SubmitForm(request.POST) if form.is_valid(): form.save(request) return HttpResponseRedirect('/') else: form = SubmitForm() return direct_to_template(request, 'submit.html', {'form': form})
def submit(request): if request.method == 'POST': form = SubmitForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/thanks') else: form = SubmitForm(initial={'submitter': request.user.id}) return render_to_response('submit.html', { 'form': form }, context_instance=RequestContext(request))
def submit(request): if request.method == 'POST': form = SubmitForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/thanks') else: form = SubmitForm(initial={'submitter': request.user.id}) return render_to_response('submit.html', {'form': form}, context_instance=RequestContext(request))
def submit(request): if request.method == 'POST': form = SubmitForm(request.POST) if form.is_valid(): form.save(request) return HttpResponseRedirect('/') else: form = SubmitForm() return direct_to_template(request, 'submit.html', { 'form': form })
def edit(request, strike_id): strike = get_object_or_404(Strike, pk=strike_id) if request.method == 'POST': form = SubmitForm(request.POST, instance=strike) if form.is_valid(): form.save() return HttpResponseRedirect('/submissions') else: form = SubmitForm(instance=strike) return render_to_response('submit.html', { 'form': form }, context_instance=RequestContext(request))
def edit(request, strike_id): strike = get_object_or_404(Strike, pk=strike_id) if request.method == 'POST': form = SubmitForm(request.POST, instance=strike) if form.is_valid(): form.save() return HttpResponseRedirect('/submissions') else: form = SubmitForm(instance=strike) return render_to_response('submit.html', {'form': form}, context_instance=RequestContext(request))
def submit(req): if req.method == 'GET': form = SubmitForm() return render_to_response('problem_submit.html', { 'path': req.path, 'form': form }, context_instance=RequestContext(req)) if req.method == 'POST': form = SubmitForm(req.POST) form.set_user(req.user) form.set_contest(req.POST.get('contest', -1)) if form.is_valid(): new_submit = form.save() con = Connect() receive = con.judge_code(new_submit.id) logger.info(receive) logger.info(u"User: "******"s Submited Problem: <" + new_submit.problem.oj + str( new_submit.problem.problem_id) + u"> Title: " + new_submit.problem.title) if form.contest_id >= 0: return HttpResponseRedirect("/contest/c/" + str(form.contest_id)) # + "?status=1" return HttpResponseRedirect("/status") else: return render_to_response("problem_submit.html", { 'path': req.path, 'form': form, }, context_instance=RequestContext(req))
def submit(request, game_type): game = get_object_or_404(Game, slug=game_type) ParticipantFormSet = formset_factory(ParticipantForm, formset=RequiredFormSet, max_num=game.players_per_side, extra=game.players_per_side) if request.method == 'POST': form = SubmitForm(request.POST) formset = ParticipantFormSet(request.POST) if form.is_valid() and formset.is_valid(): # Get all the uids given uid_set = set([ u.id for u in chain.from_iterable([ d.cleaned_data.values() for d in [ f for f in formset.forms ] ])]) if len(uid_set) != game.players_per_side * 2: # FIXME This may not be the right way to handle this, but at least # it doesn't try to save something wrong. raise forms.ValidationError("Cannot repeat participants.") match = form.save(request, game) [ f.save(match) for f in formset.forms ] compute_rankings_for_match(match) return HttpResponseRedirect(game.get_absolute_url()) else: form = SubmitForm() formset = ParticipantFormSet() return render(request, 'match/submit.html', { 'form': form, 'formset': formset })
def submit(request, game_type): game = get_object_or_404(Game, slug=game_type) ParticipantFormSet = formset_factory(ParticipantForm, formset=RequiredFormSet, max_num=game.players_per_side, extra=game.players_per_side) if request.method == 'POST': form = SubmitForm(request.POST) formset = ParticipantFormSet(request.POST) if form.is_valid() and formset.is_valid(): # Get all the uids given uid_set = set([ u.id for u in chain.from_iterable([ d.cleaned_data.values() for d in [f for f in formset.forms] ]) ]) if len(uid_set) != game.players_per_side * 2: # FIXME This may not be the right way to handle this, but at least # it doesn't try to save something wrong. raise forms.ValidationError("Cannot repeat participants.") match = form.save(request, game) [f.save(match) for f in formset.forms] compute_rankings_for_match(match) return HttpResponseRedirect(game.get_absolute_url()) else: form = SubmitForm() formset = ParticipantFormSet() return render(request, 'match/submit.html', { 'form': form, 'formset': formset })
def submit(request, game_type): # XXX Set this as part of the url try: game = Game.objects.get(slug=game_type) except Game.DoesNotExist: game = Game.objects.create(slug="pingpong", name="Ping Pong", require_results=True) ParticipantFormSet = formset_factory( ParticipantForm, formset=RequiredFormSet, max_num=game.players_per_side, extra=game.players_per_side ) if request.method == "POST": form = SubmitForm(request.POST) formset = ParticipantFormSet(request.POST) if form.is_valid() and formset.is_valid(): # Get all the uids given uid_set = set( [u.id for u in chain.from_iterable([d.cleaned_data.values() for d in [f for f in formset.forms]])] ) if len(uid_set) != game.players_per_side * 2: # FIXME This may not be the right way to handle this, but at least # it doesn't try to save something wrong. raise forms.ValidationError("Cannot repeat participants.") match = form.save(request, game) [f.save(match) for f in formset.forms] compute_rankings_for_match(match) return HttpResponseRedirect("/") else: form = SubmitForm() formset = ParticipantFormSet() return render(request, "match/submit.html", {"form": form, "formset": formset})
def submit_order(request, orderid): """ Change the order status from CLIENT_EDITING to CLIENT_SUBMITTED, and notify waiters. TODO - error handling, logging, """ if request.user.is_staff: order = WorkingOrder.objects.get(pk=orderid) else: order = request.user.workingorder_set.get(id=orderid) if order.status != BaseOrder.Const.DEALER_EDIT: return HttpResponseServerError() # always submit orders in the context of proper account account = order.owner.get_profile().account if request.method == "GET": form = SubmitForm(instance=order) else: form = SubmitForm(request.POST, instance=order) if form.is_valid(): order = form.save(commit=False) cost = order.cost or decimal.Decimal() if cost > account.credit_balance: ## users account doesn't have enough juice.. send then to the ecom engine ## to pay, then get them back here ... order = form.save() products = [form.cleaned_data["design_product"]] option = form.cleaned_data.get("processing_option", None) if option: products.append(option) new_cart(request, products) request.method = "GET" return paypal_checkout(request, success_url=reverse("submit-order", args=[orderid])) else: register_design_order(order.owner, order.owner.get_profile().account, order, cost) order = form.save(commit=False) order.status = BaseOrder.Const.SUBMITTED order.submitted = datetime.now() order.save() # return HttpResponseRedirect('completed_order_summary', args=[orderid]) # TODO return HttpResponseRedirect(reverse("submit-order-completed", args=[order.id])) return dict(order=order, form=form)