예제 #1
0
def removeoldvotes(request, sel_event_id):
    # Check rights
    if not request.user.has_perms("kompomaatti.delete_vote"):
        raise Http403

    # Don't proceed if the event is still ongoing
    event = get_object_or_404(Event, pk=int(sel_event_id))
    if utils.is_event_ongoing(event):
        raise Http404

    # Find compos belonging to this event
    compo_ids = Compo.objects.filter(event_id=int(sel_event_id)).values("pk")

    # Don't allow removing votes if votes haven't yet been consolidated to entry rows (prevent data loss)
    if utils.is_votes_unoptimized(compo_ids):
        raise Http404

    # Delete votes belonging to compos in this event
    Vote.objects.filter(compo__in=compo_ids).delete()

    # Log it
    logger.info("Event old votes removed.", extra={"user": request.user, "event": event})

    # All done, redirect
    return HttpResponseRedirect(reverse("manage-arkisto:archiver", args=(sel_event_id,)))
예제 #2
0
파일: views.py 프로젝트: k2h/Instanssi.org
def removeoldvotes(request, sel_event_id):
    # Check rights
    if not request.user.has_perms('kompomaatti.delete_vote'):
        raise Http403

    # Don't proceed if the event is still ongoing
    event = get_object_or_404(Event, pk=int(sel_event_id))
    if utils.is_event_ongoing(event):
        raise Http404

    # Find compos belonging to this event
    compo_ids = Compo.objects.filter(event_id=int(sel_event_id)).values('pk')

    # Don't allow removing votes if votes haven't yet been consolidated to entry rows (prevent data loss)
    if utils.is_votes_unoptimized(compo_ids):
        raise Http404

    # Delete votes belonging to compos in this event
    Vote.objects.filter(compo__in=compo_ids).delete()

    # Log it
    logger.info('Event old votes removed.',
                extra={
                    'user': request.user,
                    'event': event
                })

    # All done, redirect
    return HttpResponseRedirect(
        reverse('manage-arkisto:archiver', args=(sel_event_id, )))
예제 #3
0
def archiver(request, sel_event_id):
    # Get event information
    event = get_object_or_404(Event, pk=sel_event_id)

    # Get archive user information for future use
    archiveuser = get_object_or_404(User, username="******")

    # Get Compo id's belonging to this event for future use
    compo_ids = Compo.objects.filter(event_id=int(sel_event_id)).values("pk")

    # Check if there are any compo entries that are not owner by archive user
    untransferred = False
    entries = Entry.objects.filter(compo__in=compo_ids)
    for entry in entries:
        if entry.user != archiveuser:
            untransferred = True
            break

    # Check if there are any participations that are not owner by archive user
    if not untransferred:
        competition_ids = Competition.objects.filter(event_id=int(sel_event_id)).values("pk")
        participations = CompetitionParticipation.objects.filter(competition__in=competition_ids)
        for part in participations:
            if part.user != archiveuser:
                untransferred = True
                break

    # Check if voting results need to be optimized
    votes_unoptimized = utils.is_votes_unoptimized(compo_ids)

    # Check if event is still ongoing
    ongoing_activity = utils.is_event_ongoing(event)

    # See if there are any old votes left
    old_votes_found = False
    votes = Vote.objects.filter(compo__in=compo_ids)
    if len(votes) > 0:
        old_votes_found = True

    # Render response
    return admin_render(
        request,
        "admin_arkisto/archiver.html",
        {
            "selected_event_id": int(sel_event_id),
            "is_archived": event.archived,
            "untransferred": untransferred,
            "ongoing_activity": ongoing_activity,
            "votes_unoptimized": votes_unoptimized,
            "old_votes_found": old_votes_found,
        },
    )
예제 #4
0
파일: views.py 프로젝트: k2h/Instanssi.org
def archiver(request, sel_event_id):
    # Get event information
    event = get_object_or_404(Event, pk=sel_event_id)

    # Get archive user information for future use
    archiveuser = get_object_or_404(User, username="******")

    # Get Compo id's belonging to this event for future use
    compo_ids = Compo.objects.filter(event_id=int(sel_event_id)).values('pk')

    # Check if there are any compo entries that are not owner by archive user
    untransferred = False
    entries = Entry.objects.filter(compo__in=compo_ids)
    for entry in entries:
        if entry.user != archiveuser:
            untransferred = True
            break

    # Check if there are any participations that are not owner by archive user
    if not untransferred:
        competition_ids = Competition.objects.filter(
            event_id=int(sel_event_id)).values('pk')
        participations = CompetitionParticipation.objects.filter(
            competition__in=competition_ids)
        for part in participations:
            if part.user != archiveuser:
                untransferred = True
                break

    # Check if voting results need to be optimized
    votes_unoptimized = utils.is_votes_unoptimized(compo_ids)

    # Check if event is still ongoing
    ongoing_activity = utils.is_event_ongoing(event)

    # See if there are any old votes left
    old_votes_found = False
    votes = Vote.objects.filter(compo__in=compo_ids)
    if len(votes) > 0:
        old_votes_found = True

    # Render response
    return admin_render(
        request, "admin_arkisto/archiver.html", {
            'selected_event_id': int(sel_event_id),
            'is_archived': event.archived,
            'untransferred': untransferred,
            'ongoing_activity': ongoing_activity,
            'votes_unoptimized': votes_unoptimized,
            'old_votes_found': old_votes_found,
        })