<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.views import generic
from django.contrib.auth.mixins import LoginRequiredMixin

from .models import Category, Contest, Submission
from nfn_user.models import C_Owner

from .forms import ContestForm, SubmissionForm


# Contest Listing: List All
class IndexView(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'
	allow_empty = True

	def get_allow_empty(self):
		return self.allow_empty

	def get_queryset(self):
		return Contest.objects.filter(is_approved=True).order_by('-date_started')	

	def get_context_data(self, *args, **kwargs):
		context = super(IndexView, self).get_context_data(*args, **kwargs)
		context['contest_category_list'] = Category.objects.all()
		context['contest_owner_list'] = C_Owner.objects.all()
		return context

# Contest Listing: List Ongoing Contests
class FilterByOngoing(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'

	# ¯\_(ツ)_/¯
	def get_queryset(self):
		q = Contest.objects.filter(is_approved=True)
		context = []
		for contest in q:
			if contest.is_ongoing == "Ongoing":
				context.append(contest)
		return context

	def get_context_data(self, *args, **kwargs):
		context = super(FilterByOngoing, self).get_context_data(*args, **kwargs)
		context['contest_category_list'] = Category.objects.all()
		context['contest_owner_list'] = C_Owner.objects.all()
		return context

# Contest Listing: List Finished Contests
class FilterByFinished(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'

	# ¯\_(ツ)_/¯
	def get_queryset(self):
		q = Contest.objects.filter(is_approved=True)
		context = []
		for contest in q:
			if contest.is_ongoing == "Finished":
				context.append(contest)
		return context
<commit_msg>Update Ongoing/Finished Filter<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.views import generic
from django.contrib.auth.mixins import LoginRequiredMixin

from .models import Category, Contest, Submission
from nfn_user.models import C_Owner

from .forms import ContestForm, SubmissionForm


# Contest Listing: List All
class IndexView(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'
	allow_empty = True

	def get_allow_empty(self):
		return self.allow_empty

	def get_queryset(self):
		return Contest.objects.filter(is_approved=True).order_by('-date_started')

	def get_context_data(self, *args, **kwargs):
		context = super(IndexView, self).get_context_data(*args, **kwargs)
		context['contest_category_list'] = Category.objects.all()
		context['contest_owner_list'] = C_Owner.objects.all()
		return context

# Contest Listing: List Ongoing Contests
class FilterByOngoing(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'

	# ¯\_(ツ)_/¯
	def get_queryset(self):
		q = Contest.objects.filter(is_approved=True).order_by('-date_started')
		context = []
		for contest in q:
			if contest.is_ongoing == "Ongoing":
				context.append(contest)
		return context

	def get_context_data(self, *args, **kwargs):
		context = super(FilterByOngoing, self).get_context_data(*args, **kwargs)
		context['contest_category_list'] = Category.objects.all()
		context['contest_owner_list'] = C_Owner.objects.all()
		return context

# Contest Listing: List Finished Contests
class FilterByFinished(generic.ListView):
	template_name = 'contests/index.html'
	context_object_name = 'contest_list'

	# ¯\_(ツ)_/¯
	def get_queryset(self):
		q = Contest.objects.filter(is_approved=True).order_by('-date_started')
		context = []
		for contest in q:
			if contest.is_ongoing == "Finished":
				context.append(contest)
		return context

{'fraction_non_alphanumeric': 0.11517412935323383, 'fraction_numerical': 0.003482587064676617, 'mean_word_length': 5.624382207578254, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6783226', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1329, 'n_words': 280}