archives: correction du texte pour Amélie
[auf_framonde.git] / project / contact / cms_plugins.py
1 from django.utils.translation import ugettext_lazy as _
2
3 from cms.plugin_base import CMSPluginBase
4 from cms.plugin_pool import plugin_pool
5
6 from .models import *
7 from .forms import ContactForm
8
9
10 class ContactPlugin(CMSPluginBase):
11 model = Contact
12 name = _("Contact Form")
13 render_template = "contact.html"
14
15 def render(self, context, instance, placeholder):
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
29 context.update({
30 'contact': instance,
31 'form': form,
32 })
33 return context
34
35 plugin_pool.register_plugin(ContactPlugin)
36
37
38 class CMSVideoPlugin(CMSPluginBase):
39 name = _("Video")
40 model = VideoPlugin
41 render_template = "videoPlugin.html"
42
43 def render(self, context, instance, placeholder):
44 context.update({'videoG': instance.video,
45 'video': instance,
46 'placeholder': placeholder})
47 return context
48
49 plugin_pool.register_plugin(CMSVideoPlugin)