From dc6de99067d637986a16b8230cffda8acd2f0905 Mon Sep 17 00:00:00 2001 From: Mehrdad Farahani Date: Fri, 2 Feb 2018 19:54:12 +0330 Subject: [PATCH 1/2] Enabling multiple Disqus services, Adding Farsi lang --- aldryn_disqus/admin.py | 5 ++ aldryn_disqus/cms_plugins.py | 10 ++-- aldryn_disqus/locale/fa/LC_MESSAGES/django.mo | Bin 0 -> 1104 bytes aldryn_disqus/locale/fa/LC_MESSAGES/django.po | 45 ++++++++++++++++++ .../migrations/0002_auto_20180202_1919.py | 32 +++++++++++++ aldryn_disqus/models.py | 25 +++++++++- .../templates/aldryn_disqus/disqus.html | 7 +-- 7 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 aldryn_disqus/admin.py create mode 100644 aldryn_disqus/locale/fa/LC_MESSAGES/django.mo create mode 100644 aldryn_disqus/locale/fa/LC_MESSAGES/django.po create mode 100644 aldryn_disqus/migrations/0002_auto_20180202_1919.py diff --git a/aldryn_disqus/admin.py b/aldryn_disqus/admin.py new file mode 100644 index 0000000..7800981 --- /dev/null +++ b/aldryn_disqus/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from .models import DisqusService + +admin.site.register(DisqusService) diff --git a/aldryn_disqus/cms_plugins.py b/aldryn_disqus/cms_plugins.py index 3c29f1e..8216fab 100644 --- a/aldryn_disqus/cms_plugins.py +++ b/aldryn_disqus/cms_plugins.py @@ -7,17 +7,19 @@ class DisqusPlugin(CMSPluginBase): - + model = models.DisqusPlugin + name = _('Disqus Plugin') render_template = 'aldryn_disqus/disqus.html' admin_preview = False - name = _('Disqus Plugin') - model = models.DisqusPlugin page_only = True + allow_children = True def render(self, context, instance, placeholder): - context['DISQUS_SHORTNAME'] = settings.DISQUS_SHORTNAME + context['DISQUS_SHORTNAME'] = instance.disqus.shortname if instance and instance.disqus and \ + instance.disqus.shortname else None context['instance'] = instance context['developer_mode'] = settings.DEBUG return context + plugin_pool.register_plugin(DisqusPlugin) diff --git a/aldryn_disqus/locale/fa/LC_MESSAGES/django.mo b/aldryn_disqus/locale/fa/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..1538de5d6472d04c82ef2d4591884bd1798e9629 GIT binary patch literal 1104 zcmZuv&ubGw6kfFoM)crC1cgVgviZ@f#5768{*X$Gp^f5ACdo8e+03pxlhlHTDE*N` zuig}oX@d}A3)M@(gM$CTYy^e=6JGr`+t3y}JE z4FqcoxD0FqSAac006&0>z@0OOaUVPZo&uV{b?m>NHH>TEKj5F>zu=qTZ|4ld4dP%( z2X#S%1<8qZ9=j0$QkYxvWnEIguXxL`$_(<9bkizUx;6)A@r z7GEY+<&+*dx_Ct7X5W()`Dm&Xf7~;-{H6#$bJc~f-=Z&h0k<)>D_@l+Gyd?_UPCEQ, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-02 19:38+0330\n" +"PO-Revision-Date: 2018-02-02 19:40+0330\n" +"Language: fa\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Last-Translator: \n" +"Language-Team: \n" +"X-Generator: Poedit 2.0.6\n" + +#: apps/aldryn_disqus/aldryn_disqus/cms_plugins.py:12 +msgid "Disqus Plugin" +msgstr "پلاگین دیسکاس" + +#: apps/aldryn_disqus/aldryn_disqus/models.py:9 +msgid "Shortname" +msgstr "نام کوتاه در Disqus" + +#: apps/aldryn_disqus/aldryn_disqus/models.py:21 +msgid "Disqus Service" +msgstr "سرویس دیسکاس" + +#: apps/aldryn_disqus/aldryn_disqus/templates/aldryn_disqus/disqus.html:4 +msgid "" +"Please enable JavaScript to view the comments powered by Disqus." +msgstr "" +"لطفا جاوا اسکریپت را فعال کنید تا دیدگاه‌های قدرت گرفته از دیسکاس را مشاهده کنید. " + +#: apps/aldryn_disqus/aldryn_disqus/templates/aldryn_disqus/disqus.html:5 +msgid "blog comments powered by Disqus" +msgstr "" +"نظرات وبلاگ قدرت گرفته شده توسط دیسکاس " diff --git a/aldryn_disqus/migrations/0002_auto_20180202_1919.py b/aldryn_disqus/migrations/0002_auto_20180202_1919.py new file mode 100644 index 0000000..268fae7 --- /dev/null +++ b/aldryn_disqus/migrations/0002_auto_20180202_1919.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('aldryn_disqus', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='DisqusService', + fields=[ + ('id', models.AutoField(serialize=False, auto_created=True, primary_key=True, verbose_name='ID')), + ('shortname', models.CharField(verbose_name='Shortname', max_length=100, blank=True, unique=True)), + ], + ), + migrations.AlterField( + model_name='disqusplugin', + name='cmsplugin_ptr', + field=models.OneToOneField(primary_key=True, to='cms.CMSPlugin', related_name='aldryn_disqus_disqusplugin', serialize=False, auto_created=True, parent_link=True), + ), + migrations.AddField( + model_name='disqusplugin', + name='disqus', + field=models.ForeignKey(to='aldryn_disqus.DisqusService', on_delete=django.db.models.deletion.SET_NULL, blank=True, verbose_name='Disqus Service', null=True), + ), + ] diff --git a/aldryn_disqus/models.py b/aldryn_disqus/models.py index 6d67e87..0ef05a1 100644 --- a/aldryn_disqus/models.py +++ b/aldryn_disqus/models.py @@ -1,7 +1,30 @@ # -*- coding: utf-8 -*- from cms.models.pluginmodel import CMSPlugin +from django.db import models +from django.utils.translation import ugettext_lazy as _ +class DisqusService(models.Model): + shortname = models.CharField( + verbose_name=_('Shortname'), + unique=True, + blank=True, + max_length=100 + ) + + def __str__(self): + return '{}'.format(self.shortname) + class DisqusPlugin(CMSPlugin): + disqus = models.ForeignKey( + DisqusService, + verbose_name=_('Disqus Service'), + on_delete=models.SET_NULL, + blank=True, null=True + ) + + def __str__(self): + return '{}'.format(self.disqus) - pass + def copy_relations(self, old_instance): + self.disqus = old_instance.disqus diff --git a/aldryn_disqus/templates/aldryn_disqus/disqus.html b/aldryn_disqus/templates/aldryn_disqus/disqus.html index 3e87355..bc9879e 100644 --- a/aldryn_disqus/templates/aldryn_disqus/disqus.html +++ b/aldryn_disqus/templates/aldryn_disqus/disqus.html @@ -1,8 +1,9 @@ -{% load sekizai_tags %} +{% load i18n sekizai_tags %}
- -blog comments powered by Disqus + +{% trans 'blog comments powered by Disqus' %} + {% addtoblock "js" %}