Skip to content

Commit

Permalink
Merge pull request #30 from deployed/missing_translations
Browse files Browse the repository at this point in the history
Added missing translations into some fields
  • Loading branch information
czubik8805 committed Nov 17, 2020
2 parents 812a96f + ab872d7 commit c87c4c9
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 13 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Assumptions

Changelog
=========

1.1.7
-----
* added missing translations [pl]
* added support for naming of the templates

1.1.6
-----
* Template loader fix
Expand Down
18 changes: 17 additions & 1 deletion emailtemplates/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
from django.utils.translation import ugettext_lazy as _

from .forms import EmailTemplateAdminForm, MassEmailMessageForm, MassEmailAttachmentForm
from .models import EmailTemplate, MassEmailMessage, MassEmailAttachment
from .models import EmailTemplate, MassEmailMessage, MassEmailAttachment, EmailAttachment


class EmailTemplateAttachmentInline(admin.TabularInline):
model = EmailTemplate.attachments.through
extra = 1
verbose_name = _("Attachment")
verbose_name_plural = _("Attachments")


class EmailTemplateAdmin(admin.ModelAdmin):
Expand All @@ -20,6 +27,7 @@ class EmailTemplateAdmin(admin.ModelAdmin):
save_on_top = True
save_as = True
readonly_fields = ['show_links', 'created', 'modified']
inlines = [EmailTemplateAttachmentInline]

def show_links(self, obj):
if not obj.pk:
Expand All @@ -35,6 +43,14 @@ def show_links(self, obj):
admin.site.register(EmailTemplate, EmailTemplateAdmin)


class EmailAttachmentAdmin(admin.ModelAdmin):
list_display = ["name"]
search_fields = ["name"]


admin.site.register(EmailAttachment, EmailAttachmentAdmin)


class MassEmailAttachmentInline(admin.TabularInline):
model = MassEmailAttachment
form = MassEmailAttachmentForm
Expand Down
5 changes: 3 additions & 2 deletions emailtemplates/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from django.core.exceptions import ValidationError
from django.template import Template
from django.template import TemplateSyntaxError
from django.utils.safestring import mark_safe
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _

from emailtemplates.models import EmailTemplate, MassEmailAttachment, MassEmailMessage
from emailtemplates.registry import email_templates
Expand All @@ -15,7 +16,7 @@


class EmailTemplateAdminForm(forms.ModelForm):
title = forms.ChoiceField(choices=lazy(email_templates.email_template_choices, list))
title = forms.ChoiceField(choices=lazy(email_templates.email_template_choices, list), label=_("template"))

class Meta:
model = EmailTemplate
Expand Down
132 changes: 132 additions & 0 deletions emailtemplates/locale/pl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-13 12:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n"
"%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n"
"%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n"

#: emailtemplates/admin.py:34
msgid "Show email preview"
msgstr "Pokaż podgląd wiadomości"

#: emailtemplates/admin.py:38
msgid "Actions"
msgstr "Akcje"

#: emailtemplates/apps.py:8
msgid "E-MAIL TEMPLATES"
msgstr "Szblony wiadomości E-mail"

#: emailtemplates/forms.py:19 emailtemplates/models.py:25
msgid "template"
msgstr "szablon"

#: emailtemplates/models.py:26 emailtemplates/models.py:76
msgid "subject"
msgstr "tytuł"

#: emailtemplates/models.py:27 emailtemplates/models.py:77
msgid "content"
msgstr "zawartość"

#: emailtemplates/models.py:28
msgid "language"
msgstr "język"

#: emailtemplates/models.py:30
msgid "created"
msgstr "utworzono"

#: emailtemplates/models.py:31
msgid "modified"
msgstr "zmodyfikowano"

#: emailtemplates/models.py:35
msgid "Email template"
msgstr "Szablon wiadomości"

#: emailtemplates/models.py:36
msgid "Email templates"
msgstr "Szablony wiadomości"

#: emailtemplates/models.py:56
msgid "name"
msgstr "nazwa"

#: emailtemplates/models.py:57
msgid "Attachment file"
msgstr "Plik załącznika"

#: emailtemplates/models.py:61
msgid "Attachment"
msgstr "Załącznik"

#: emailtemplates/models.py:62
msgid "Attachments"
msgstr "Załączniki"

#: emailtemplates/models.py:65
#, python-format
msgid "Attachment: %s"
msgstr "Załącznik: %s"

#: emailtemplates/models.py:72
msgid "email template"
msgstr "szablon email"

#: emailtemplates/models.py:78
msgid "sent"
msgstr "wysłano"

#: emailtemplates/models.py:81
msgid "Mass email message"
msgstr "Wiadomość grupowa"

#: emailtemplates/models.py:82
msgid "Mass email messages"
msgstr "Wiadomości grupowe"

#: emailtemplates/registry.py:68
#, python-format
msgid "<b>USAGE: %s</b>"
msgstr "<b>UŻYCIE: %s</b>"

#: emailtemplates/registry.py:69
#, python-format
msgid "<b>CONTEXT:</b><br/>%s"
msgstr "<b>KONTEKST:</b><br/>%s"

#: emailtemplates/templates/admin/emailtemplates/massemailmessage/change_form.html:5
msgid "Send to all users"
msgstr "Wyślij do wszystkich użytkowników"

#: emailtemplates/views.py:51
msgid ""
"Mass email was already sent. Create new mail message or force sending from "
"shell."
msgstr ""
"Wiadomość grupowa została już wysłana. Utwórz nową lub wymuś wysłanie z "
"konsoli shell."

#: emailtemplates/views.py:56
msgid "Mass email sent successfully"
msgstr "Wiadomość grupowa wysłana pomyślnie"

#: emailtemplates/views.py:58
msgid "Error occurred when trying to send mass email message."
msgstr "Wystąpił błąd podczas próby wysłania wiadomości grupowej."
24 changes: 24 additions & 0 deletions emailtemplates/migrations/0006_auto_20201110_1151.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.1.2 on 2020-11-10 11:51

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('emailtemplates', '0005_auto_20201110_1115'),
]

operations = [
migrations.AlterField(
model_name='emailtemplate',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='created'),
),
migrations.AlterField(
model_name='emailtemplate',
name='modified',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='modified'),
),
]
45 changes: 45 additions & 0 deletions emailtemplates/migrations/0007_auto_20201113_1354.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.1.2 on 2020-11-13 13:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('emailtemplates', '0006_auto_20201110_1151'),
]

operations = [
migrations.CreateModel(
name='EmailAttachment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=50, verbose_name='name')),
('attachment_file', models.FileField(upload_to='emails/attachments/', verbose_name='Attachment file')),
],
options={
'verbose_name': 'Attachment',
'verbose_name_plural': 'Attachments',
'abstract': False,
},
),
migrations.AlterModelOptions(
name='massemailattachment',
options={'verbose_name': 'Attachment', 'verbose_name_plural': 'Attachments'},
),
migrations.AddField(
model_name='massemailattachment',
name='name',
field=models.CharField(blank=True, max_length=50, verbose_name='name'),
),
migrations.AlterField(
model_name='massemailattachment',
name='attachment_file',
field=models.FileField(upload_to='emails/attachments/', verbose_name='Attachment file'),
),
migrations.AddField(
model_name='emailtemplate',
name='attachments',
field=models.ManyToManyField(blank=True, to='emailtemplates.EmailAttachment', verbose_name='attachments'),
),
]
31 changes: 27 additions & 4 deletions emailtemplates/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding=utf-8
import logging
import os

from django.conf import settings
from django.db import models
Expand All @@ -26,8 +27,9 @@ class EmailTemplate(models.Model):
content = models.TextField(_(u'content'))
language = models.CharField(_(u'language'), max_length=10, choices=settings.LANGUAGES,
default=settings.LANGUAGE_CODE)
created = models.DateTimeField(default=now)
modified = models.DateTimeField(default=now)
attachments = models.ManyToManyField("EmailAttachment", blank=True, verbose_name=_("attachments"))
created = models.DateTimeField(default=now, verbose_name=_("created"))
modified = models.DateTimeField(default=now, verbose_name=_("modified"))

class Meta:
unique_together = (('title', 'language'),)
Expand All @@ -51,6 +53,28 @@ def save(self, *args, **kwargs):
super(EmailTemplate, self).save(*args, **kwargs)


class BaseEmailAttachment(models.Model):
name = models.CharField(_("name"), blank=True, max_length=50)
attachment_file = models.FileField(_(u"Attachment file"), upload_to="emails/attachments/")

class Meta:
abstract = True
verbose_name = _("Attachment")
verbose_name_plural = _("Attachments")

def __str__(self):
return _("Attachment: %s") % self.get_name()

def get_name(self):
return self.name or os.path.basename(self.attachment_file.name)


class EmailAttachment(BaseEmailAttachment):
pass

# email_template = models.ForeignKey(EmailTemplate, verbose_name=_('email template'), on_delete=models.CASCADE)


class MassEmailMessage(models.Model):
subject = models.CharField(_(u'subject'), max_length=255)
content = models.TextField(_(u'content'))
Expand Down Expand Up @@ -90,6 +114,5 @@ def send(self, recipients=None, force=False):
return sent_count == len(recipients)


class MassEmailAttachment(models.Model):
attachment_file = models.FileField(_(u"Attachment file"))
class MassEmailAttachment(BaseEmailAttachment):
mass_email_message = models.ForeignKey(MassEmailMessage, related_name="attachments", on_delete=models.CASCADE)

0 comments on commit c87c4c9

Please sign in to comment.