Skip to content

Commit 22a7108

Browse files
committed
Remove duplicate notifications
1 parent 70e34cb commit 22a7108

File tree

6 files changed

+19
-27
lines changed

6 files changed

+19
-27
lines changed

common/utils/helpers.py

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.db.models import Q
1212
from django.db.models.query import QuerySet
1313
from django.template.defaultfilters import truncatechars
14+
from django.utils.translation import gettext_lazy as _
1415
from django.utils.formats import date_format
1516
from django.utils.safestring import mark_safe
1617
from django.utils.safestring import SafeString
@@ -27,10 +28,15 @@
2728
CONTENT_COPY_LINK = '<a href="{}" title="{}">{}</a>'
2829
CRM_NOTICE = '<i class ="material-icons" style="color: var(--body-quiet-color);\
2930
font-size: 17px;vertical-align: middle;">message</i>:'
31+
FRIDAY_SATURDAY_SUNDAY_MSG = _("Attention! Mass mailings are not carried out on: Fridays, Saturdays and Sundays.")
3032
LEADERS = '- - - - -'
3133
OBJ_DOESNT_EXIT_STR = gettext_lazy("{} with ID '{}' doesn’t exist. "
3234
"Perhaps it was deleted?")
3335
ONCLICK_STR = "window.open('{}', '{}','width=800,height=700'); return false;"
36+
USE_HTML = _("""
37+
Use HTML. To specify the address of the embedded image, use {% cid_media ‘path/to/pic.png' %}.<br>
38+
You can embed files uploaded to the CRM server in the ‘media/pics/’ folder.
39+
""")
3440
USER_MODEL = get_user_model()
3541

3642

crm/site/crmmodeladmin.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
from django.utils.translation import gettext_lazy as _
2020
from django.urls import reverse
2121

22-
from common.models import Department, TheFile
22+
from common.models import Department
23+
from common.models import TheFile
2324
from common.site.basemodeladmin import BaseModelAdmin
25+
from common.utils.helpers import FRIDAY_SATURDAY_SUNDAY_MSG
2426
from common.utils.helpers import get_active_users
2527
from common.utils.helpers import get_department_id
2628
from common.utils.helpers import get_manager_departments
@@ -336,10 +338,7 @@ def make_massmail(self, request):
336338
department_id=request.user.department_id
337339
)
338340
mailing_out.save()
339-
messages.info(
340-
request,
341-
_("""Note massmail is not performed on the following days:
342-
Friday, Saturday, Sunday.""")
341+
messages.info(request, _(FRIDAY_SATURDAY_SUNDAY_MSG)
343342
)
344343
return HttpResponseRedirect(reverse(
345344
'site:massmail_mailingout_change',

massmail/admin_actions.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.urls import reverse
1111
from django.utils.translation import gettext_lazy as _
1212

13+
from common.utils.helpers import FRIDAY_SATURDAY_SUNDAY_MSG
1314
from massmail.models import EmailAccount
1415
from massmail.models import MailingOut
1516
from massmail.models import MassContact
@@ -49,11 +50,7 @@ def make_mailing_out(modeladmin, request, queryset):
4950
recipient_ids=",".join([str(obj.id) for obj in queryset]),
5051
recipients_number=queryset.count()
5152
)
52-
messages.info(
53-
request,
54-
_("Note massmail is not performed on the following days:"
55-
" Friday, Saturday, Sunday.")
56-
)
53+
messages.info(request, _(FRIDAY_SATURDAY_SUNDAY_MSG))
5754
return HttpResponseRedirect(
5855
reverse(
5956
'site:massmail_mailingout_change',

massmail/models/email_message.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
from django.contrib.contenttypes.fields import GenericRelation
55
from django.urls import reverse
66

7+
from common.utils.helpers import USE_HTML
78
from massmail.models.baseeml import BaseEml
89

9-
content_help_text = mark_safe(_(
10-
"""
11-
Use HTML. To specify the address of the embedded image, use {% cid_media ‘path/to/pic.png' %}.<br>
12-
You can embed files uploaded to the CRM server in the ‘media/pics/’ folder or attached to this message.
13-
"""
14-
))
10+
content_help_text = mark_safe(_(USE_HTML))
1511

1612

1713
class EmlMessage(BaseEml):

massmail/models/signature.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
from django.db import models
22
from django.utils.safestring import mark_safe
33
from django.utils.translation import gettext_lazy as _
4+
45
from common.models import Base1
6+
from common.utils.helpers import USE_HTML
57

6-
content_help_text = mark_safe(_(
7-
"""
8-
Use HTML. To specify the address of the embedded image, use {% cid_media ‘path/to/pic.png' %}.<br>
9-
You can embed files uploaded to the CRM server in the ‘media/pics/’ folder.
10-
"""
11-
))
8+
content_help_text = mark_safe(_(USE_HTML))
129

1310

1411
class Signature(Base1):

massmail/site/mailingoutadmin.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.utils.translation import gettext_lazy as _
88
from django.utils.safestring import mark_safe
99

10+
from common.utils.helpers import FRIDAY_SATURDAY_SUNDAY_MSG
1011
from common.utils.helpers import get_today
1112
from crm.site.crmmodeladmin import CrmModelAdmin
1213
from crm.utils.admfilters import ByOwnerFilter
@@ -67,11 +68,7 @@ def changelist_view(self, request, extra_context=None):
6768
now = timezone.localtime(timezone.now())
6869
weekday = now.weekday()
6970
if weekday in (4, 5, 6):
70-
messages.warning(
71-
request,
72-
gettext("""Note massmail is not performed on the following days:
73-
Friday, Saturday, Sunday.""")
74-
)
71+
messages.warning(request, gettext(FRIDAY_SATURDAY_SUNDAY_MSG))
7572
return super().changelist_view(request, extra_context)
7673

7774
def save_model(self, request, obj, form, change):

0 commit comments

Comments
 (0)