Commit 738f0b9f authored by Patrick's avatar Patrick

RC

parent 3d4f0b37
# -*- coding: utf-8 -*-
import ConfigParser
try:
import configparser
except:
from six.moves import configparser
import codecs
import logging
......@@ -38,7 +42,7 @@ MEDIA_URL = "%s%s%s" % (os.sep, "media", os.sep)
STATIC_ROOT = os.path.join(PROJECT_DIR, "collect-static")
DJANGO_SETTINGS_SITE_NAME = os.path.split(PROJECT_DIR)[-1]
config = ConfigParser.RawConfigParser(allow_no_value=True)
config = configparser.RawConfigParser(allow_no_value=True)
conf_file_name = '%s%s%s.ini' % (
PROJECT_DIR,
os.sep,
......
......@@ -272,7 +272,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
self.message_user(request, user_message, user_message_level)
return
# Also display order without delivery point -> The customer has not selected it yet
deliveries_to_be_exported.append(None)
# deliveries_to_be_exported.append(None)
else:
deliveries_to_be_exported = None
response = None
......
......@@ -8,8 +8,8 @@ from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from openpyxl.writer.excel import save_virtual_workbook
from repanier.models import DeliveryBoard
from repanier.models import Customer
from repanier.models import DeliveryBoard
from repanier.models import Permanence, Configuration, CustomerInvoice
from repanier.models import PermanenceBoard
from repanier.models import Producer, ProducerInvoice
......@@ -17,7 +17,7 @@ from repanier.tools import *
from repanier.xlsx.xlsx_order import generate_customer_xlsx, generate_producer_xlsx
def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, producers_id=None):
def email_order(permanence_id, all_producers=True, producers_id=None, closed_deliveries_id=None):
from repanier.apps import REPANIER_SETTINGS_SEND_ORDER_MAIL_TO_BOARD, \
REPANIER_SETTINGS_GROUP_NAME, REPANIER_SETTINGS_SEND_ORDER_MAIL_TO_PRODUCER, \
REPANIER_SETTINGS_SEND_ABSTRACT_ORDER_MAIL_TO_PRODUCER, \
......@@ -42,6 +42,7 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
if closed_deliveries_id:
# closed_deliveries_id is not empty list and not "None"
# all_producers is True
all_producers = True
for delivery_id in closed_deliveries_id:
delivery_board = DeliveryBoard.objects.filter(
id=delivery_id
......@@ -110,7 +111,7 @@ def email_order(permanence_id, all_producers=True, closed_deliveries_id=None, pr
permanence=permanence.id,
language=language_code,
).order_by('?')
if producers_id is not None:
if producers_id:
producer_set = producer_set.filter(id__in=producers_id)
for producer in producer_set:
long_profile_name = producer.long_profile_name if producer.long_profile_name is not None else producer.short_profile_name
......
......@@ -17,102 +17,107 @@ class Command(BaseCommand):
help = 'Recalculate order amount'
def handle(self, *args, **options):
latest_total = BankAccount.objects.filter(
producer__isnull=True,
customer__isnull=True,
permanence__isnull=False
).only(
"permanence"
).order_by(
"-id"
).first()
while latest_total:
permanence = latest_total.permanence
if permanence.status == PERMANENCE_INVOICED:
print ("Cancel %s %s" % (permanence.permanence_date, permanence.get_status_display()))
task_invoice.admin_cancel(permanence)
else:
latest_total.delete()
latest_total = BankAccount.objects.filter(
producer__isnull=True,
customer__isnull=True,
permanence__isnull=False
).only(
"permanence"
).order_by(
"-id"
).first()
recalculate_order_amount(
permanence_id=60,
re_init=True
)
for permanence in Permanence.objects.filter(
status=PERMANENCE_ARCHIVED
).order_by('permanence_date'):
print ("Cancel %s %s" % (permanence.permanence_date, permanence.get_status_display()))
task_invoice.admin_cancel(permanence)
for permanence in Permanence.objects.filter(
status__lt=PERMANENCE_CLOSED
).order_by('permanence_date'):
print ("Recalculate %s %s" % (permanence.permanence_date, permanence.get_status_display()))
recalculate_order_amount(
permanence_id=permanence.id,
re_init=True
)
reorder_offer_items(permanence.id)
for customer_invoice in CustomerInvoice.objects.filter(permanence_id=permanence.id):
delivery_point = LUT_DeliveryPoint.objects.filter(
customer_responsible=customer_invoice.customer_id
).order_by('?').first()
if delivery_point is not None:
delivery = DeliveryBoard.objects.filter(
delivery_point_id=delivery_point.id,
permanence_id=permanence.id,
).order_by('?').first()
customer_invoice.delivery = delivery
customer_invoice.set_delivery(customer_invoice.delivery)
if customer_invoice.is_order_confirm_send:
customer_invoice.confirm_order()
customer_invoice.save()
# if customer_invoice.is_order_confirm_send:
# confirm_customer_invoice(permanence.id, customer_invoice.customer_id)
for permanence in Permanence.objects.filter(
status__gte=PERMANENCE_CLOSED,
status__lt=PERMANENCE_INVOICED
).order_by('permanence_date'):
# Important : Do not reclaculte if permanence is invoiced or archived.
# First, cancel the invoice / archiving.
print ("Recalculate %s %s" % (permanence.permanence_date, permanence.get_status_display()))
status = permanence.status
permanence.set_status(status)
# if status >= PERMANENCE_SEND:
recalculate_order_amount(
permanence_id=permanence.id,
re_init=True
)
reorder_offer_items(permanence.id)
for customer_invoice in CustomerInvoice.objects.filter(permanence_id=permanence.id):
delivery_point = LUT_DeliveryPoint.objects.filter(
customer_responsible=customer_invoice.customer_id
).order_by('?').first()
if delivery_point is not None:
print("---- %s" % delivery_point)
delivery = DeliveryBoard.objects.filter(
delivery_point_id=delivery_point.id,
permanence_id=permanence.id,
).order_by('?').first()
customer_invoice.delivery = delivery
customer_invoice.set_delivery(customer_invoice.delivery)
if customer_invoice.is_order_confirm_send:
customer_invoice.confirm_order()
customer_invoice.save()
for permanence in Permanence.objects.filter(
status=PERMANENCE_SEND,
highest_status__in=[PERMANENCE_INVOICED, PERMANENCE_ARCHIVED]
).order_by(
"payment_date", "is_updated_on"
):
# if permanence.highest_status == PERMANENCE_INVOICED:
# else:
pass
# latest_total = BankAccount.objects.filter(
# producer__isnull=True,
# customer__isnull=True,
# permanence__isnull=False
# ).only(
# "permanence"
# ).order_by(
# "-id"
# ).first()
# while latest_total:
# permanence = latest_total.permanence
# if permanence.status == PERMANENCE_INVOICED:
# print ("Cancel %s %s" % (permanence.permanence_date, permanence.get_status_display()))
# task_invoice.admin_cancel(permanence)
# else:
# latest_total.delete()
# latest_total = BankAccount.objects.filter(
# producer__isnull=True,
# customer__isnull=True,
# permanence__isnull=False
# ).only(
# "permanence"
# ).order_by(
# "-id"
# ).first()
#
# for permanence in Permanence.objects.filter(
# status=PERMANENCE_ARCHIVED
# ).order_by('permanence_date'):
# print ("Cancel %s %s" % (permanence.permanence_date, permanence.get_status_display()))
# task_invoice.admin_cancel(permanence)
#
# for permanence in Permanence.objects.filter(
# status__lt=PERMANENCE_CLOSED
# ).order_by('permanence_date'):
# print ("Recalculate %s %s" % (permanence.permanence_date, permanence.get_status_display()))
# recalculate_order_amount(
# permanence_id=permanence.id,
# re_init=True
# )
# reorder_offer_items(permanence.id)
# for customer_invoice in CustomerInvoice.objects.filter(permanence_id=permanence.id):
# delivery_point = LUT_DeliveryPoint.objects.filter(
# customer_responsible=customer_invoice.customer_id
# ).order_by('?').first()
# if delivery_point is not None:
# delivery = DeliveryBoard.objects.filter(
# delivery_point_id=delivery_point.id,
# permanence_id=permanence.id,
# ).order_by('?').first()
# customer_invoice.delivery = delivery
# customer_invoice.set_delivery(customer_invoice.delivery)
# if customer_invoice.is_order_confirm_send:
# customer_invoice.confirm_order()
# customer_invoice.save()
# # if customer_invoice.is_order_confirm_send:
# # confirm_customer_invoice(permanence.id, customer_invoice.customer_id)
# for permanence in Permanence.objects.filter(
# status__gte=PERMANENCE_CLOSED,
# status__lt=PERMANENCE_INVOICED
# ).order_by('permanence_date'):
# # Important : Do not reclaculte if permanence is invoiced or archived.
# # First, cancel the invoice / archiving.
# print ("Recalculate %s %s" % (permanence.permanence_date, permanence.get_status_display()))
# status = permanence.status
# permanence.set_status(status)
# # if status >= PERMANENCE_SEND:
# recalculate_order_amount(
# permanence_id=permanence.id,
# re_init=True
# )
# reorder_offer_items(permanence.id)
# for customer_invoice in CustomerInvoice.objects.filter(permanence_id=permanence.id):
# delivery_point = LUT_DeliveryPoint.objects.filter(
# customer_responsible=customer_invoice.customer_id
# ).order_by('?').first()
# if delivery_point is not None:
# print("---- %s" % delivery_point)
# delivery = DeliveryBoard.objects.filter(
# delivery_point_id=delivery_point.id,
# permanence_id=permanence.id,
# ).order_by('?').first()
# customer_invoice.delivery = delivery
# customer_invoice.set_delivery(customer_invoice.delivery)
# if customer_invoice.is_order_confirm_send:
# customer_invoice.confirm_order()
# customer_invoice.save()
#
# for permanence in Permanence.objects.filter(
# status=PERMANENCE_SEND,
# highest_status__in=[PERMANENCE_INVOICED, PERMANENCE_ARCHIVED]
# ).order_by(
# "payment_date", "is_updated_on"
# ):
# # if permanence.highest_status == PERMANENCE_INVOICED:
# # else:
# pass
......@@ -202,11 +202,11 @@ class CustomerInvoice(models.Model):
purchase.Purchase.objects.filter(
customer_invoice__id=self.id
).update(quantity_confirmed=F('quantity_ordered'))
self.calculate_and_save_delta_buyinggroup()
self.calculate_and_save_delta_buyinggroup(confirm_order=True)
self.is_order_confirm_send = True
@transaction.atomic
def calculate_and_save_delta_buyinggroup(self):
def calculate_and_save_delta_buyinggroup(self, confirm_order=False):
producer_invoice_buyinggroup = ProducerInvoice.objects.filter(
producer__represent_this_buyinggroup=True,
permanence_id=self.permanence_id,
......@@ -225,7 +225,7 @@ class CustomerInvoice(models.Model):
producer_invoice_buyinggroup.delta_vat.amount -= self.delta_vat.amount
producer_invoice_buyinggroup.delta_transport.amount -= self.delta_transport.amount
self.calculate_delta_price()
self.calculate_delta_price(confirm_order)
self.calculate_delta_transport()
producer_invoice_buyinggroup.delta_price_with_tax.amount += self.delta_price_with_tax.amount
......@@ -234,10 +234,11 @@ class CustomerInvoice(models.Model):
producer_invoice_buyinggroup.save()
def calculate_delta_price(self):
def calculate_delta_price(self, confirm_order=False):
getcontext().rounding = ROUND_HALF_UP
if self.customer_charged is None:
if self.customer_charged is None or confirm_order:
# confirm_order : the customer confirm his/her order
result_set = purchase.Purchase.objects.filter(
permanence_id=self.permanence_id,
customer_id=self.customer_id,
......@@ -307,7 +308,6 @@ class CustomerInvoice(models.Model):
self.delta_price_with_tax.amount = DECIMAL_ZERO
self.delta_vat.amount = DECIMAL_ZERO
def calculate_delta_transport(self):
self.delta_transport.amount = DECIMAL_ZERO
......
......@@ -348,10 +348,10 @@ class OfferItem(TranslatableModel):
unit_price = self.get_unit_price(customer_price=customer_price)
if len(qty_display) > 0:
if self.unit_deposit.amount > DECIMAL_ZERO:
return '%s, %s + ♻ %s' % (
return '%s; %s + ♻ %s' % (
qty_display, unit_price, self.unit_deposit)
else:
return '%s, %s' % (qty_display, unit_price)
return '%s; %s' % (qty_display, unit_price)
else:
if self.unit_deposit.amount > DECIMAL_ZERO:
return '%s + ♻ %s' % (
......@@ -361,7 +361,10 @@ class OfferItem(TranslatableModel):
def get_order_name(self, is_quantity_invoiced=False, box_unicode=BOX_UNICODE):
return '%s %s' % (self.long_name, self.get_qty_display(is_quantity_invoiced, box_unicode))
qty_display = self.get_qty_display(is_quantity_invoiced, box_unicode)
if qty_display:
return '%s %s' % (self.long_name, qty_display)
return '%s' % self.long_name
def get_long_name_with_producer_price(self):
return self.get_long_name(customer_price=False)
......@@ -370,7 +373,11 @@ class OfferItem(TranslatableModel):
get_long_name_with_producer_price.admin_order_field = 'translations__long_name'
def get_long_name(self, is_quantity_invoiced=False, customer_price=True, box_unicode=BOX_UNICODE):
return '%s %s' % (self.long_name, self.get_qty_and_price_display(is_quantity_invoiced, customer_price, box_unicode))
qty_and_price_display = self.get_qty_and_price_display(is_quantity_invoiced, customer_price, box_unicode)
if qty_and_price_display:
return '%s %s' % (self.long_name, qty_and_price_display)
return '%s' % self.long_name
get_long_name.short_description = (_("long_name"))
get_long_name.allow_tags = False
......
......@@ -264,10 +264,10 @@ class Product(TranslatableModel):
unit_price = self.get_unit_price(customer_price=customer_price)
if len(qty_display) > 0:
if self.unit_deposit.amount > DECIMAL_ZERO:
return '%s, %s + ♻ %s' % (
return '%s; %s + ♻ %s' % (
qty_display, unit_price, self.unit_deposit)
else:
return '%s, %s' % (qty_display, unit_price)
return '%s; %s' % (qty_display, unit_price)
else:
if self.unit_deposit.amount > DECIMAL_ZERO:
return '%s + ♻ %s' % (
......@@ -276,8 +276,10 @@ class Product(TranslatableModel):
return '%s' % unit_price
def get_long_name(self, is_quantity_invoiced=False, customer_price=True, box_unicode=BOX_UNICODE):
return '%s %s' % (
self.long_name, self.get_qty_and_price_display(is_quantity_invoiced, customer_price, box_unicode))
qty_and_price_display = self.get_qty_and_price_display(is_quantity_invoiced, customer_price, box_unicode)
if qty_and_price_display:
return '%s %s' % (self.long_name, qty_and_price_display)
return "%s" % self.long_name
get_long_name.short_description = (_("long_name"))
get_long_name.allow_tags = True
......
......@@ -184,7 +184,7 @@ class Purchase(models.Model):
get_delivery_display.allow_tags = False
def get_quantity(self):
if self.status < PERMANENCE_SEND:
if self.status < PERMANENCE_WAIT_FOR_SEND:
return self.quantity_ordered
else:
return self.quantity_invoiced
......@@ -192,19 +192,29 @@ class Purchase(models.Model):
get_quantity.short_description = (_("quantity invoiced"))
get_quantity.allow_tags = False
def get_producer_quantity(self):
if self.status < PERMANENCE_WAIT_FOR_SEND:
return self.quantity_ordered
else:
offer_item = self.offer_item
if offer_item.order_unit == PRODUCT_ORDER_UNIT_PC_KG:
if offer_item.order_average_weight != 0:
return (self.quantity_invoiced / offer_item.order_average_weight).quantize(FOUR_DECIMALS)
return self.quantity_invoiced
def get_long_name(self, customer_price=True):
if self.offer_item is not None:
if self.is_box_content:
return "%s %s" % (
self.offer_item.get_long_name(
is_quantity_invoiced=self.status >= PERMANENCE_SEND,
# is_quantity_invoiced=self.status >= PERMANENCE_WAIT_FOR_SEND,
customer_price=customer_price
),
BOX_UNICODE
)
else:
return self.offer_item.get_long_name(
is_quantity_invoiced=self.status >= PERMANENCE_SEND,
# is_quantity_invoiced=self.status >= PERMANENCE_WAIT_FOR_SEND,
customer_price=customer_price
)
else:
......@@ -307,10 +317,8 @@ class Purchase(models.Model):
def purchase_post_init(sender, **kwargs):
purchase = kwargs["instance"]
if purchase.id is not None:
if purchase.status < PERMANENCE_WAIT_FOR_SEND:
purchase.previous_quantity = purchase.quantity_ordered
else:
purchase.previous_quantity = purchase.quantity_invoiced
purchase.previous_quantity_ordered = purchase.quantity_ordered
purchase.previous_quantity_invoiced = purchase.quantity_invoiced
purchase.previous_purchase_price = purchase.purchase_price.amount
purchase.previous_selling_price = purchase.selling_price.amount
purchase.previous_producer_vat = purchase.producer_vat.amount
......@@ -318,6 +326,8 @@ def purchase_post_init(sender, **kwargs):
purchase.previous_deposit = purchase.deposit.amount
purchase.previous_comment = purchase.comment
else:
purchase.previous_quantity_ordered = DECIMAL_ZERO
purchase.previous_quantity_invoiced = DECIMAL_ZERO
purchase.previous_quantity = DECIMAL_ZERO
purchase.previous_purchase_price = DECIMAL_ZERO
purchase.previous_selling_price = DECIMAL_ZERO
......@@ -332,11 +342,17 @@ def purchase_pre_save(sender, **kwargs):
purchase = kwargs["instance"]
if purchase.status < PERMANENCE_WAIT_FOR_SEND:
quantity = purchase.quantity_ordered
delta_quantity = quantity - purchase.previous_quantity_ordered
if purchase.offer_item.order_unit == PRODUCT_ORDER_UNIT_PC_KG:
# This quantity is used to calculate the price
# The unit price is for 1 kg.
# 1 = 1 piece of order_average_weight
# 2 = 2 pices of order_average_weight
quantity *= purchase.offer_item.order_average_weight
else:
quantity = purchase.quantity_invoiced
delta_quantity = quantity - purchase.previous_quantity
delta_quantity = quantity - purchase.previous_quantity_invoiced
if purchase.is_box_content:
purchase.is_resale_price_fixed = True
if delta_quantity != DECIMAL_ZERO:
......@@ -415,10 +431,8 @@ def purchase_pre_save(sender, **kwargs):
total_profit=F('total_profit') + delta_profit
)
# Do not do it twice
if purchase.status < PERMANENCE_WAIT_FOR_SEND:
purchase.previous_quantity = purchase.quantity_ordered
else:
purchase.previous_quantity = purchase.quantity_invoiced
purchase.previous_quantity_ordered = purchase.quantity_ordered
purchase.previous_quantity_invoiced = purchase.quantity_invoiced
purchase.previous_purchase_price = purchase.purchase_price.amount
purchase.previous_selling_price = purchase.selling_price.amount
# -*- coding: utf-8 -*-
import thread
import threading
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
......@@ -670,7 +670,9 @@ def admin_cancel(permanence):
def admin_send(permanence):
if permanence.status == PERMANENCE_INVOICED:
thread.start_new_thread(email_invoice.send_invoice, (permanence.id,))
# thread.start_new_thread(email_invoice.send_invoice, (permanence.id,))
t = threading.Thread(target=email_invoice.send_invoice, args=(permanence.id,))
t.start()
user_message = _("Emails containing the invoices will be send to the customers and the producers.")
user_message_level = messages.INFO
else:
......
# -*- coding: utf-8 -*-
import datetime
import thread
import threading
import uuid
from django.conf import settings
......@@ -19,10 +19,8 @@ from repanier.models import OfferItem
from repanier.models import Permanence
from repanier.models import Producer
from repanier.models import Product
from repanier.tools import clean_offer_item
from repanier.tools import recalculate_order_amount, create_or_update_one_purchase, get_or_create_offer_item, \
add_months, \
reorder_offer_items
from repanier.tools import clean_offer_item, reorder_purchases
from repanier.tools import recalculate_order_amount, create_or_update_one_purchase, reorder_offer_items
@transaction.atomic
......@@ -261,13 +259,17 @@ def admin_open_and_send(request, permanence, do_not_send_any_mail=False):
else:
permanence.set_status(PERMANENCE_WAIT_FOR_PRE_OPEN)
# pre_open_order(permanence.id)
thread.start_new_thread(pre_open_order, (permanence.id,))
# thread.start_new_thread(pre_open_order, (permanence.id,))
t = threading.Thread(target=pre_open_order, args=(permanence.id,))
t.start()
user_message = _("The offers are being generated.")
user_message_level = messages.INFO
else:
permanence.set_status(PERMANENCE_WAIT_FOR_OPEN)
# open_order(permanence.id)
thread.start_new_thread(open_order, (permanence.id, do_not_send_any_mail))
# thread.start_new_thread(open_order, (permanence.id, do_not_send_any_mail))
t = threading.Thread(target=open_order, args=(permanence.id, do_not_send_any_mail))
t.start()
user_message = _("The offers are being generated.")
user_message_level = messages.INFO
return user_message, user_message_level
......@@ -417,9 +419,14 @@ def close_order(permanence, all_producers, producers_id=None):
@transaction.atomic
def send_order(permanence, all_producers, producers_id=None, deliveries_id=None):
def send_order(permanence, all_producers=True, producers_id=None, deliveries_id=None):
recalculate_order_amount(
permanence_id=permanence.id,
send_to_producer=True
)
reorder_purchases(permanence.id)
try:
email_order.email_order(permanence.id, all_producers, closed_deliveries_id=deliveries_id, producers_id=producers_id)
email_order.email_order(permanence.id, all_producers, producers_id=producers_id, closed_deliveries_id=deliveries_id)
except Exception as error_str:
print("################################## send_order")
print(error_str)
......@@ -491,7 +498,10 @@ def close_send_order(permanence_id, all_producers, producers_id=None, deliveries
def admin_close(permanence_id, all_producers=False, deliveries_id=None, producers_id=None):
# close_send_order(permanence_id, deliveries_id, False, False)
thread.start_new_thread(close_send_order, (permanence_id, all_producers, producers_id, deliveries_id, False))
# thread.start_new_thread(close_send_order, (permanence_id, all_producers, producers_id, deliveries_id, False))
t = threading.Thread(target=close_send_order,
args=(permanence_id, all_producers, producers_id, deliveries_id, False))
t.start()
user_message = _("The orders are being closed.")
user_message_level = messages.INFO
return user_message, user_message_level
......@@ -499,7 +509,10 @@ def admin_close(permanence_id, all_producers=False, deliveries_id=None, producer
def admin_send(permanence_id, all_producers=False, deliveries_id=None, producers_id=None):
# close_send_order(permanence_id, deliveries_id, True)
thread.start_new_thread(close_send_order, (permanence_id, all_producers, producers_id, deliveries_id, True))
# thread.start_new_thread(close_send_order, (permanence_id, all_producers, producers_id, deliveries_id, True))
t = threading.Thread(target=close_send_order,
args=(permanence_id, all_producers, producers_id, deliveries_id, True))
t.start()
user_message = _("The orders are being send.")
user_message_level = messages.INFO
return user_message, user_message_level
This diff is collapsed.
......@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import json
from django.contrib.auth.decorators import login_required
from django.core.serializers.json import DjangoJSONEncoder
from django.http import Http404
from django.http import HttpResponse
......@@ -12,7 +13,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_GET
from repanier.const import PERMANENCE_CLOSED, DECIMAL_ZERO
from repanier.const import DECIMAL_ZERO
from repanier.email.email_order import export_order_2_1_customer
from repanier.models import Customer, CustomerInvoice, Permanence
from repanier.tools import sint, get_signature, my_basket, my_order_confirmation, calc_basket_message
......@@ -20,14 +21,12 @@ from repanier.tools import sint, get_signature, my_basket, my_order_confirmation
@never_cache
@require_GET
# @login_required
@login_required
def btn_confirm_order_ajax(request):
if not request.is_ajax():
raise Http404
permanence_id = sint(request.GET.get('permanence', 0))
user = request.user
if not user.is_authenticated:
raise Http404
customer = Customer.objects.filter(
user_id=user.id, is_active=True, may_order=True).order_by('?').first()
if customer is None:
......
# -*- coding: utf-8
from __future__ import unicode_literals
import thread
import threading
from django import forms
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.mail import EmailMessage
from django.forms import Textarea
......@@ -15,7 +14,6 @@ from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from djng.forms import NgFormValidationMixin
from repanier.const import EMPTY_STRING
from repanier.models import Customer, Staff
from repanier.tools import send_email
from repanier.views.forms import RepanierForm
......@@ -73,7 +71,9 @@ def send_mail_to_all_members_view(request):
cc=to_email_customer
)
# send_email(email=email, from_name=user_customer.long_basket_name)
thread.start_new_thread(send_email,(email, user_customer.long_basket_name, True))
# thread.start_new_thread(send_email,(email, user_customer.long_basket_name, True))
t = threading.Thread(target=send_email, args=(email, user_customer.long_basket_name, True))
t.start()
email = form.fields["your_email"]
email.initial = request.user.email
email.widget.attrs['readonly'] = True
......
# -*- coding: utf-8
from __future__ import unicode_literals
import thread
import threading
from django import forms
from django.conf import settings
from django.contrib.auth.decorators import login_required
......@@ -102,7 +102,9 @@ def send_mail_to_coordinators_view(request):
cc=to_email_staff
)
# send_email(email=email)
thread.start_new_thread(send_email, (email,))
# thread.start_new_thread(send_email, (email,))
t = threading.Thread(target=send_email, args=(email,))
t.start()
# return HttpResponseRedirect('/')
email = form.fields["your_email"]
email.initial = request.user.email
......
This diff is collapsed.
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