Exemple #1
0
def show_event(request, permalink, ajax=None):
  if request.POST:
    if not request.user.is_authenticated():
      if ajax:
        return json_error('LOGIN')
      else:
        return HttpResponseRedirect(full_url('LOGIN') + '?next=%s&reason=vote' % request.path)
    form = rating_helper.handle_rating(RatingForm(request.POST),request.user)
    valid = form.is_valid()
    if ajax:
      return json_success() if valid else json_error("Hmm serwer nawalil?");

  event = get_object_or_404(Event,permalink = permalink)
  nominated = Nominated.objects.with_rates(event)
 
  # randomize lists if event status is open
  if event.event_status == Event.STATUS_OPEN:
    previous_type = -1
    itemlist = []
    new_nominated = []
    for item in nominated:
      current_type = item.oscar_type
      if current_type == previous_type: pass
      elif previous_type==-1: pass
      else:
        shuffle_and_extend(itemlist, new_nominated)
        itemlist = []
      itemlist.append(item)
      previous_type=current_type
    # this shuffles and extends for the last category
    shuffle_and_extend(itemlist, new_nominated)

    # finished!
    nominated = new_nominated

  ctx = {
    'event':event,
    'nominated':nominated
  }

  return render_to_response('event/event.html', ctx, context_instance=RequestContext(request))
Exemple #2
0
def rate_films_fast_forward(request, ajax=None):
    if request.POST:
        if not request.user.is_authenticated():
            if ajax:
                return json_error('LOGIN')
            else:
                return HttpResponseRedirect(full_url('LOGIN') + '?next=%s&reason=vote' % request.path)
        form = rating_helper.handle_rating(RatingForm(request.POST),request.user)
        valid = form.is_valid()
        print "valid=" + str(valid)
        if ajax:
            print "ajax"
            return json_success() if valid else json_error("Hmm serwer nawalil?");

    films1 = []
    films2 = []
    for i in range(1, 6):
        film = rating_helper.get_next_film(request)
        films1.append(film)
        print "got film: " + film.title

    for j in range(1, 6):
        film = rating_helper.get_next_film(request)
        films2.append(film)
        print "got film: " + film.title

    context = {
        'films1': films1,
        'films2': films2
    }

    return render_to_response(
        templates['RATE_FILMS_FAST_FORWARD'], 
        context, 
        context_instance=RequestContext(request),
    )
Exemple #3
0
def rate_films_fast_forward(request, ajax=None):
    if request.POST:
        if not request.user.is_authenticated():
            if ajax:
                return json_error('LOGIN')
            else:
                return HttpResponseRedirect(
                    full_url('LOGIN') + '?next=%s&reason=vote' % request.path)
        form = rating_helper.handle_rating(RatingForm(request.POST),
                                           request.user)
        valid = form.is_valid()
        print "valid=" + str(valid)
        if ajax:
            print "ajax"
            return json_success() if valid else json_error(
                "Hmm serwer nawalil?")

    films1 = []
    films2 = []
    for i in range(1, 6):
        film = rating_helper.get_next_film(request)
        films1.append(film)
        print "got film: " + film.title

    for j in range(1, 6):
        film = rating_helper.get_next_film(request)
        films2.append(film)
        print "got film: " + film.title

    context = {'films1': films1, 'films2': films2}

    return render_to_response(
        templates['RATE_FILMS_FAST_FORWARD'],
        context,
        context_instance=RequestContext(request),
    )