Commit 35265c7e authored by Patrick's avatar Patrick

first release

parent b1c80fe3
......@@ -31,14 +31,8 @@ Login as : pi
.. code:: bash
sudo apt-get update && sudo apt-get -y upgrade
Install Virtualenv, Nginx, Uwsgi
--------------------------------
.. code:: bash
sudo apt-get install python-virtualenv
sudo apt-get update && sudo apt-get upgrade -uy
# sudo dist-upgrade -uy
Install Nginx
-------------
......@@ -84,12 +78,22 @@ For each of those files create a symbolic link between /etc/uwsgi/apps-enabled a
sudo ln -s /etc/wsgi/apps-available/´$FILE_NAME$´ /etc/wsgi/apps-enabled/´$FILE_NAME$´
Install RabbitMQ
----------------
Install Required libs for Django installation
---------------------------------------------
.. code:: bash
sudo apt-get install rabbitmq-server
sudo apt-get install gettext unzip
sudo apt-get python-setuptools
# vv For the PostgreSQL connector
sudo apt-get install libpq-dev python-dev
# vv for Pillow
sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms1-dev libwebp-dev tcl8.5-dev tk8.5-dev
# vv for docx
sudo apt-get install libxml2-dev libxslt1-dev
Optional : force static IP adress
---------------------------------
......
......@@ -2,9 +2,6 @@
How to setup PostgreSQL
-----------------------
- raspberrypi, using raspbian 'wheezy'
- virtualbox, using debian 'wheezy'
Install PostgreSQL
------------------
......
------------------------------------------------------
How to setup Virtualenv, Django, Django-cms - Repanier
------------------------------------------------------
Install Virtualenv
------------------
.. code:: bash
sudo apt-get install python-virtualenv
Install Django, Django-cms
--------------------------
Copy /install/install_new_virtualenv.sh and install_new_site.sh to your home directory.
.. code:: bash
chmod +x ~/install_new_virtualenv.sh
chmod +x ~/install_new_site.sh
~/install_new_virtualenv.sh v1
For each site replacing ´$REPANIER.BE$´ with the domain name of the corresponding site execute install_new_site.sh.
.. code:: bash
chmod +x ~/install_new_site.sh
~/install_new_site.sh v1 $REPANIER.BE$
Merge the folder /mysite of the git repo with the folder to ~/v1/mysite/mysite of your installation.
Copy the ´secret_key´ of ~/v1/mysite/mysite/setup.py and check DB paramters into the *.INI file loacted at /etc/uwsgi/apps-available/.
Generate a copy of static files needed by Django
.. code:: bash
cd ~/v1
source bin/activate
cd mysite
python manage.py collectstatic --settings=ptidej.ptidej_settings
# If some errors execute
# python manage.py collectstatic --traceback --settings=ptidej.ptidej_settings
# to detect the root cause
Create the DB with south. During this step you will be asked to create the ´superuser´ of Django.
.. code:: bash
python manage.py syncdb --all --settings=ptidej.ptidej_settings
python manage.py schemamigration repanier --initial --settings=ptidej.ptidej_settings
python manage.py migrate --fake --settings=ptidej.ptidej_settings
Check if CMS install is ok
.. code:: bash
python manage.py cms check --settings=ptidej.ptidej_settings
Compile translation files
.. code:: bash
cd ~/v1/mysite/repanier
export DJANGO_SETTINGS_MODULE=
django-admin.py compilemessages
If you want, initialize the DB with test content : copy the content of /install/createdb into ~/v1/mysite/
.. code:: bash
cd ~/v1/mysite/
export DJANGO_SETTINGS_MODULE='ptidej.ptidej_settings'
python createdb.py
Finalize th configuration
.. code:: bash
cd ~
ln -s ~/v1 ~/production
Restart Nginx and Uwsgi
.. code:: bash
# Restart Nginx
sudo /etc/init.d/nginx restart
# Stop Uwsgi
sudo /etc/init.d/uwsgi stop
# Clean the Django cache
rm -rf /var/tmp/django_cache/*
# Start Uwsgi
sudo /etc/init.d/uwsgi start
The surf on your sites
When needed, upgrade the DB with south for a new version of specific INSTALLED_APPS (eg repanier)
-------------------------------------------------------------------------------------------------
.. code:: bash
cd ~/production/mysite/
python manage.py schemamigration repanier --auto --settings=ptidej.ptidej_settings
python manage.py migrate repanier --settings=ptidej.ptidej_settings
If needed, check what South has done
.. code:: bash
cd ~/production/mysite/
python manage.py migrate --list --settings=mysite.repanier_settings
......@@ -10,8 +10,6 @@ mkdir $1
virtualenv $1
cd $1
source bin/activate
sudo apt-get install gettext unzip
sudo apt-get install libpq-dev python-dev python-setuptools
pip install psycopg2
# IF installing the latest stable version
# pip install django-cms
......@@ -32,7 +30,6 @@ pip install -U djangocms-text-ckeditor
# pip install -U djangocms-table
# pip install -U djangocms-googlemap
# For easy_thumbnails which need Pillow (https://github.com/python-imaging/Pillow)
sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms1-dev libwebp-dev tcl8.5-dev tk8.5-dev
pip install -U Pillow
pip install -U cmsplugin-filer
pip install -U django-reversion
......@@ -40,7 +37,6 @@ pip install -U django_compressor
pip install -U django-admin-sortable2
pip install -U openpyxl
# pip install -U django-hvad
sudo apt-get install libxml2-dev libxslt1-dev
pip install -U docx
# pip install django_debug_toolbar
# pip install django-dajaxice ! not working with Django 1.6
......
......@@ -12,7 +12,6 @@ from repanier.models import Staff
from repanier.models import Product
from repanier.models import LUT_ProductionMode
from repanier.models import LUT_DepartmentForCustomer
from repanier.models import LUT_DepartmentForProducer
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from openpyxl import load_workbook
......@@ -57,7 +56,7 @@ def add_all_customers(worksheet):
user_set = User.objects.filter(username = row['short_basket_name'])[:1]
if user_set:
for user in user_set:
user.password = make_password(uuid.uuid1().hex)
user.password = make_password("=test=")
user.is_superuser=False
user.is_staff=False
user.is_active=True
......@@ -83,7 +82,7 @@ def add_all_customers(worksheet):
customer.phone2 = row['phone2']
customer.address = row['address']
customer.vat_id = row['vat_id']
customer.represent_this_buyinggroup = ( row['represent_this_buyinggroup'] != None )
customer.balance = row['balance']
customer.is_active = True
customer.save()
else:
......@@ -97,7 +96,6 @@ def add_all_customers(worksheet):
date_balance = row['date_balance'],
balance = row['balance'],
vat_id = row['vat_id'],
represent_this_buyinggroup = ( row['represent_this_buyinggroup'] != None ),
is_active = True)
row_num += 1
......@@ -118,7 +116,7 @@ def add_all_staffs(worksheet):
user_set = User.objects.filter(username = row['username'])[:1]
if user_set:
for user in user_set:
user.password = make_password(uuid.uuid1().hex)
user.password = make_password("=test=")
user.is_superuser=False
user.is_staff=False
user.is_active=True
......@@ -137,14 +135,14 @@ def add_all_staffs(worksheet):
customer_responsible_id = None
if row['customer_responsible']:
customer_responsible = Customer.objects.get(
short_basket_name = row['customer_responsible']).id
short_basket_name = row['customer_responsible'])
staff = None
staff_set = Staff.objects.filter(user_id = user.id)[:1]
if staff_set:
for staff in staff_set:
staff.long_name = row['long_name']
staff.customer_responsible_id = customer_responsible_id
staff.customer_responsible_id = customer_responsible.id
staff.is_reply_to_order_email = ( row['is_reply_to_order_email'] != None )
staff.is_reply_to_invoice_email = ( row['is_reply_to_invoice_email'] != None )
staff.is_active = True
......@@ -153,7 +151,7 @@ def add_all_staffs(worksheet):
Staff.objects.create(
user_id = user.id,
long_name = row['long_name'],
customer_responsible_id = customer_responsible,
customer_responsible_id = customer_responsible.id,
is_reply_to_order_email = ( row['is_reply_to_order_email'] != None ),
is_reply_to_invoice_email = ( row['is_reply_to_invoice_email'] != None ),
is_active = True)
......@@ -186,7 +184,6 @@ def add_all_producers(worksheet):
producer.price_list_multiplier = row['price_list_multiplier']
producer.date_balance = row['date_balance']
producer.balance = row['balance']
producer.represent_this_buyinggroup = ( row['represent_this_buyinggroup'] != None )
producer.is_active = True
producer.save()
else:
......@@ -197,13 +194,10 @@ def add_all_producers(worksheet):
phone1 = row['phone1'],
phone2 = row['phone2'],
fax = row['fax'],
bank_account = row['bank_account'],
vat_id = row['vat_id'],
address = row['address'],
price_list_multiplier = row['price_list_multiplier'],
date_balance = row['date_balance'],
balance = row['balance'],
represent_this_buyinggroup = ( row['represent_this_buyinggroup'] != None ),
is_active = True)
row_num += 1
......@@ -220,10 +214,10 @@ def add_all_products(worksheet):
print row
producer_id = None
producer = None
if row['producer']:
producer_id = Producer.objects.get(
short_profile_name = row['producer']).id
producer = Producer.objects.get(
short_profile_name = row['producer'])
production_mode_id = None
if row['production_mode']:
......@@ -251,37 +245,23 @@ def add_all_products(worksheet):
if department_for_customer!= None:
department_for_customer_id = department_for_customer.id
department_for_producer_id = None
if row['department_for_producer']:
department_for_producer_set = LUT_DepartmentForProducer.objects.filter(
short_name = row['department_for_producer'])[:1]
if department_for_producer_set:
department_for_producer_id = department_for_producer_set[0].id
else:
department_for_producer = LUT_DepartmentForProducer.objects.create(
short_name = row['department_for_producer'],
is_active = True)
if department_for_producer!= None:
department_for_producer_id = department_for_producer.id
product = None
product_set = Product.objects.filter(
producer_id = producer_id,
producer_id = producer.id,
long_name = row['long_name']
)[:1]
if product_set:
for product in product_set:
product.producer_id = producer_id
product.producer_id = producer.id
product.long_name = row['long_name']
product.production_mode_id = production_mode_id
product.department_for_customer_id = department_for_customer_id
product.department_for_producer_id = department_for_producer_id
product.order_by_kg_pay_by_kg = ( row['order_by_kg_pay_by_kg'] != None )
product.order_by_piece_pay_by_kg = ( row['order_by_piece_pay_by_kg'] != None )
product.order_average_weight = row['order_average_weight']
product.order_by_piece_pay_by_piece = ( row['order_by_piece_pay_by_piece'] != None )
product.producer_must_give_order_detail_per_customer = ( row['producer_must_give_order_detail_per_customer'] != None )
product.producer_unit_price = row['producer_unit_price']
product.original_unit_price = row['producer_unit_price']
product.customer_minimum_order_quantity = row['customer_minimum_order_quantity']
product.customer_increment_order_quantity = row['customer_increment_order_quantity']
product.customer_alert_order_quantity = row['customer_alert_order_quantity']
......@@ -289,17 +269,16 @@ def add_all_products(worksheet):
product.save()
else:
product = Product.objects.create(
producer_id = producer_id,
producer_id = producer.id,
long_name = row['long_name'],
production_mode_id = production_mode_id,
department_for_customer_id = department_for_customer_id,
department_for_producer_id = department_for_producer_id,
order_by_kg_pay_by_kg = ( row['order_by_kg_pay_by_kg'] != None ),
order_by_piece_pay_by_kg = ( row['order_by_piece_pay_by_kg'] != None ),
order_average_weight = row['order_average_weight'],
order_by_piece_pay_by_piece = ( row['order_by_piece_pay_by_piece'] != None ),
producer_must_give_order_detail_per_customer = ( row['producer_must_give_order_detail_per_customer'] != None ),
producer_unit_price = row['producer_unit_price'],
original_unit_price = row['producer_unit_price'],
customer_minimum_order_quantity = row['customer_minimum_order_quantity'],
customer_increment_order_quantity = row['customer_increment_order_quantity'],
customer_alert_order_quantity = row['customer_alert_order_quantity'],
......
# crontab -e
# Every hour/5'
# 5 */1 * * * /home/pi/v1/ptidej/cron/close_orders.sh >/dev/null 2>&1
# At 6h5, 12h5, .., 22h5
# 5 6,12,14,16,18,19,20,21,22 * * * /home/pi/v1/ptidej/cron/close_orders.sh >/dev$
# Do not forget to change chmod +x on this .sh file
export DJANGO_SETTINGS_MODULE=mysite.$REPANIER.BE$_settings
export DJANGO_SETTINGS_MODULE_CELERY_APP=mysite
export DJANGO_SETTINGS_MODULE_CELERY_USER=$CEL_USER$
export DJANGO_SETTINGS_MODULE_CELERY_PASSWORD=$CEL_PASSWORD$
export DJANGO_SETTINGS_MODULE_DEBUG=False
export DJANGO_SETTINGS_MODULE_DATABASE_NAME=$NAME$
export DJANGO_SETTINGS_MODULE_DATABASE_USER=$USER$
export DJANGO_SETTINGS_MODULE_DATABASE_PASSWORD=$PASSWORD$
export =DJANGO_SETTINGS_MODULE_DATABASE_HOST=127.0.0.1
export =DJANGO_SETTINGS_MODULE_DATABASE_PORT=5432
export =DJANGO_SETTINGS_MODULE_EMAIL_HOST=$EMAIL_HOST$
export =DJANGO_SETTINGS_MODULE_EMAIL_HOST_USER=$EMAIL_HOST_USER$
export =DJANGO_SETTINGS_MODULE_EMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD$
export =DJANGO_SETTINGS_MODULE_EMAIL_PORT=$EMAIL_PORT$
export =DJANGO_SETTINGS_MODULE_EMAIL_USE_TLS=True
export =DJANGO_SETTINGS_MODULE_ADMIN_NAME=$ADMIN_NAME$
export =DJANGO_SETTINGS_MODULE_ADMIN_EMAIL=$ADMIN_EMAIL$
/$PATH_TO$/$VIRTUAL_ENV$/python /$PATH_TO$/$VIRTUAL_ENV$/mysite/manage.py close_orders
from __future__ import absolute_import
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
\ No newline at end of file
This diff is collapsed.
......@@ -3,20 +3,20 @@
# 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"
"Project-Id-Version: Repanier\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-12 18:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2014-03-18 21:19+0100\n"
"Last-Translator: Patrick Colmant <pcolmant@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.6.4\n"
#: ptidej_settings.py:18
msgid "Homepage"
......
......@@ -3,20 +3,20 @@
# 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"
"Project-Id-Version: Repanier\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-11 22:59+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2014-03-18 21:20+0100\n"
"Last-Translator: Patrick Colmant <pcolmant@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.6.4\n"
#: collect-static/admin/js/SelectFilter2.js:45
#, c-format
......
......@@ -3,7 +3,7 @@ from common_settings import *
### Site 3 specific parameters
SITE_ID = 1
ALLOWED_HOSTS = ['ptidej.$REPANIER.BE$',]
ALLOWED_HOSTS = ['ptidej.repanier.be','ptidej.repanier.local']
EMAIL_SUBJECT_PREFIX = '['+ ALLOWED_HOSTS[0] +']'
# DEFAULT_FROM_EMAIL Used by PASSWORD RESET
DEFAULT_FROM_EMAIL=ALLOWED_HOSTS[0] + "@repanier.be"
......@@ -33,6 +33,7 @@ CMS_PLACEHOLDER_CONF = {
'home-hero': {
'name': gettext('Hero'),
'plugins': ['TextPlugin',],
# 'plugins': ['TextPlugin', 'LinkPlugin', 'StylePlugin', 'GoogleMapPlugin', 'MultiColumnPlugin', 'SnippetPlugin', 'VideoPlugin', 'CMSOembedVideoPlugin', 'TablePlugin'],
},
'home-col-1': {
'name': gettext('Column 1'),
......@@ -55,4 +56,17 @@ CMS_PLACEHOLDER_CONF = {
'name': gettext('Content'),
'plugins': ['TextPlugin',],
},
}
\ No newline at end of file
}
CMS_STYLE_NAMES = (
('info', gettext("info")),
('new', gettext("new")),
('hint', gettext("hint")),
)
CMS_COLUMN_WIDTH_CHOICES = (
('1', gettext("normal")),
('2', gettext("2x")),
('3', gettext("3x")),
('4', gettext("4x"))
)
\ No newline at end of file
{% load admin_static %}{% load firstof from future %}<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
{% block extrastyle %}{% endblock %}
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{% static "admin/css/ie.css" %}{% endblock %}" /><![endif]-->
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
<script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "admin/" %}{% endfilter %}";</script>
{% block extrahead %}{% endblock %}
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
</head>
{% load i18n %}
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}">
<!-- Container -->
<div id="container">
{% if not is_popup %}
<!-- Header -->
<div id="header">
{% block nav-global %}{% endblock %}
</div>
<!-- END Header -->
{% endif %}
{% block messages %}
{% if messages %}
<ul class="messagelist">{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
{% endfor %}</ul>
{% endif %}
{% endblock messages %}
<!-- Content -->
<div id="content" class="{% block coltype %}colM{% endblock %}">
{% block pretitle %}{% endblock %}
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
{% block content %}
{% block object-tools %}{% endblock %}
{{ content }}
{% endblock %}
{% block sidebar %}{% endblock %}
<br class="clear" />
</div>
<!-- END Content -->
{% block footer %}<div id="footer"></div>{% endblock %}
</div>
<!-- END Container -->
</body>
</html>
......@@ -7,7 +7,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% addtoblock "css" %}<link rel="stylesheet" href="{{ STATIC_URL}}bootstrap/css/bootstrap.min.css">{% endaddtoblock %}
{% addtoblock "css" %}<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">{% endaddtoblock %}
{% addtoblock "css" %}<link rel="stylesheet" href="{{ STATIC_URL}}bootstrap/css/custom.css">{% endaddtoblock %}
{% addtoblock "css" %}
<style type="text/css">
......@@ -80,8 +80,8 @@
</center>
</nav>
</div>
{% addtoblock "js" %}<script src="{{ STATIC_URL }}js/jquery-1.10.1.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script src="{{ STATIC_URL}}bootstrap/js/bootstrap.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>{% endaddtoblock %}
{% render_block "jsuncompressed" %}
{% render_block "js" %}
{% render_block "lastjs" %}
......
......@@ -2,6 +2,7 @@ from django.conf.urls import patterns, include, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.contrib import auth
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from cms.sitemaps import CMSSitemap
......@@ -12,11 +13,14 @@ admin.autodiscover()
# )
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^go_repanier/$', auth.views.login, name='login_form'),
url(r'^leave_repanier/$', auth.views.logout, name='logout_form'),
url(r'^coordi/', include(admin.site.urls)),
url(r'^repanier/', include('repanier.urls')),
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': {'cmspages': CMSSitemap}}),
# url(r'^', include('filer.server.urls')),
url(r'^', include('password_reset.urls')),
url(r'^', include('cms.urls')),
url(r'^', include('filer.server.urls')),
)
urlpatterns += staticfiles_urlpatterns()
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,7 +6,6 @@ from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.mail import EmailMultiAlternatives
from django.core.mail import EmailMessage
from django.template.loader import render_to_string
from django.utils.html import strip_tags
......@@ -25,12 +24,12 @@ from repanier.admin_export_xlsx import export_order_customer_xlsx
from repanier.admin_export_xlsx import export_orders_xlsx
from repanier.admin_export_xlsx import export_invoices_xlsx
def send_test_email(request, queryset):
def send_alert_email(permanence, current_site_name):
try:
send_mail('Test sujet', 'Test msg', settings.ALLOWED_HOSTS[0] + '@repanier.be', ['pcolmant@gmail.com'])
send_mail('Alert - ' + " - " + unicode(permanence) + " - " + current_site_name, permanence.get_status_display(), settings.ALLOWED_HOSTS[0] + '@repanier.be', ['pcolmant@gmail.com'])
# send_mail('Test sujet', 'Test msg', 'coordi@repanier.be', ['pcolmant@gmail.com'])
except BadHeaderError:
self.message_user(request, _("Invalid header found."))
except:
pass
# subject, from_email, to = 'Order Confirmation', 'admin@yourdomain.com', 'someone@somewhere.com'
......@@ -44,7 +43,7 @@ def send_test_email(request, queryset):
# msg.attach_alternative(html_content, "text/html")
# msg.send()
def email_offers(permanence_id, current_site):
def email_offers(permanence_id, current_site_name):
permanence = Permanence.objects.get(id=permanence_id)
sender_email = settings.DEFAULT_FROM_EMAIL
for staff in Staff.objects.all().active().order_by():
......@@ -53,18 +52,19 @@ def email_offers(permanence_id, current_site):
bcc_email = []
for customer in Customer.objects.all().active().not_the_buyinggroup().may_order().order_by():
bcc_email.append(customer.user.email)
# bcc_email.append('pcolmant@gmail.com')
html_content = permanence.offer_description
email = EmailMultiAlternatives(
_("Orders opened") + " " + current_site.name + ", " + permanence.__unicode__(),
unicode(_("Opening of orders")) + " - " + unicode(permanence) + " - " + current_site_name,
strip_tags(html_content),
sender_email,
# [sender_email],
bcc=bcc_email
)
email.attach_alternative(html_content, "text/html")
email.send()
# email.send()
def email_orders(permanence_id, current_site):
def email_orders(permanence_id, current_site_name):
permanence = Permanence.objects.get(id=permanence_id)
sender_email = settings.DEFAULT_FROM_EMAIL
cc_email_staff = []
......@@ -86,7 +86,7 @@ def email_orders(permanence_id, current_site):
c_part = ''
c=permanenceboard.customer
if c:
c_part = c.short_basket_name + ',' + c.phone1
c_part = c.long_basket_name + ',' + c.phone1
if first_board:
board_composition += '<br/>'
board_composition += r_part + c_part + '<br/>'
......@@ -98,57 +98,60 @@ def email_orders(permanence_id, current_site):
for producer in producer_set:
wb = export_order_producer_xlsx(permanence=permanence, producer=producer, wb=None)
html_content = producer.order_description
long_profile_name = producer.long_profile_name if producer.long_profile_name != None else producer.short_profile_name
email = EmailMultiAlternatives(
current_site.name + ", " + permanence.__unicode__() + " - " + producer.short_profile_name,
unicode(_("Order")) + " - " + unicode(permanence) + " - " + current_site_name + " - " + long_profile_name,
strip_tags(html_content),
sender_email,
[producer.email],
bcc=['pcolmant@gmail.com'],
# bcc=['pcolmant@gmail.com'],
cc=cc_email_staff
)
email.attach(permanence.__unicode__() + '.xlsx',
email.attach(unicode(permanence) + '.xlsx',
save_virtual_workbook(wb),
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
email.attach_alternative(html_content, "text/html")
email.send()
# email.send()
customer_set = Customer.objects.filter(
purchase__permanence=permanence_id).order_by().distinct()
for customer in customer_set:
wb = export_order_customer_xlsx(permanence=permanence, customer=customer, wb=None)
html_content = permanence.order_description + board_composition
long_basket_name = customer.long_basket_name if customer.long_basket_name != None else customer.short_baskrt_name
email = EmailMultiAlternatives(
current_site.name + ", " + permanence.__unicode__() + " - " + customer.short_basket_name,
unicode(_("Order")) + " - " + unicode(permanence) + " - " + current_site_name + " - " + long_basket_name,
strip_tags(html_content),
sender_email,
[customer.user.email],
bcc=['pcolmant@gmail.com']
# bcc=['pcolmant@gmail.com']
)
email.attach(permanence.__unicode__() + '.xlsx',
email.attach(unicode(permanence) + '.xlsx',
save_virtual_workbook(wb),
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
email.attach_alternative(html_content, "text/html")
email.send()
# email.send()
wb = export_orders_xlsx(permanence=permanence, wb=None)
to_email_board = []
for permanenceboard in PermanenceBoard.objects.filter(
permanence=permanence_id).order_by():
to_email_board.append(permanenceboard.customer.user.email)
if permanenceboard.customer:
to_email_board.append(permanenceboard.customer.user.email)
html_content = permanence.order_description + board_message
email = EmailMultiAlternatives(
current_site.name + ", " + permanence.__unicode__() + " - " + unicode(_('permanence preparation list')),
unicode(_('Permanence preparation list')) + " - " + unicode(permanence) + " - " + current_site_name,
strip_tags(html_content),
sender_email,
to_email_board,
bcc=['pcolmant@gmail.com'],
# bcc=['pcolmant@gmail.com'],
cc=cc_email_staff
)
email.attach(permanence.__unicode__() + '.xlsx',
email.attach(unicode(permanence) + '.xlsx',