From: Jan Szejko Date: Wed, 1 Jun 2016 16:09:57 +0000 (+0200) Subject: teaser stub X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/2d1a48203fbde7378cb2268ffd667f9208bcb598?ds=sidebyside;hp=003a3fab503e3c8362b14f8f8c7306f305d9cc39 teaser stub --- diff --git a/edumed/templates/olimpiada_teaser.html b/edumed/templates/olimpiada_teaser.html new file mode 100644 index 0000000..071e68e --- /dev/null +++ b/edumed/templates/olimpiada_teaser.html @@ -0,0 +1,15 @@ +{% extends "base_super.html" %} + +{% block logo %}{% endblock %} +{% block title %}Olimpiada cyfrowa{% endblock %} + +{% block body %} + +

Tutaj będzie coś zajebistego!

+

Podaj swój adres e-mail, żeby dostać powiadomienie:

+
+ {% csrf_token %} + + +
+{% endblock %} \ No newline at end of file diff --git a/edumed/urls.py b/edumed/urls.py index 32eb97e..2d0d0a0 100644 --- a/edumed/urls.py +++ b/edumed/urls.py @@ -15,6 +15,7 @@ urlpatterns = patterns( url(r'^info/(?P.*)$', flatpage, name="info"), url(r'^olimpiada/$', lambda request: flatpage(request, 'turniej/'), name='olimpiada'), url(r'^olimpiada/(?P.*)$', 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'), diff --git a/edumed/views.py b/edumed/views.py index 47c5d16..1ba6137 100644 --- a/edumed/views.py +++ b/edumed/views.py @@ -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))