def calendar(request):
  # create match from calendar
  if request.method == 'POST':
    match_form = MatchForm(request.POST)
    if match_form.is_valid():
      match = match_form.save(commit=False)
      match.creator = request.user
      match.save()
      return HttpResponse(match.id)
  else:
    return render(request, "match/calendar.html", )
def add(request):
  if request.method == 'POST':
    match = MatchForm(request.POST)
    if match.is_valid():
      new_match = match.save(commit=False)
      new_match.creator = request.user
      new_match.save()
      return HttpResponseRedirect(reverse('match:detail', args=[new_match.id]))
  else:
    match = MatchForm()

  return render(request, 'match/match_form.html', {'match_form' : match}, )
def edit(request, match_id):
  match_obj = get_object_or_404(Match, pk=match_id)
  if request.method == 'POST' and match_obj:
    match = MatchForm(request.POST)
    if match.is_valid():
      match_obj = match.save(commit=False)
      match_obj.creator = request.user
      match_obj.id = match_id
      match_obj.save()
      return HttpResponseRedirect(reverse('match:detail', args=(match_obj.id,)))
  else:
    match = MatchForm(instance=match_obj)
  return render (request, 'match/match_form.html', {'match_form' : match, 'form_type' : 'edit', })
Esempio n. 4
0
def edit_match(request, match_id=None):
    match = get_object_or_404(Match, id=match_id)
    submitted = False
    if request.method == "POST":
        form = MatchForm(request.POST, instance=match)
        if form.is_valid():
            submitted = True
            form.save()
            Notification.objects.edit_match(request.user, match)
    else:
        form = MatchForm(instance=match)
    return render_to_response('match/edit_match.html',
            {'form': form, 'match_id': match_id, 'match': match,
                'submitted': submitted},
            context_instance=RequestContext(request))
Esempio n. 5
0
def match_view(request):
    forms = MatchForm(request.POST or None)
    try:
        if forms.is_valid():
            forms.save()

            return HttpResponseRedirect(reverse('match:score'))

        context = {
            'forms': forms,
        }
        return render(request, 'match/match.html', context)
    except:
        messages.warning(request, "Kayıt Başarısız")