# Path: oshc/main/forms.py
# class ContestForm(forms.ModelForm):
#     def __init__(self, *args, **kwargs):
#         super(ContestForm, self).__init__(*args, **kwargs)
#         self.helper = FormHelper()
#         self.helper.form_tag = False
#         self.helper.label_class = 'col-lg-2'
#         self.helper.field_class = 'col-lg-8'
#         self.fields['start_date'].widget.attrs['class'] = 'datepicker'
#         self.fields['end_date'].widget.attrs['class'] = 'datepicker'
# 
#     class Meta:
#         model = Contest
#         fields = ['name', 'link', 'description', 'start_date', 'end_date']


from django.shortcuts import render
from django.http import HttpResponseRedirect
from main.models import chatSession, Contest, Journey
from .forms import ContestForm


def home(request):
    # chat_session_list = chatSessions.objects.order_by('start_date')[:3]
    # context_dict = {'chatSessions': chat_session_list}
    return render(request, 'index.html')


def about(request):
    return render(request, 'about.html')


def request_session(request):
    return render(request, 'session.html')


def contests(request):
    contest_list = Contest.objects.all()
    return render(
        request, 'contests.html', context={
            'contest_list': contest_list
        })


def contest_new(request):

# Path: oshc/main/forms.py
# class ContestForm(forms.ModelForm):
#     def __init__(self, *args, **kwargs):
#         super(ContestForm, self).__init__(*args, **kwargs)
#         self.helper = FormHelper()
#         self.helper.form_tag = False
#         self.helper.label_class = 'col-lg-2'
#         self.helper.field_class = 'col-lg-8'
#         self.fields['start_date'].widget.attrs['class'] = 'datepicker'
#         self.fields['end_date'].widget.attrs['class'] = 'datepicker'
# 
#     class Meta:
#         model = Contest
#         fields = ['name', 'link', 'description', 'start_date', 'end_date']


# Path: oshc/main/views.py
from django.shortcuts import render
from django.http import HttpResponseRedirect
from main.models import chatSession, Contest, Journey
from .forms import ContestForm



def home(request):
    # chat_session_list = chatSessions.objects.order_by('start_date')[:3]
    # context_dict = {'chatSessions': chat_session_list}
    return render(request, 'index.html')


def about(request):
    return render(request, 'about.html')


def request_session(request):
    return render(request, 'session.html')


def contests(request):
    contest_list = Contest.objects.all()
    return render(
        request, 'contests.html', context={
            'contest_list': contest_list
        })


def contest_new(request):

    form = ContestForm()