...
 
Commits (10)
This diff is collapsed.
......@@ -19,6 +19,8 @@ DATABASES = {
}
}
BLOG_URL = "{{ django_project_blog_url }}"
# Email sending
DEFAULT_FROM_EMAIL = '{{ django_project_email_host_user }}'
EMAIL_SUBJECT_PREFIX = '[HexACK site] '
......
......@@ -18,3 +18,5 @@ DATABASES = {
# Email sending auth
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
BLOG_URL = "https://blog.recette.hexack.fr/"
......@@ -4,6 +4,12 @@
{% block content %}
<section class="container">
{% for message in messages %}
<div class="callout alert{% if message.tags %} alert-{% if message.tags == 'error' %}danger{% else %}{{ message.tags }}{% endif %}{% endif %} alert-dismissable lead">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&#215;</button>
{{ message|safe }}
</div>
{% endfor %}
<div class="row">
<div class="col text-center">
<h1>{% blocktrans %}Une agence à votre <span>écoute{% endblocktrans %}</span></h1>
......
......@@ -72,7 +72,7 @@
<h2>{% blocktrans %}Dernières <span>nouvelles</span>:</h2>
<p>Régulièrement, nous publions des billets techniques ou évènementiels.{% endblocktrans %}</p>
<div class="btn-cont float-right">
<a href="{% url 'home' %}" class="btn btn-bleu">{% trans "En savoir +" %}
<a href="{{ blog_url }}" class="btn btn-bleu">{% trans "En savoir +" %}
<span class='line-1'></span>
<span class='line-2'></span>
<span class='line-3'></span>
......
......@@ -62,10 +62,10 @@
<ul class="list-inline float-right align-middle">
<li class="list-inline-item"><a href="https://suivi.hexack.fr/login">{% trans "Service Client" %}</a></li>
{% language 'fr' %}
<!--<li class="list-inline-item"><a href="{% if 'entity' in request.resolver_match.kwargs %}{% url request.resolver_match.view_name request.resolver_match.kwargs.entity %}{% else %}{% url request.resolver_match.view_name %}{% endif %}">FR</a></li>-->
<li class="list-inline-item"><a href="{% if 'entity' in request.resolver_match.kwargs %}{% url request.resolver_match.view_name request.resolver_match.kwargs.entity %}{% else %}{% url request.resolver_match.view_name %}{% endif %}">FR</a></li>
{% endlanguage%}
{% language 'en' %}
<!--<li class="list-inline-item"><a href="{% if 'entity' in request.resolver_match.kwargs %}{% url request.resolver_match.view_name request.resolver_match.kwargs.entity %}{% else %}{% url request.resolver_match.view_name %}{% endif %}">EN</a></li>-->
<li class="list-inline-item"><a href="{% if 'entity' in request.resolver_match.kwargs %}{% url request.resolver_match.view_name request.resolver_match.kwargs.entity %}{% else %}{% url request.resolver_match.view_name %}{% endif %}">EN</a></li>
{% endlanguage%}
</ul>
......@@ -101,6 +101,9 @@
<li class="nav-item">
<a id="menu-contact" class="nav-link " href="{% url 'contact' %}">{% trans "Contact" %}</a>
</li>
<li class="nav-item">
<a id="menu-blog" class="nav-link " href="{{ blog_url }}">{% trans "Carnet" %}</a>
</li>
</ul>
</div>
</nav>
......
......@@ -2,26 +2,25 @@ from django.urls import include, path
from django.conf.urls.i18n import i18n_patterns
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import TemplateView
from django.contrib import admin
from website import views as website_views
from website.views import TemplateSettingsView, ReferenceView, ContactView
admin.autodiscover()
urlpatterns = i18n_patterns(
path('', TemplateView.as_view(template_name="home.html"), name='home'),
path('contact/', website_views.contacts, name='contact'),
path('', TemplateSettingsView.as_view(template_name="home.html"), name='home'),
path('contact/', ContactView.as_view(template_name="contact.html"), name='contact'),
path(r'admin/', admin.site.urls),
path('solutions/', TemplateView.as_view(template_name="solutions.html"), name='solutions'),
path('transition/', TemplateView.as_view(template_name="transition.html"), name='transition'),
path('development/', TemplateView.as_view(template_name="development.html"), name='development'),
path('bigdata/', TemplateView.as_view(template_name="bigdata.html"), name='bigdata'),
path('legal/', TemplateView.as_view(template_name="legal.html"), name='legal'),
path('agency/', TemplateView.as_view(template_name="agency.html"), name='agency'),
path('methodology/', TemplateView.as_view(template_name="methodology.html"), name='methodology'),
path('reference/<str:entity>', website_views.reference_entity, name='reference'),
path('solutions/', TemplateSettingsView.as_view(template_name="solutions.html"), name='solutions'),
path('transition/', TemplateSettingsView.as_view(template_name="transition.html"), name='transition'),
path('development/', TemplateSettingsView.as_view(template_name="development.html"), name='development'),
path('bigdata/', TemplateSettingsView.as_view(template_name="bigdata.html"), name='bigdata'),
path('legal/', TemplateSettingsView.as_view(template_name="legal.html"), name='legal'),
path('agency/', TemplateSettingsView.as_view(template_name="agency.html"), name='agency'),
path('methodology/', TemplateSettingsView.as_view(template_name="methodology.html"), name='methodology'),
path('reference/<str:entity>', ReferenceView.as_view(), name='reference'),
)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
......@@ -135,7 +135,17 @@ class TestReferencePage(LiveServerTestCase):
# TODO - L'entreprise et ses besoins
# TODO - Nos solutions
def test_reference_is_nonexistent(self):
driver = self.driver
driver.get('%s/fr/reference/nonexistent' % self.live_server_url)
print(driver.title)
print(driver.page_source)
self.assertEqual('', driver.title)
self.assertNotEqual(-1, driver.page_source.lower().find('not found'))
def tearDown(self):
driver = self.driver
driver.close()
self.assertEqual([], self.verificationErrors)
......
from website.forms import ContactForm
from django.core.mail import send_mail
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.conf import settings
from django.views.generic import TemplateView, FormView
from django.contrib import messages
from django.utils.translation import ugettext as _
from website.forms import ContactForm
REFERENCES = [
('Yacast', 'http://www.yacast.fr'),
......@@ -19,14 +22,44 @@ REFERENCES = [
('Nuajik', 'https://www.nuajik.io/'),
]
def reference_entity(request, entity=''):
t = loader.get_template(f'references/{entity}.html')
return HttpResponse(t.render({}, request))
def contacts(request):
if request.method == 'POST':
form = ContactForm(request.POST)
class TemplateSettingsView(TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['blog_url'] = settings.BLOG_URL
return context
class ReferenceView(TemplateSettingsView):
def dispatch(request, *args, **kwargs):
if 'entity' in kwargs:
try:
from django import template
template.loader.get_template("references/%s.html" % kwargs['entity'])
except template.TemplateDoesNotExist:
# TODO test both exception and response in recette
from django.http.response import Http404
raise Http404
#from django.http import HttpResponseNotFound
#return HttpResponseNotFound('404 - Not Found')
return TemplateView.dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
self.template_name = "references/%s.html" % context['entity']
return context
class ContactView(FormView):
form_class = ContactForm
template_name = "contact.html"
def post(self, request, *args, **kwargs):
self.extra_contact = {"blog_url": settings.BLOG_URL}
self.success_url = request.path_info
form = self.get_form()
if form.is_valid():
name = form.cleaned_data['name']
subject = form.cleaned_data['subject']
......@@ -34,11 +67,12 @@ def contacts(request):
phone = form.cleaned_data['phone']
message = form.cleaned_data['message']
send_mail(subject, f"From:{name}\nTel:{phone}\n\n" + message, mail, ['contact@hexack.fr'], fail_silently=False)
sent = True
send_mail(subject, f"From:{name}\nTel:{phone}\n\n{message}",
mail, ['contact@hexack.fr'], fail_silently=False)
else:
sent = False
form = ContactForm()
messages.success(request,
_("Votre message a bien été envoyé. Nous vous contacterons dès que possible."))
return render(request, 'contact.html', {'form': form, 'sent': sent})
return self.form_valid(form)
else:
return self.form_invalid(form)