1 # -*- coding: utf-8 -*-
2 from django.contrib.flatpages.views import flatpage
3 from django.core.exceptions import ValidationError
4 from django.core.validators import EmailValidator
5 from django.http.response import HttpResponseRedirect
6 from django.shortcuts import render_to_response
7 from django.template.context import RequestContext
8 from django.views.defaults import page_not_found
9 from django.views.generic import TemplateView
10 from pybb.views import ProfileEditView
12 from contact.models import Contact
13 from .forms import AvatarlessEditProfileForm
16 class HomeView(TemplateView):
17 template_name = "home.html"
20 def mil_home_view(request):
21 return flatpage(request, url='/' if request.LANGUAGE_CODE == 'pl' else '/en/')
24 def mil_404_view(request):
25 return page_not_found(request, '404_mil.html')
28 def mil_contact_view(request):
29 return flatpage(request, url='/kontakt_mil/' if request.LANGUAGE_CODE == 'pl' else '/contact_mil/')
32 def mil_knowledge_base_view(request, url):
33 return flatpage(request, url='bazawiedzy/' + url)
36 class AvatarlessProfileEditView(ProfileEditView):
37 form_class = AvatarlessEditProfileForm
40 def olimpiada_teaser(request):
42 email = request.POST.get('email')
44 EmailValidator()(email)
45 Contact.objects.create(
48 ip=request.META['REMOTE_ADDR'],
49 form_tag='olimpiada-teaser')
50 except ValidationError:
52 return HttpResponseRedirect(request.path)
53 return render_to_response('olimpiada_teaser.html', context_instance=RequestContext(request))