Commit f5880825 authored by Patrick's avatar Patrick

Display only permanence.short_name if the field is filled

parent f4c2164e
......@@ -64,7 +64,7 @@ class ConfigurationAdmin(TranslatableAdmin):
'classes': ('collapse',),
'fields' :
(
'offer_producer_mail',
'offer_producer_mail_subject', 'offer_producer_mail',
),
}),
]
......@@ -73,25 +73,25 @@ class ConfigurationAdmin(TranslatableAdmin):
'classes': ('collapse',),
'fields' :
(
'send_opening_mail_to_customer', 'offer_customer_mail',
'send_opening_mail_to_customer', 'offer_customer_mail_subject', 'offer_customer_mail',
),
}),
(_('Ordering mails'), {
'classes': ('collapse',),
'fields' :
(
'send_order_mail_to_customer', 'send_abstract_order_mail_to_customer', 'order_customer_mail',
'send_cancel_order_mail_to_customer', 'cancel_order_customer_mail',
'send_order_mail_to_producer', 'send_abstract_order_mail_to_producer', 'order_producer_mail',
'send_order_mail_to_board', 'order_staff_mail',
'send_order_mail_to_customer', 'send_abstract_order_mail_to_customer', 'order_customer_mail_subject', 'order_customer_mail',
'send_cancel_order_mail_to_customer', 'cancel_order_customer_mail_subject', 'cancel_order_customer_mail',
'send_order_mail_to_producer', 'send_abstract_order_mail_to_producer', 'order_producer_mail_subject', 'order_producer_mail',
'send_order_mail_to_board', 'order_staff_mail_subject', 'order_staff_mail',
),
}),
(_('Invoicing mails'), {
'classes': ('collapse',),
'fields' :
(
'send_invoice_mail_to_customer', 'invoice_customer_mail',
'send_invoice_mail_to_producer', 'invoice_producer_mail',
'send_invoice_mail_to_customer', 'invoice_customer_mail_subject', 'invoice_customer_mail',
'send_invoice_mail_to_producer', 'invoice_producer_mail_subject', 'invoice_producer_mail',
),
}),
(_('Advanced options'), {
......
......@@ -42,6 +42,14 @@ def send_invoice(permanence_id):
invoice_producer_mail = config.invoice_producer_mail
except TranslationDoesNotExist:
invoice_producer_mail = EMPTY_STRING
invoice_producer_mail_subject = "%s - %s - %s - %s" % (
_('Payment'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_profile_name)
try:
if config.invoice_producer_mail_subject:
invoice_producer_mail_subject = config.invoice_producer_mail_subject
except TranslationDoesNotExist:
pass
template = Template(invoice_producer_mail)
context = TemplateContext({
'name' : long_profile_name,
......@@ -61,8 +69,7 @@ def send_invoice(permanence_id):
else:
to_email_producer = [producer.email]
email = EmailMultiAlternatives(
"%s - %s - %s - %s" % (
_('Payment'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_profile_name),
invoice_producer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to_email_producer
......@@ -95,6 +102,13 @@ def send_invoice(permanence_id):
invoice_customer_mail = config.invoice_customer_mail
except TranslationDoesNotExist:
invoice_customer_mail = EMPTY_STRING
invoice_customer_mail_subject = "%s - %s - %s - %s" % (_('Invoice'), permanence, REPANIER_SETTINGS_GROUP_NAME,
long_basket_name)
try:
if config.invoice_customer_mail_subject:
invoice_customer_mail_subject = config.invoice_customer_mail_subject
except TranslationDoesNotExist:
pass
customer_last_balance, customer_on_hold_movement, customer_payment_needed, customer_order_amount = payment_message(
customer, permanence)
template = Template(invoice_customer_mail)
......@@ -120,8 +134,7 @@ def send_invoice(permanence_id):
})
html_content = template.render(context)
email = EmailMultiAlternatives(
"%s - %s - %s - %s" % (_('Invoice'), permanence, REPANIER_SETTINGS_GROUP_NAME,
long_basket_name),
invoice_customer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to_email_customer
......
......@@ -35,6 +35,12 @@ def send_pre_open_order(permanence_id):
offer_description = permanence.offer_description
except TranslationDoesNotExist:
offer_description = EMPTY_STRING
offer_producer_mail_subject = "%s - %s - %s" % (_("Pre-opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME)
try:
if config.offer_producer_mail_subject:
offer_producer_mail_subject = config.offer_producer_mail_subject
except TranslationDoesNotExist:
pass
template = Template(offer_producer_mail)
producer_set = Producer.objects.filter(
permanence=permanence_id, producer_pre_opening=True,
......@@ -66,7 +72,7 @@ def send_pre_open_order(permanence_id):
else:
to_email_producer = [producer.email]
email = EmailMultiAlternatives(
"%s - %s - %s" % (_("Pre-opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME),
offer_producer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to_email_producer,
......@@ -110,6 +116,12 @@ def send_open_order(permanence_id):
offer_customer_mail = config.offer_customer_mail
except TranslationDoesNotExist:
offer_customer_mail = EMPTY_STRING
offer_customer_mail_subject = "%s - %s - %s" % (_("Opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME)
try:
if config.offer_customer_mail_subject:
offer_customer_mail_subject = config.offer_customer_mail_subject
except TranslationDoesNotExist:
pass
offer_producer = ', '.join([p.short_profile_name for p in permanence.producers.all()])
qs = OfferItem.objects.filter(
permanence_id=permanence_id, is_active=True,
......@@ -137,7 +149,7 @@ def send_open_order(permanence_id):
})
html_content = template.render(context)
email = EmailMultiAlternatives(
"%s - %s - %s" % (_("Opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME),
offer_customer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
bcc=list(set(to_email_staff) | set(to_email_customer))
......
......@@ -75,6 +75,13 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
order_staff_mail = config.order_staff_mail
except TranslationDoesNotExist:
order_staff_mail = EMPTY_STRING
order_staff_mail_subject = "%s - %s - %s" % (
_('Permanence preparation list'), permanence, REPANIER_SETTINGS_GROUP_NAME)
try:
if config.order_staff_mail_subject:
order_staff_mail_subject = config.order_staff_mail_subject
except TranslationDoesNotExist:
pass
template = Template(order_staff_mail)
context = TemplateContext({
......@@ -87,8 +94,7 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
})
html_content = template.render(context)
email = EmailMultiAlternatives(
"%s - %s - %s" % (
_('Permanence preparation list'), permanence, REPANIER_SETTINGS_GROUP_NAME),
order_staff_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to_email_board,
......@@ -134,6 +140,13 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
order_producer_mail = config.order_producer_mail
except TranslationDoesNotExist:
order_producer_mail = EMPTY_STRING
order_producer_mail_subject = "%s - %s - %s" % (
_('Permanence preparation list'), permanence, REPANIER_SETTINGS_GROUP_NAME)
try:
if config.order_producer_mail_subject:
order_producer_mail_subject = config.order_producer_mail_subject
except TranslationDoesNotExist:
pass
template = Template(order_producer_mail)
context = TemplateContext({
......@@ -148,8 +161,6 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
})
html_content = template.render(context)
subject = "%s - %s - %s - %s" % (_('Order'), permanence, REPANIER_SETTINGS_GROUP_NAME,
long_profile_name)
producer_invoice = models.ProducerInvoice.objects.filter(
producer_id=producer.id, permanence_id=permanence.id
).only("total_price_with_tax").order_by('?').first()
......@@ -157,9 +168,9 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
and producer_invoice.total_price_with_tax < producer.minimum_order_value:
to = cc_email_staff
html_content = \
subject + '<br/><br/>' + html_content
order_producer_mail_subject + '<br/><br/>' + html_content
cc = []
subject = _(
order_producer_mail_subject = _(
'/!\ Mail not send to our producer %s because the minimum order value has not been reached.') % long_profile_name
else:
if producer.email2:
......@@ -168,7 +179,7 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
to = [producer.email]
cc = cc_email_staff
email = EmailMultiAlternatives(
subject,
order_producer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to,
......@@ -264,11 +275,25 @@ def export_order_2_1_customer(customer, filename, permanence, sender_email, send
order_customer_mail = config.cancel_order_customer_mail
except TranslationDoesNotExist:
order_customer_mail = EMPTY_STRING
order_customer_mail_subject = "%s - %s - %s - %s" % (
_('/!\ Order cancelled'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_basket_name)
try:
if config.cancel_order_customer_mail_subject:
order_customer_mail_subject = config.cancel_order_customer_mail_subject
except TranslationDoesNotExist:
pass
else:
try:
order_customer_mail = config.order_customer_mail
except TranslationDoesNotExist:
order_customer_mail = EMPTY_STRING
order_customer_mail_subject = "%s - %s - %s - %s" % (
_('Order'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_basket_name)
try:
if config.order_customer_mail_subject:
order_customer_mail_subject = config.order_customer_mail_subject
except TranslationDoesNotExist:
pass
template = Template(order_customer_mail)
context = TemplateContext({
'name' : long_basket_name,
......@@ -288,14 +313,8 @@ def export_order_2_1_customer(customer, filename, permanence, sender_email, send
'%s<br/>%s<br/>%s' % (signature, sender_function, REPANIER_SETTINGS_GROUP_NAME))
})
html_content = template.render(context)
if cancel_order:
subject = "%s - %s - %s - %s" % (
_('/!\ Order cancelled'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_basket_name)
else:
subject = "%s - %s - %s - %s" % (
_('Order'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_basket_name)
email = EmailMultiAlternatives(
subject,
order_customer_mail_subject,
strip_tags(html_content),
from_email=sender_email,
to=to_email_customer
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment