Commit 5291b26f authored by Patrick's avatar Patrick

use of cms 3.0.3, ckeditor using bootstrap 3, many new features.

parent 111c7306
This source diff could not be displayed because it is too large. You can view the blob instead.
# -*- coding: utf-8 -*-
from const import *
from django.utils.translation import ugettext_lazy as _
from repanier.models import Customer
from repanier.models import LUT_DepartmentForCustomer
from repanier.models import Permanence
from repanier.models import Producer
from repanier.models import Product
# Filters in the right sidebar of the change list page of the admin
from django.contrib.admin import SimpleListFilter
class ProductFilterByProducer(SimpleListFilter):
# Human-readable title which will be displayed in the
# right admin sidebar.
title = _("producers")
# Parameter for the filter that will be used in the URL query.
parameter_name = 'producer'
def lookups(self, request, model_admin):
"""
Returns a list of tuples. The first element in each
tuple is the coded value for the option that will
appear in the URL query. The second element is the
human-readable name for the option that will appear
in the right sidebar.
"""
# This list is a collection of producer.id, .name
return [(c.id, c.short_profile_name) for c in
Producer.objects.filter(is_active=True)
]
def queryset(self, request, queryset):
"""
Returns the filtered queryset based on the value
provided in the query string and retrievable via
`self.value()`.
"""
# This query set is a collection of products
if self.value():
return queryset.filter(producer_id=self.value())
else:
return queryset
class ProductFilterByDepartmentForThisProducer(SimpleListFilter):
title = _("departments for customer")
parameter_name = 'department_for_customer'
def lookups(self, request, model_admin):
producer_id = request.GET.get('producer')
if producer_id:
inner_qs = Product.objects.filter(is_active=True, producer_id=producer_id).order_by().distinct(
'department_for_customer__id')
else:
inner_qs = Product.objects.filter(is_active=True).order_by().distinct(
'department_for_customer__id')
return [(c.id, c.short_name) for c in
LUT_DepartmentForCustomer.objects.filter(is_active=True, product__in=inner_qs)
]
def queryset(self, request, queryset):
# This query set is a collection of products
if self.value():
return queryset.filter(department_for_customer_id=self.value())
else:
return queryset
class PurchaseFilterByCustomerForThisPermanence(SimpleListFilter):
title = _("customer")
parameter_name = 'customer'
def lookups(self, request, model_admin):
permanence_id = request.GET.get('permanence')
if permanence_id:
return [(c.id, c.short_basket_name) for c in
Customer.objects.filter(purchase__permanence_id=permanence_id).distinct()
]
else:
return [(c.id, c.short_basket_name) for c in
Customer.objects.filter(may_order=True)
]
def queryset(self, request, queryset):
# This query set is a collection of permanence
if self.value():
return queryset.filter(customer_id=self.value())
else:
return queryset
class PurchaseFilterByProducerForThisPermanence(SimpleListFilter):
title = _("producer")
parameter_name = 'producer'
def lookups(self, request, model_admin):
permanence_id = request.GET.get('permanence')
if permanence_id:
return [(c.id, c.short_profile_name) for c in
Producer.objects.filter(permanence=permanence_id).distinct()
]
else:
return [(c.id, c.short_profile_name) for c in
Producer.objects.filter(is_active=True)
]
def queryset(self, request, queryset):
# This query set is a collection of permanence
if self.value():
return queryset.filter(producer_id=self.value())
else:
return queryset
class PurchaseFilterByPermanence(SimpleListFilter):
title = _("permanences")
parameter_name = 'permanence'
def lookups(self, request, model_admin):
# This list is a collection of permanence.id, .name
return [(c.id, c.__unicode__()) for c in
Permanence.objects.filter(status__in=[PERMANENCE_OPENED, PERMANENCE_SEND])
]
def queryset(self, request, queryset):
# This query set is a collection of permanence
if self.value():
return queryset.filter(permanence_id=self.value())
else:
return queryset
......@@ -4,57 +4,58 @@ from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
class RepanierCustomBackend(ModelBackend):
def authenticate(self, **credentials):
user_or_none = None
try:
user_or_none = super(RepanierCustomBackend, self).authenticate(**credentials)
if user_or_none and not user_or_none.is_superuser:
# if not (user_or_none.is_active):
# user_or_none = None
# else:
is_customer = False
is_staff = False
try:
a = user_or_none.customer
is_customer = True
except:
try:
a = user_or_none.staff
is_staff = True
except:
user_or_none = None
except Exception as e:
user_or_none = None
# if user_or_none :
# print ('Authenyticate user : %s' % getattr(user_or_none, get_user_model().USERNAME_FIELD))
# else:
# print ('Authenticate user : not defined')
return user_or_none
def authenticate(self, **credentials):
user_or_none = None
try:
user_or_none = super(RepanierCustomBackend, self).authenticate(**credentials)
if user_or_none and not user_or_none.is_superuser:
# if not (user_or_none.is_active):
# user_or_none = None
# else:
is_customer = False
is_staff = False
try:
a = user_or_none.customer
is_customer = True
except:
try:
a = user_or_none.staff
is_staff = True
except:
user_or_none = None
except Exception as e:
user_or_none = None
# if user_or_none :
# print ('Authenyticate user : %s' % getattr(user_or_none, get_user_model().USERNAME_FIELD))
# else:
# print ('Authenticate user : not defined')
return user_or_none
def get_user(self, user_id):
user_or_none = None
try:
user_or_none = User.objects.get(pk=user_id)
if user_or_none and not user_or_none.is_superuser:
# if not (user_or_none.is_active):
# user_or_none = None
# else:
is_customer = False
is_staff = False
try:
a = user_or_none.customer
is_customer = True
except:
try:
a = user_or_none.staff
is_staff = True
except:
user_or_none = None
except:
user_or_none = None
# if user_or_none :
# print ('Get user : %s' % getattr(user_or_none, get_user_model().USERNAME_FIELD))
# else:
# print ('Get user : not defined')
return user_or_none
\ No newline at end of file
def get_user(self, user_id):
user_or_none = None
try:
user_or_none = User.objects.get(pk=user_id)
if user_or_none and not user_or_none.is_superuser:
# if not (user_or_none.is_active):
# user_or_none = None
# else:
is_customer = False
is_staff = False
try:
a = user_or_none.customer
is_customer = True
except:
try:
a = user_or_none.staff
is_staff = True
except:
user_or_none = None
except:
user_or_none = None
# if user_or_none :
# print ('Get user : %s' % getattr(user_or_none, get_user_model().USERNAME_FIELD))
# else:
# print ('Get user : not defined')
return user_or_none
\ No newline at end of file
......@@ -8,94 +8,55 @@ from cms.toolbar.items import Break, SubMenu
from cms.cms_toolbar import ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK
from cms.toolbar_base import CMSToolbar
@toolbar_pool.register
class RepanierToolbar(CMSToolbar):
def populate(self):
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, _('Manage'))
# _('Administration')
position = admin_menu.get_alphabetical_insert_position(
_('Parameters'),
SubMenu
)
if not position:
position = admin_menu.find_first(
Break,
identifier=ADMINISTRATION_BREAK
) + 1
position = 0
admin_menu.add_break('custom-break', position=position)
office_menu = admin_menu.get_or_create_menu(
'parameter-menu',
_('Paramters ...'),
position=position
)
# add_sideframe_item
url = reverse('admin:repanier_staff_changelist')
office_menu.add_sideframe_item(_('Staff Member List'), url=url)
url = reverse('admin:repanier_lut_permanencerole_changelist')
office_menu.add_sideframe_item(_('Permanence Role List'), url=url)
url = reverse('admin:repanier_lut_productionmode_changelist')
office_menu.add_sideframe_item(_('Production Mode List'), url=url)
url = reverse('admin:repanier_lut_departmentforcustomer_changelist')
office_menu.add_sideframe_item(_('Departement for Customer List'), url=url)
position += 1
url = reverse('admin:repanier_customer_changelist')
admin_menu.add_sideframe_item(_('Customer List'), url=url, position=position)
position += 1
url = reverse('admin:repanier_producer_changelist')
admin_menu.add_sideframe_item(_('Producer List'), url=url, position=position)
position += 1
url = reverse('admin:repanier_permanenceinpreparation_changelist')
admin_menu.add_sideframe_item(_('Permanence in Preparation List'), url=url, position=position)
def populate(self):
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, _('Manage'))
# _('Administration')
position = admin_menu.get_alphabetical_insert_position(
_('Parameters'),
SubMenu
)
if not position:
position = admin_menu.find_first(
Break,
identifier=ADMINISTRATION_BREAK
) + 1
position = 0
admin_menu.add_break('custom-break', position=position)
office_menu = admin_menu.get_or_create_menu(
'parameter-menu',
_('Paramters ...'),
position=position
)
# add_sideframe_item
url = reverse('admin:repanier_staff_changelist')
office_menu.add_sideframe_item(_('Staff Member List'), url=url)
# url = reverse('admin:repanier_staff_add')
# office_menu.add_modal_item(_('Add New Staff Member'), url=url)
# office_menu.add_break()
url = reverse('admin:repanier_lut_permanencerole_changelist')
office_menu.add_sideframe_item(_('Permanence Role List'), url=url)
# url = reverse('admin:repanier_lut_permanencerole_add')
# office_menu.add_modal_item(_('Add New Permanence Role'), url=url)
# office_menu.add_break()
url = reverse('admin:repanier_lut_productionmode_changelist')
office_menu.add_sideframe_item(_('Production Mode List'), url=url)
# url = reverse('admin:repanier_lut_productionmode_add')
# office_menu.add_modal_item(_('Add New Production Mode'), url=url)
# office_menu.add_break()
url = reverse('admin:repanier_lut_departmentforcustomer_changelist')
office_menu.add_sideframe_item(_('Departement for Customer List'), url=url)
# url = reverse('admin:repanier_lut_departmentforcustomer_add')
# office_menu.add_modal_item(_('Add New Departement for Customer'), url=url)
# position += 1
# customer_menu = admin_menu.get_or_create_menu(
# 'customer-menu',
# _('Customer ...'),
# position=position
# )
position += 1
url = reverse('admin:repanier_customer_changelist')
admin_menu.add_sideframe_item(_('Customer List'), url=url, position=position)
# url = reverse('admin:repanier_customer_add')
# customer_menu.add_modal_item(_('Add New Customer'), url=url)
# producer_menu = admin_menu.get_or_create_menu(
# 'producer-menu',
# _('Producer ...'),
# position=position
# )
position += 1
url = reverse('admin:repanier_producer_changelist')
admin_menu.add_sideframe_item(_('Producer List'), url=url, position=position)
# url = reverse('admin:repanier_producer_add')
# producer_menu.add_modal_item(_('Add New Producer'), url=url)
# producer_menu.add_break()
# url = reverse('admin:repanier_product_changelist')
# producer_menu.add_sideframe_item(_('Product List'), url=url)
# url = reverse('admin:repanier_product_add')
# producer_menu.add_modal_item(_('Add New Product'), url=url)
position += 1
# order_menu = admin_menu.get_or_create_menu(
# 'order-menu',
# _('Order ...'),
# position=position
# )
url = reverse('admin:repanier_permanenceinpreparation_changelist')
admin_menu.add_sideframe_item(_('Permanence in Preparation List'), url=url, position=position)
# url = reverse('admin:repanier_permanenceinpreparation_add')
# order_menu.add_modal_item(_('Add New Permanence in Preparation'), url=url)
position += 1
# invoice_menu = admin_menu.get_or_create_menu(
# 'invoice-menu',
# _('Invoice ...'),
# position=position
# )
url = reverse('admin:repanier_permanencedone_changelist')
admin_menu.add_sideframe_item(_('Permanence done List'), url=url, position=position)
position += 1
url = reverse('admin:repanier_bankaccount_changelist')
admin_menu.add_sideframe_item(_('Bank Account List'), url=url, position=position)
# url = reverse('admin:repanier_bankaccount_add')
# invoice_menu.add_modal_item(_('Add New Bank Account'), url=url)
\ No newline at end of file
if self.request.user.groups.filter(name=READ_ONLY_GROUP).count() == 0:
# Not visible for read-only users
position += 1
url = reverse('admin:repanier_permanencedone_changelist')
admin_menu.add_sideframe_item(_('Permanence done List'), url=url, position=position)
position += 1
url = reverse('admin:repanier_bankaccount_changelist')
admin_menu.add_sideframe_item(_('Bank Account List'), url=url, position=position)
# -*- coding: utf-8 -*-
from decimal import *
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
READ_ONLY_GROUP = "read_only"
ORDER_GROUP = "order"
INVOICE_GROUP = "invoice"
DECIMAL_ZERO = Decimal('0')
DECIMAL_ONE = Decimal('1')
DECIMAL_0_01 = Decimal('.01')
DECIMAL_0_001 = Decimal('.001')
DECIMAL_0_0001 = Decimal('.0001')
DECIMAL_1_02 = Decimal('1.02')
DECIMAL_1_06 = Decimal('1.06')
DECIMAL_0_06 = Decimal('0.06')
DECIMAL_0_12 = Decimal('0.12')
DECIMAL_0_21 = Decimal('0.21')
ZERO_DECIMAL = Decimal('0')
TWO_DECIMALS = Decimal('0.00')
THREE_DECIMALS = Decimal('0.000')
FOUR_DECIMALS = Decimal('0.0000')
PERMANENCE_DISABLED = '050'
PERMANENCE_PLANIFIED = '100'
PERMANENCE_WAIT_FOR_OPEN = '200'
PERMANENCE_PLANIFIED = '100'
PERMANENCE_WAIT_FOR_OPEN = '200'
PERMANENCE_OPENED = '300'
PERMANENCE_WAIT_FOR_SEND = '400'
PERMANENCE_SEND = '500'
......@@ -21,15 +32,15 @@ PERMANENCE_DONE = '800'
PERMANENCE_CANCELED = '900'
LUT_PERMANENCE_STATUS = (
(PERMANENCE_DISABLED, unicode(_('disabled'))),
(PERMANENCE_PLANIFIED, unicode(_('planified'))),
(PERMANENCE_WAIT_FOR_OPEN, unicode(_('wait for open'))),
(PERMANENCE_OPENED, unicode(_('orders opened'))),
(PERMANENCE_WAIT_FOR_SEND, unicode(_('wait for send'))),
(PERMANENCE_SEND, unicode(_('orders send to producers'))),
(PERMANENCE_WAIT_FOR_DONE, unicode(_('wait for done'))),
(PERMANENCE_INVOICES_VALIDATION_FAILED, unicode(_('invoices validation test failed'))),
(PERMANENCE_DONE, unicode(_('done')))
(PERMANENCE_DISABLED, unicode(_('disabled'))),
(PERMANENCE_PLANIFIED, unicode(_('planified'))),
(PERMANENCE_WAIT_FOR_OPEN, unicode(_('wait for open'))),
(PERMANENCE_OPENED, unicode(_('orders opened'))),
(PERMANENCE_WAIT_FOR_SEND, unicode(_('wait for send'))),
(PERMANENCE_SEND, unicode(_('orders send to producers'))),
(PERMANENCE_WAIT_FOR_DONE, unicode(_('wait for done'))),
(PERMANENCE_INVOICES_VALIDATION_FAILED, unicode(_('invoices validation test failed'))),
(PERMANENCE_DONE, unicode(_('done')))
)
PRODUCT_PLACEMENT_FREEZER = '100'
......@@ -38,15 +49,17 @@ PRODUCT_PLACEMENT_OUT_OF_BASKET = '300'
PRODUCT_PLACEMENT_BASKET = '400'
LUT_PRODUCT_PLACEMENT = (
(PRODUCT_PLACEMENT_FREEZER, unicode(_('freezer'))),
(PRODUCT_PLACEMENT_FRIDGE, unicode(_('fridge'))),
(PRODUCT_PLACEMENT_OUT_OF_BASKET, unicode(_('loose, out of the basket'))),
(PRODUCT_PLACEMENT_BASKET, unicode(_('into the basket'))),
(PRODUCT_PLACEMENT_FREEZER, unicode(_('freezer'))),
(PRODUCT_PLACEMENT_FRIDGE, unicode(_('fridge'))),
(PRODUCT_PLACEMENT_OUT_OF_BASKET, unicode(_('loose, out of the basket'))),
(PRODUCT_PLACEMENT_BASKET, unicode(_('into the basket'))),
)
PRODUCT_ORDER_UNIT_LOOSE_PC = '100'
PRODUCT_ORDER_UNIT_LOOSE_KG = '120'
PRODUCT_ORDER_UNIT_LOOSE_PC_KG = '140'
PRODUCT_ORDER_UNIT_LOOSE_LT = '150'
PRODUCT_ORDER_UNIT_LOOSE_BT_LT = '160'
PRODUCT_ORDER_UNIT_NAMED_PC = '200'
PRODUCT_ORDER_UNIT_NAMED_KG = '220'
PRODUCT_ORDER_UNIT_NAMED_PC_KG = '240'
......@@ -55,78 +68,73 @@ PRODUCT_ORDER_UNIT_SUBSCRIPTION = '400'
PRODUCT_ORDER_UNIT_TRANSPORTATION = '500'
LUT_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_LOOSE_PC, unicode(_("/piece (loose)"))),
(PRODUCT_ORDER_UNIT_LOOSE_KG, unicode(_("/Kg (loose)"))),
(PRODUCT_ORDER_UNIT_LOOSE_PC_KG, unicode(_("/piece -> Kg (loose)"))),
(PRODUCT_ORDER_UNIT_NAMED_PC, unicode(_("/piece (named)"))),
(PRODUCT_ORDER_UNIT_NAMED_KG, unicode(_("/Kg (named)"))),
(PRODUCT_ORDER_UNIT_NAMED_PC_KG, unicode(_("/piece -> Kg (named)"))),
(PRODUCT_ORDER_UNIT_DEPOSIT, unicode(_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.'))),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, unicode(_('As a subscription, common expense : add the minimal order quantity of this product to each customer of the group'))),
(PRODUCT_ORDER_UNIT_TRANSPORTATION, unicode(_('As a transportation cost : add the minimal order quantity of this product to the basket representing the group.'))),
(PRODUCT_ORDER_UNIT_LOOSE_PC, unicode(_("/piece (loose)"))),
(PRODUCT_ORDER_UNIT_NAMED_PC, unicode(_("/piece (named)"))),
(PRODUCT_ORDER_UNIT_LOOSE_KG, unicode(_("/Kg (loose)"))),
(PRODUCT_ORDER_UNIT_NAMED_KG, unicode(_("/Kg (named)"))),
(PRODUCT_ORDER_UNIT_LOOSE_PC_KG, unicode(_("/piece -> Kg (loose)"))),
(PRODUCT_ORDER_UNIT_NAMED_PC_KG, unicode(_("/piece -> Kg (named)"))),
(PRODUCT_ORDER_UNIT_LOOSE_LT, unicode(_("/L (loose)"))),
(PRODUCT_ORDER_UNIT_LOOSE_BT_LT, unicode(_("/piece -> L (loose)"))),
(PRODUCT_ORDER_UNIT_DEPOSIT, unicode(
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.'))),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, unicode(_(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group'))),
(PRODUCT_ORDER_UNIT_TRANSPORTATION, unicode(_(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.'))),
)
LUT_PRODUCT_ORDER_UNIT_REVERSE = (
(unicode(_("/piece (loose)")), PRODUCT_ORDER_UNIT_LOOSE_PC),
(unicode(_("/Kg (loose)")), PRODUCT_ORDER_UNIT_LOOSE_KG),
(unicode(_("/piece -> Kg (loose)")), PRODUCT_ORDER_UNIT_LOOSE_PC_KG),
(unicode(_("/piece (named)")), PRODUCT_ORDER_UNIT_NAMED_PC),
(unicode(_("/Kg (named)")), PRODUCT_ORDER_UNIT_NAMED_KG),
(unicode(_("/piece -> Kg (named)")), PRODUCT_ORDER_UNIT_NAMED_PC_KG),
(unicode(_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')), PRODUCT_ORDER_UNIT_DEPOSIT),
(unicode(_('As a subscription, common expense : add the minimal order quantity of this product to each customer of the group')), PRODUCT_ORDER_UNIT_SUBSCRIPTION),
(unicode(_('As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')), PRODUCT_ORDER_UNIT_TRANSPORTATION),
)
# zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
ADD_PRODUCT_MANUALY = '100'
ADD_PRODUCT_TO_CUSTOMER_BASKET_0 = '200'
ADD_PRODUCT_TO_CUSTOMER_BASKET = '300'
ADD_PRODUCT_TO_GROUP_BASKET = '400'
LUT_ADD_PRODUCT = (
(ADD_PRODUCT_MANUALY, _("As usual, let customers freely order it.")),
(ADD_PRODUCT_TO_CUSTOMER_BASKET_0, _('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
(ADD_PRODUCT_TO_CUSTOMER_BASKET, _('As a subscription, common expense : add the minimal order quantity of this product to each customer of the group')),
(ADD_PRODUCT_TO_GROUP_BASKET, _('As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
(unicode(_("/piece (loose)")), PRODUCT_ORDER_UNIT_LOOSE_PC),
(unicode(_("/Kg (loose)")), PRODUCT_ORDER_UNIT_LOOSE_KG),
(unicode(_("/piece -> Kg (loose)")), PRODUCT_ORDER_UNIT_LOOSE_PC_KG),
(unicode(_("/piece -> L (loose)")), PRODUCT_ORDER_UNIT_LOOSE_BT_LT),
(unicode(_("/piece (named)")), PRODUCT_ORDER_UNIT_NAMED_PC),
(unicode(_("/Kg (named)")), PRODUCT_ORDER_UNIT_NAMED_KG),
(unicode(_("/L (loose)")), PRODUCT_ORDER_UNIT_LOOSE_LT),
(unicode(_("/piece -> Kg (named)")), PRODUCT_ORDER_UNIT_NAMED_PC_KG),
(unicode(
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
PRODUCT_ORDER_UNIT_DEPOSIT),
(unicode(_(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group')),
PRODUCT_ORDER_UNIT_SUBSCRIPTION),
(unicode(_(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
PRODUCT_ORDER_UNIT_TRANSPORTATION),
)
# zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
VAT_100 = '100'
VAT_200 = '200'
VAT_200 = '200'
VAT_300 = '300'
VAT_400 = '400'
VAT_500 = '500'
VAT_600 = '600'
LUT_VAT = (
(VAT_100, unicode(_('none'))),
(VAT_200, unicode(_('compensation 2%'))),
(VAT_300, unicode(_('compensation 6%'))),
(VAT_400, unicode(_('vat 6%'))),
(VAT_500, unicode(_('vat 12%'))),
(VAT_600, unicode(_('vat 21%'))),
(VAT_100, unicode(_('none'))),
(VAT_200, unicode(_('compensation 2%'))),
(VAT_300, unicode(_('compensation 6%'))),
(VAT_400, unicode(_('vat 6%'))),
(VAT_500, unicode(_('vat 12%'))),
(VAT_600, unicode(_('vat 21%'))),
)
LUT_VAT_REVERSE = (
( unicode(_('none')), VAT_100),
( unicode(_('compensation 2%')), VAT_200),
( unicode(_('compensation 6%')), VAT_300),
( unicode(_('vat 6%')), VAT_400),
( unicode(_('vat 12%')), VAT_500),
( unicode(_('vat 21%')), VAT_600),
( unicode(_('none')), VAT_100),
( unicode(_('compensation 2%')), VAT_200),
( unicode(_('compensation 6%')), VAT_300),
( unicode(_('vat 6%')), VAT_400),
( unicode(_('vat 12%')), VAT_500),
( unicode(_('vat 21%')), VAT_600),
)
BANK_NOT_LATEST_TOTAL = '100'
# BANK_CALCULTAING_LATEST_TOTAL = '200'
BANK_NEXT_LATEST_TOTAL = '300'
BANK_LATEST_TOTAL = '400'
# update repanier_bankaccount set operation_status = '200' where operation_status = '400';
LUT_BANK_TOTAL = (
(BANK_NOT_LATEST_TOTAL, unicode(_('This is not the latest total'))),
# (BANK_CALCULTAING_LATEST_TOTAL, unicode(_('This is the previous latest total. The system is calculating the new one.'))),
(BANK_NEXT_LATEST_TOTAL, unicode(_('This is the next lastest bank total'))),
(BANK_LATEST_TOTAL, unicode(_('This is the lastest bank total'))),
(BANK_NOT_LATEST_TOTAL, unicode(_('This is not the latest total'))),
(BANK_NEXT_LATEST_TOTAL, unicode(_('This is the next lastest bank total'))),
(BANK_LATEST_TOTAL, unicode(_('This is the lastest bank total'))),
)
\ No newline at end of file
# -*- coding: utf-8 -*-
from repanier.const import *
from django.conf import settings
from django.core.mail import send_mail
from django.utils.translation import ugettext_lazy as _
def send(permanence, current_site_name):
try:
send_mail('Alert - ' + " - " + unicode(permanence) + " - " + current_site_name, permanence.get_status_display(),
settings.ALLOWED_HOSTS[0] + '@repanier.be', [v for k, v in settings.ADMINS])
except:
pass
# subject, from_email, to = 'Order Confirmation', 'admin@yourdomain.com', 'someone@somewhere.com'
# html_content = render_to_string('the_template.html', {'varname':'value'}) # ...
# <div style="display: none"><a onclick="javascript:pageTracker._trackPageview('/outgoing/wikiexback.com/');" href="http://wikiexback.com/" title="how to get your ex back">how to get your ex back</a></div>
# text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.
# # create the email, and attach the HTML version as well.
# msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
# msg.attach_alternative(html_content, "text/html")
# msg.send()
# -*- coding: utf-8 -*-
from repanier.const import *
from django.conf import settings
from django.core import urlresolvers
from django.core.mail import EmailMultiAlternatives
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 Customer
from repanier.models import Permanence
from repanier.models import Producer
from repanier.models import Staff
from repanier.tools import *
from repanier.xslx import xslx_invoice
def send(permanence_id, current_site_name):
permanence = Permanence.objects.get(id=permanence_id)
sender_email = settings.DEFAULT_FROM_EMAIL
sender_function = ""
signature = ""
cc_email_staff = []
staff_composition = ""
first_staff = True
for staff in Staff.objects.filter(is_active=True, is_external_group=False):
cc_email_staff.append(staff.user.email)
if staff.is_reply_to_invoice_email:
sender_email = staff.user.username + '@repanier.be'
sender_function = staff.long_name
r = staff.customer_responsible
if r:
if r.long_basket_name:
signature = r.long_basket_name + " - " + r.phone1
else:
signature = r.short_basket_name + " - " + r.phone1
if r.phone2:
signature += " / " + r.phone2
# To the producer we speak of "payment".
# This is the detail of the paiment to the producer, i.e. received products
filename = (unicode(_("Payment")) + u" - " + permanence.__unicode__() + u'.xlsx').encode('ascii',
errors='replace').replace(
'?', '_')
producer_set = Producer.objects.filter(
permanence=permanence_id).order_by()
for producer in producer_set:
if producer.email.upper().find("NO-SPAM.WS") < 0:
long_profile_name = producer.long_profile_name if producer.long_profile_name != None else producer.short_profile_name
wb = xslx_invoice.export(permanence=permanence, producer=producer, wb=None, sheet_name=long_profile_name)
if wb != None:
invoices_url = 'http://' + settings.ALLOWED_HOSTS[0] + urlresolvers.reverse(
'invoicep_uuid_view',
args=(0, producer.uuid )
)
html_content = unicode(_('Dear')) + " " + long_profile_name + ",<br/><br/>" + unicode(
_('In attachment, you will find the detail of our payment for the')) + \
' <a href="' + invoices_url + '">' + unicode(permanence) + \
"</a>.<br/><br/>" + unicode(
_('In case of discordance, please advertise the staff team :')) + \
"<br/><br/>" + signature + \
"<br/>" + sender_function + \
"<br/>" + current_site_name
email = EmailMultiAlternatives(
unicode(_('Payment')) + " - " + unicode(
permanence) + " - " + current_site_name + " - " + long_profile_name,
strip_tags(html_content),
sender_email,
[producer.email],
cc=[sender_email]
)
email.attach(filename,
save_virtual_workbook(wb),
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
email.attach_alternative(html_content, "text/html")
if not settings.DEBUG: