teaser stub
authorJan Szejko <jan.szejko@gmail.com>
Wed, 1 Jun 2016 16:09:57 +0000 (18:09 +0200)
committerJan Szejko <jan.szejko@gmail.com>
Wed, 1 Jun 2016 16:09:57 +0000 (18:09 +0200)
edumed/templates/olimpiada_teaser.html [new file with mode: 0644]
edumed/urls.py
edumed/views.py

diff --git a/edumed/templates/olimpiada_teaser.html b/edumed/templates/olimpiada_teaser.html
new file mode 100644 (file)
index 0000000..071e68e
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "base_super.html" %}
+
+{% block logo %}{% endblock %}
+{% block title %}Olimpiada cyfrowa{% endblock %}
+
+{% block body %}
+  <img src="http://edukacjamedialna.edu.pl/media/chunks/attachment/olimpiada_cyfrowa-srednie.png"/>
+  <h1>Tutaj będzie coś zajebistego!</h1>
+  <p>Podaj swój adres e-mail, żeby dostać powiadomienie:</p>
+  <form method="post" action="">
+    {% csrf_token %}
+    <label><input type="text" name="email"/></label>
+    <input type="submit" value="Wyślij">
+  </form>
+{% endblock %}
\ No newline at end of file
index 32eb97e..2d0d0a0 100644 (file)
@@ -15,6 +15,7 @@ urlpatterns = patterns(
     url(r'^info/(?P<url>.*)$', flatpage, name="info"),
     url(r'^olimpiada/$', lambda request: flatpage(request, 'turniej/'), name='olimpiada'),
     url(r'^olimpiada/(?P<url>.*)$', lambda request, url: flatpage(request, 'turniej/' + url), name='olimpiada'),
+    url(r'^olimpiada-teaser/$', 'edumed.views.olimpiada_teaser', name='olimpiada_teaser'),
     url(r'^szukaj/', include('haystack.urls')),
     url(r'^zglos/', include('contact.urls')),
     url(r'^forum/profile/edit/$', AvatarlessProfileEditView.as_view(), name='edit_profile'),
index 47c5d16..1ba6137 100644 (file)
@@ -1,9 +1,15 @@
 # -*- coding: utf-8 -*-
 from django.contrib.flatpages.views import flatpage
+from django.core.exceptions import ValidationError
+from django.core.validators import EmailValidator
+from django.http.response import HttpResponseRedirect
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
 from django.views.defaults import page_not_found
 from django.views.generic import TemplateView
 from pybb.views import ProfileEditView
 
+from contact.models import Contact
 from .forms import AvatarlessEditProfileForm
 
 
@@ -29,3 +35,19 @@ def mil_knowledge_base_view(request, url):
 
 class AvatarlessProfileEditView(ProfileEditView):
     form_class = AvatarlessEditProfileForm
+
+
+def olimpiada_teaser(request):
+    if request.POST:
+        email = request.POST.get('email')
+        try:
+            EmailValidator()(email)
+            Contact.objects.create(
+                contact=email,
+                body={},
+                ip=request.META['REMOTE_ADDR'],
+                form_tag='olimpiada-teaser')
+        except ValidationError:
+            pass
+        return HttpResponseRedirect(request.path)
+    return render_to_response('olimpiada_teaser.html', context_instance=RequestContext(request))