# Path: apps/site/forms.py
# class TeamSelectForm(Form):
# 
#     team = ModelChoiceField(
#         label='', empty_label=_("PICK_A_LOCATION"),
#         queryset=teams,
#         widget=Select(attrs={'class':'form-control'})
#     )
# 
# Path: config/settings.py
# PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))


import os
import random
from django.http import HttpResponseRedirect
from django.views.decorators.http import require_http_methods
from apps.common.shortcuts import render_response
from apps.site.forms import TeamSelectForm
from config.settings import PROJECT_DIR
# -*- coding: utf-8 -*-
# Copyright (c) 2012 Fabian Barkhau <fabian.barkhau@gmail.com>
# License: MIT (see LICENSE.TXT file)




@require_http_methods(['GET', 'POST'])
def index(request):
    if request.method == 'POST':
        form = TeamSelectForm(request.POST)
        if form.is_valid():
            team_link = form.cleaned_data['team'].link
            return HttpResponseRedirect("/%s" % team_link)
    else:

# Path: apps/site/forms.py
# class TeamSelectForm(Form):
# 
#     team = ModelChoiceField(
#         label='', empty_label=_("PICK_A_LOCATION"),
#         queryset=teams,
#         widget=Select(attrs={'class':'form-control'})
#     )
# 
# Path: config/settings.py
# PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))


# Path: apps/site/views.py
import os
import random
from django.http import HttpResponseRedirect
from django.views.decorators.http import require_http_methods
from apps.common.shortcuts import render_response
from apps.site.forms import TeamSelectForm
from config.settings import PROJECT_DIR

# -*- coding: utf-8 -*-
# Copyright (c) 2012 Fabian Barkhau <fabian.barkhau@gmail.com>
# License: MIT (see LICENSE.TXT file)




@require_http_methods(['GET', 'POST'])
def index(request):
    if request.method == 'POST':
        form = TeamSelectForm(request.POST)
        if form.is_valid():
            team_link = form.cleaned_data['team'].link
            return HttpResponseRedirect("/%s" % team_link)
    else:

        form = TeamSelectForm()