Moved contact form model in order to be reusable by ungleich app, Created unit test for digitalglarus contact page, Created ungleich contact page, Created unit test for ungleich contact page, Created unit test for forms .
This commit is contained in:
parent
cf0fec706c
commit
942464f6f6
37 changed files with 425 additions and 31 deletions
0
ungleich_page/__init__.py
Normal file
0
ungleich_page/__init__.py
Normal file
3
ungleich_page/admin.py
Normal file
3
ungleich_page/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
ungleich_page/apps.py
Normal file
5
ungleich_page/apps.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UngleichPageConfig(AppConfig):
|
||||
name = 'ungleich_page'
|
||||
0
ungleich_page/migrations/__init__.py
Normal file
0
ungleich_page/migrations/__init__.py
Normal file
3
ungleich_page/models.py
Normal file
3
ungleich_page/models.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
40
ungleich_page/templates/ungleich_page/_footer.html
Normal file
40
ungleich_page/templates/ungleich_page/_footer.html
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{% load cms_tags %}
|
||||
<hr />
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<ul class="list-inline text-center">
|
||||
<li>
|
||||
<a href="https://twitter.com/ungleich">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.linkedin.com/company/ungleich-gmbh">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-linkedin fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/ungleich">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="copyright text-muted text-centered">
|
||||
{% static_placeholder "footer_copyright" %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
17
ungleich_page/templates/ungleich_page/_header_base.html
Normal file
17
ungleich_page/templates/ungleich_page/_header_base.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{% load cms_tags staticfiles %}
|
||||
<!-- Page Header -->
|
||||
<!-- Set your background image for this header on the line below. -->
|
||||
<header class="intro-header" style="background-image: url('{% static 'blog.ungleich.ch/img/home-bg.jpg' %}');">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="site-heading">
|
||||
<h1> {{ page_title }} </h1>
|
||||
<hr class="small">
|
||||
<span class="subheading"> {{page_subtitle}} </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
36
ungleich_page/templates/ungleich_page/_menu.html
Normal file
36
ungleich_page/templates/ungleich_page/_menu.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{% load menu_tags staticfiles cms_tags %}
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header page-scroll">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="{% static "blog.ungleich.ch/img/logo_white.svg" %}" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% for child in children %}
|
||||
<li class="child{% if child.selected %} selected{% endif %}{% if child.ancestor %} ancestor{% endif %}{% if child.sibling %} sibling{% endif %}{% if child.descendant %} descendant{% endif %}">
|
||||
<a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
|
||||
{% if child.children %}
|
||||
<ul>
|
||||
{% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
</nav>
|
||||
78
ungleich_page/templates/ungleich_page/base_ungleich.html
Normal file
78
ungleich_page/templates/ungleich_page/base_ungleich.html
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{% load cms_tags menu_tags sekizai_tags staticfiles bootstrap3 %}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
{% block title %}
|
||||
{% page_attribute "page_title" %}
|
||||
{% endblock %}
|
||||
</title>
|
||||
{% addtoblock "external-css" %}
|
||||
{% bootstrap_css %}
|
||||
|
||||
<link href='//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' rel="stylesheet" type="text/css">
|
||||
<link href='//fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
|
||||
<link href='//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800'
|
||||
rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
{% endaddtoblock %}
|
||||
|
||||
{% addtoblock "css" %}
|
||||
<link href="{% static 'blog.ungleich.ch/css/clean-blog.css' %}" type="text/css"
|
||||
rel="stylesheet" medial="all" />
|
||||
{% endaddtoblock %}
|
||||
{% block meta %}
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="{% page_attribute 'meta_description' %}">
|
||||
{% include 'meta.html' %}
|
||||
{% endblock %}
|
||||
{% render_block "external-css" %}
|
||||
{% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %}
|
||||
</head>
|
||||
<body>
|
||||
{% cms_toolbar %}
|
||||
{% show_menu 0 0 0 1 "cms/ungleichch/_menu.html" %}
|
||||
<!-- body -->
|
||||
<!-- Main Content -->
|
||||
{% block base_header %}
|
||||
{% include "ungleich_page/_header_base.html" %}
|
||||
{% endblock %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
{% block base_content %}
|
||||
{% placeholder "default" %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end body -->
|
||||
{% include "cms/ungleichch/_footer.html" %}
|
||||
{% addtoblock "external-js" %}
|
||||
{% bootstrap_javascript %}
|
||||
{% endaddtoblock %}
|
||||
{% addtoblock "js" %}
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-62285904-4', 'auto');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
|
||||
<script src="{% static 'blog.ungleich.ch/vendor/js/jquery.min.js' %}" type="text/javascript" />
|
||||
<script src="{% static 'blog.ungleich.ch/js/navbar-scroll-up.js' %}" type="text/javascript" />
|
||||
{% endaddtoblock %}
|
||||
{% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
|
||||
{% render_block "external-js" %}
|
||||
</body>
|
||||
</html>
|
||||
38
ungleich_page/templates/ungleich_page/contact.html
Normal file
38
ungleich_page/templates/ungleich_page/contact.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{% extends "ungleich_page/base_ungleich.html" %}
|
||||
|
||||
{% block base_content %}
|
||||
<form action="{% url 'ungleich_page:contact' %}" method="post" >
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div autofocus class="form-group col-lg-4 {% if form.name.errors %}has-error text-danger{% endif %}">
|
||||
{{ form.name.label_tag }}
|
||||
{{ form.name }}
|
||||
{{ form.name.errors|striptags}}
|
||||
</div>
|
||||
<div class="form-group col-lg-4 {% if form.email.errors %}has-error text-danger {% endif %}">
|
||||
{{ form.email.label_tag }}
|
||||
{{ form.email }}
|
||||
{{ form.email.errors|striptags}}
|
||||
</div>
|
||||
<div class="form-group col-lg-4 {% if form.phone_number.errors %}has-error text-danger {% endif %}">
|
||||
{{ form.phone_number.label_tag }}
|
||||
{{ form.phone_number }}
|
||||
{{ form.phone_number.errors|striptags}}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group col-lg-12 {% if form.message.errors %}has-error text-danger {% endif %}">
|
||||
{{ form.message.label_tag }}
|
||||
{{ form.message }}
|
||||
{{ form.message.errors|striptags}}
|
||||
</div>
|
||||
{{ form.non_field_errors }}
|
||||
<div class="form-group col-lg-12">
|
||||
<input type="hidden" name="save" value="contact">
|
||||
<button type="submit" class="btn btn-default" {% if form.name.errors %} autofocus {% endif %}>Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
3
ungleich_page/templates/ungleich_page/index.html
Normal file
3
ungleich_page/templates/ungleich_page/index.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{% extends "base_glarus.html" %}
|
||||
{% block base_content %}
|
||||
{% endblock %}
|
||||
5
ungleich_page/templates/ungleich_page/page.html
Normal file
5
ungleich_page/templates/ungleich_page/page.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{% extends "base_ungleich.html" %}
|
||||
{% load cms_tags %}
|
||||
{% block base_content %}
|
||||
{% placeholder "page_content" %}
|
||||
{% endblock %}
|
||||
23
ungleich_page/test_views.py
Normal file
23
ungleich_page/test_views.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import resolve
|
||||
|
||||
|
||||
class ContactViewTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.url = reverse('ungleich_page:contact')
|
||||
self.data = {
|
||||
'name': 'test',
|
||||
'email': 'test@gmail.com',
|
||||
'phone_number': '32123123123123',
|
||||
'message': 'This is a message',
|
||||
}
|
||||
|
||||
def url_resolve_to_view_correctly(self):
|
||||
found = resolve(self.url)
|
||||
self.assertEqual(found.func.__name__, self.view.__name__)
|
||||
|
||||
def test_any_user_should_contact_us(self):
|
||||
response = self.client.post(self.url, self.data, follow=True)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
3
ungleich_page/tests.py
Normal file
3
ungleich_page/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
6
ungleich_page/urls.py
Normal file
6
ungleich_page/urls.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.conf.urls import url
|
||||
from .views import ContactView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'contact/?$', ContactView.as_view(), name='contact'),
|
||||
]
|
||||
25
ungleich_page/views.py
Normal file
25
ungleich_page/views.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from django.contrib import messages
|
||||
|
||||
from django.views.generic.edit import FormView
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from utils.forms import ContactUsForm
|
||||
|
||||
|
||||
class ContactView(FormView):
|
||||
template_name = 'ungleich_page/contact.html'
|
||||
form_class = ContactUsForm
|
||||
success_url = reverse_lazy('digitalglarus:contact')
|
||||
success_message = _('Message Successfully Sent')
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
form.send_email()
|
||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
return super(ContactView, self).form_valid(form)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ContactView, self).get_context_data(**kwargs)
|
||||
context['page_title'] = _('Contact Us')
|
||||
context['page_subtitle'] = _('If you have any question, just send us an email.')
|
||||
return context
|
||||
Loading…
Add table
Add a link
Reference in a new issue