archives: correction du texte pour Amélie
[auf_framonde.git] / project / contact / cms_plugins.py
CommitLineData
01b54c21 1from django.utils.translation import ugettext_lazy as _
6837e829 2
01b54c21
MN
3from cms.plugin_base import CMSPluginBase
4from cms.plugin_pool import plugin_pool
6837e829
PH
5
6from .models import *
7from .forms import ContactForm
8
01b54c21
MN
9
10class ContactPlugin(CMSPluginBase):
11 model = Contact
12 name = _("Contact Form")
13 render_template = "contact.html"
6837e829 14
01b54c21 15 def render(self, context, instance, placeholder):
6837e829
PH
16 request = context['request']
17
18 if request.method == "POST":
19 form = ContactForm(request.POST)
20 if form.is_valid():
21 form.send(instance.site_email)
22 context.update({
23 'contact': instance,
24 })
25 return context
26 else:
27 form = ContactForm()
28
01b54c21 29 context.update({
6837e829
PH
30 'contact': instance,
31 'form': form,
32 })
01b54c21 33 return context
6837e829 34
01b54c21
MN
35plugin_pool.register_plugin(ContactPlugin)
36
6837e829 37
01b54c21
MN
38class CMSVideoPlugin(CMSPluginBase):
39 name = _("Video")
40 model = VideoPlugin
41 render_template = "videoPlugin.html"
42
43 def render(self, context, instance, placeholder):
6837e829
PH
44 context.update({'videoG': instance.video,
45 'video': instance,
46 'placeholder': placeholder})
01b54c21 47 return context
6837e829
PH
48
49plugin_pool.register_plugin(CMSVideoPlugin)