Commit fc80caa9 authored by Patrick's avatar Patrick

Update to djangocms-admin-style==1.2.6.2

parent d69d10c1
......@@ -150,7 +150,7 @@ class BoxAdmin(TranslatableAdmin):
model = Box
list_display = (
'is_into_offer', 'get_long_name', 'all_languages_column',
'is_into_offer', 'get_long_name', 'language_column',
)
list_display_links = ('get_long_name',)
list_per_page = 16
......
......@@ -54,7 +54,7 @@ class ConfigurationAdmin(TranslatableAdmin):
'display_anonymous_order_form',
('display_producer_on_order_form', 'max_week_wo_participation'),
'customers_must_confirm_orders',
('bank_account', 'vat_id'),
'bank_account',
('membership_fee', 'membership_fee_duration')),
}),
]
......@@ -64,7 +64,7 @@ class ConfigurationAdmin(TranslatableAdmin):
'classes': ('collapse',),
'fields' :
(
'offer_producer_mail_subject', 'offer_producer_mail',
'offer_producer_mail',
),
}),
]
......@@ -73,25 +73,25 @@ class ConfigurationAdmin(TranslatableAdmin):
'classes': ('collapse',),
'fields' :
(
'send_opening_mail_to_customer', 'offer_customer_mail_subject', 'offer_customer_mail',
'send_opening_mail_to_customer', 'offer_customer_mail',
),
}),
(_('Ordering mails'), {
'classes': ('collapse',),
'fields' :
(
'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',
'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',
),
}),
(_('Invoicing mails'), {
'classes': ('collapse',),
'fields' :
(
'send_invoice_mail_to_customer', 'invoice_customer_mail_subject', 'invoice_customer_mail',
'send_invoice_mail_to_producer', 'invoice_producer_mail_subject', 'invoice_producer_mail',
'send_invoice_mail_to_customer', 'invoice_customer_mail',
'send_invoice_mail_to_producer', 'invoice_producer_mail',
),
}),
(_('Advanced options'), {
......@@ -99,13 +99,13 @@ class ConfigurationAdmin(TranslatableAdmin):
'fields' :
(
'home_site',
'transport',
'min_transport',
('transport', 'min_transport'),
'group_label',
'page_break_on_customer_check',
'close_wo_sending',
'sms_gateway_mail',
('currency', 'invoice',),
'invoice',
('currency', 'vat_id'),
),
}),
]
......
......@@ -4,7 +4,6 @@ from __future__ import unicode_literals
import uuid
from collections import OrderedDict
from os import sep as os_sep
from re import compile
from decimal import Decimal
from django import forms
......
......@@ -78,10 +78,10 @@ class ProducerInvoicedForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ProducerInvoicedForm, self).__init__(*args, **kwargs)
self.fields["to_be_invoiced_balance"].widget.attrs['style'] = "width:100px"
self.fields["invoice_reference"].widget.attrs['style'] = "width:300px"
self.fields["to_be_invoiced_balance"].widget.attrs['style'] = "width:100px !important"
self.fields["invoice_reference"].widget.attrs['style'] = "width:250px !important"
self.fields["calculated_invoiced_balance"].widget.attrs['readonly'] = True
self.fields["calculated_invoiced_balance"].widget.attrs['style'] = "width:100px"
# self.fields["calculated_invoiced_balance"].widget.attrs['style'] = "width:100px"
ProducerInvoicedFormSet = formset_factory(ProducerInvoicedForm, extra=0)
......@@ -119,8 +119,8 @@ class LUTDeliveryPointAdmin(LUTAdmin):
def get_fields(self, request, obj=None):
if obj is None:
return ['parent', 'is_active', 'short_name', 'description', 'customer_responsible', 'price_list_multiplier', 'transport', 'min_transport']
return ['parent', 'is_active', 'short_name', 'description', 'customer_responsible', 'price_list_multiplier', 'transport', 'min_transport', 'customers']
return [('parent',), 'is_active', 'short_name', 'description', 'customer_responsible', 'price_list_multiplier', 'transport', 'min_transport']
return [('parent',), 'is_active', 'short_name', 'description', 'customer_responsible', 'price_list_multiplier', 'transport', 'min_transport', 'customers']
class LUTDepartmentForCustomerAdmin(LUTAdmin):
......
......@@ -13,9 +13,9 @@ from django.http import HttpResponseRedirect
from django.template import Context as TemplateContext, Template
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from parler.admin import TranslatableAdmin, TranslatableTabularInline
from parler.forms import TranslatableModelForm
from parler.models import TranslationDoesNotExist
from parler.utils.context import switch_language
......@@ -25,7 +25,7 @@ from repanier.admin.forms import OpenAndSendOfferForm, CloseAndSendOrderForm, Ge
from repanier.const import *
from repanier.fields.RepanierMoneyField import RepanierMoney
from repanier.models import Customer, Purchase, Producer, PermanenceBoard, LUT_PermanenceRole, PermanenceInPreparation, \
Box, OfferItem, DeliveryBoard, LUT_DeliveryPoint, ProducerInvoice, Product
Box, OfferItem, DeliveryBoard, LUT_DeliveryPoint, ProducerInvoice, Product, Configuration
from repanier.task import task_order, task_purchase
from repanier.tools import send_email_to_who, get_signature, get_board_composition
from repanier.xlsx import xlsx_offer, xlsx_order
......@@ -94,7 +94,30 @@ class DeliveryBoardInline(ForeignKeyCacheMixin, TranslatableTabularInline):
return super(DeliveryBoardInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
class PermanenceInPreparationForm(TranslatableModelForm):
def __init__(self, *args, **kwargs):
super(PermanenceInPreparationForm, self).__init__(*args, **kwargs)
# if self.instance.id is None:
# config = Configuration.objects.language(self.language_code).get(id=DECIMAL_ONE)
# self.fields["offer_customer_mail_subject"].initial = config.offer_customer_mail_subject
# else:
# try:
# check_if_translation_exists = self.instance.offer_customer_mail_subject
# print('------------------ check_if_translation_exists')
# print('<%s>' % check_if_translation_exists)
# except TranslationDoesNotExist:
# The translation doesn't exists
# config = Configuration.objects.language(self.language_code).get(id=DECIMAL_ONE)
# self.fields["offer_customer_mail_subject"].initial = config.offer_customer_mail_subject
class Meta:
model = PermanenceInPreparation
fields = "__all__"
class PermanenceInPreparationAdmin(TranslatableAdmin):
form = PermanenceInPreparationForm
exclude = ['invoice_description']
list_per_page = 10
list_max_show_all = 10
......@@ -102,7 +125,8 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
inlines = [DeliveryBoardInline, PermanenceBoardInline]
date_hierarchy = 'permanence_date'
list_display = (
'__str__', 'all_languages_column', 'get_producers', 'get_customers', 'get_board', 'get_full_status_display')
'__str__', 'language_column', 'get_producers', 'get_customers', 'get_board', 'get_full_status_display'
)
ordering = ('permanence_date',)
if settings.DJANGO_SETTINGS_ENV == "dev":
actions = [
......@@ -147,12 +171,14 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
def get_fields(self, request, permanence=None):
fields = [
('permanence_date', 'short_name',),
'permanence_date',
'automatically_closed',
'short_name',
'offer_description',
'producers',
'get_boxes'
'producers'
]
if self.get_boxes():
fields.append('get_boxes')
return fields
def get_readonly_fields(self, request, permanence=None):
......@@ -161,8 +187,8 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
return ['status', 'producers', 'get_boxes']
return ['status', 'get_boxes']
def get_boxes(self, obj=None):
if obj is None or obj.status == PERMANENCE_PLANNED:
def get_boxes(self, permanence=None):
if permanence is None or permanence.status == PERMANENCE_PLANNED:
qs = Box.objects.filter(
is_box=True,
is_into_offer=True,
......@@ -175,7 +201,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
result = ", ".join(o.long_name for o in qs)
else:
qs = OfferItem.objects.filter(
permanence_id=obj.id,
permanence_id=permanence.id,
is_box=True,
may_order=True,
translations__language_code=translation.get_language()
......@@ -183,7 +209,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
"translations__preparation_sort_order"
)
result = ", ".join(o.long_name for o in qs)
return result if result is not None else _("None")
return result if result is not None else EMPTY_STRING
get_boxes.short_description = _("boxes")
......
......@@ -359,22 +359,22 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin):
if producer is not None:
if producer.producer_pre_opening:
self.list_editable = ('producer_unit_price', 'stock')
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'all_languages_column',
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'language_column',
'producer_unit_price',
'stock')
elif producer.manage_replenishment or producer.manage_production:
self.list_editable = ('producer_unit_price', 'stock')
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'all_languages_column',
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'language_column',
'producer_unit_price',
'get_customer_alert_order_quantity', 'stock')
else:
self.list_editable = ('producer_unit_price',)
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'all_languages_column',
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'language_column',
'producer_unit_price',
'get_customer_alert_order_quantity')
else:
self.list_editable = ('producer_unit_price', 'stock')
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'all_languages_column',
return ('is_into_offer', 'producer', 'department_for_customer', 'get_long_name', 'language_column',
'producer_unit_price',
'get_customer_alert_order_quantity', 'stock')
......
......@@ -221,7 +221,7 @@ class OfferItemSendAdmin(admin.ModelAdmin):
self.fields = (
('permanence', 'department_for_customer', 'product', 'get_vat_level',),
prices,
('stock', 'qty_prepared', 'qty_delivered', 'offer_purchase_price')
('stock', 'qty_delivered', 'qty_prepared', 'offer_purchase_price')
)
else:
if not obj.wrapped and obj.order_unit in [PRODUCT_ORDER_UNIT_KG, PRODUCT_ORDER_UNIT_PC_KG]:
......
......@@ -115,7 +115,7 @@ class StaffWithUserDataAdmin(TranslatableAdmin):
'is_coordinator', 'is_contributor', 'is_webmaster',
'customer_responsible', 'long_name', 'function_description',
'is_active']
list_display = ('user', 'all_languages_column', 'long_name', 'customer_responsible', 'get_customer_phone1')
list_display = ('user', 'language_column', 'long_name', 'customer_responsible', 'get_customer_phone1')
list_filter = ('is_active',)
list_select_related = ('customer_responsible',)
list_per_page = 16
......
......@@ -4,6 +4,7 @@ from __future__ import unicode_literals
import re
from django import forms
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import Permission
from django.contrib.auth.models import User
from django.db.models import F, Q
from django.utils import translation
......@@ -128,3 +129,12 @@ class RepanierCustomBackend(ModelBackend):
self.user = user_or_none
return user_or_none
def has_perm(self, user_obj, perm, obj=None):
if perm.startswith('dummy_cmsplugin_cascade'):
codename = perm.split('.', 1)[1]
if not Permission.objects.filter(codename=codename).exists():
perm_splitted = codename.split('_', 1)
codename = '%s_bootstrapcontainerpluginmodel' % perm_splitted[0]
perm = 'cmsplugin_cascade.%s' % codename
return super(RepanierCustomBackend, self).has_perm(user_obj, perm, obj)
......@@ -42,13 +42,9 @@ 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
# invoice_producer_mail_subject = "%s - %s - %s - %s" % (
# _('Payment'), permanence, REPANIER_SETTINGS_GROUP_NAME, long_profile_name)
invoice_producer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
template = Template(invoice_producer_mail)
context = TemplateContext({
......@@ -102,13 +98,9 @@ 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
# invoice_customer_mail_subject = "%s - %s - %s - %s" % (_('Invoice'), permanence, REPANIER_SETTINGS_GROUP_NAME,
# long_basket_name)
invoice_customer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
customer_last_balance, customer_on_hold_movement, customer_payment_needed, customer_order_amount = payment_message(
customer, permanence)
template = Template(invoice_customer_mail)
......
......@@ -35,12 +35,9 @@ 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
# offer_producer_mail_subject = "%s - %s - %s" % (_("Pre-opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME)
offer_producer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
template = Template(offer_producer_mail)
producer_set = Producer.objects.filter(
permanence=permanence_id, producer_pre_opening=True,
......@@ -116,12 +113,8 @@ 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_customer_mail_subject = "%s - %s - %s" % (_("Opening of orders"), permanence, REPANIER_SETTINGS_GROUP_NAME)
offer_customer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
offer_producer = ', '.join([p.short_profile_name for p in permanence.producers.all()])
qs = OfferItem.objects.filter(
permanence_id=permanence_id, is_active=True,
......
......@@ -75,13 +75,9 @@ 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
# order_staff_mail_subject = "%s - %s - %s" % (
# _('Permanence preparation list'), permanence, REPANIER_SETTINGS_GROUP_NAME)
order_staff_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
template = Template(order_staff_mail)
context = TemplateContext({
......@@ -140,13 +136,9 @@ 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
# order_producer_mail_subject = "%s - %s - %s" % (
# _('Permanence preparation list'), permanence, REPANIER_SETTINGS_GROUP_NAME)
order_producer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
template = Template(order_producer_mail)
context = TemplateContext({
......@@ -275,25 +267,17 @@ 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
order_customer_mail_subject = "%s - %s - %s" % (
_('/!\ Order cancelled'), REPANIER_SETTINGS_GROUP_NAME, permanence)
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
# order_customer_mail_subject = "%s - %s - %s" % (
# _('Order'), REPANIER_SETTINGS_GROUP_NAME, permanence)
order_customer_mail_subject = "%s - %s" % (REPANIER_SETTINGS_GROUP_NAME, permanence)
template = Template(order_customer_mail)
context = TemplateContext({
'name' : long_basket_name,
......
......@@ -251,9 +251,9 @@ class MoneyInput(NumberInput):
# Only add the 'value' attribute if a value is non-empty.
final_attrs['value'] = force_text(self._format_value(value))
if repanier.apps.REPANIER_SETTINGS_AFTER_AMOUNT:
return format_html('<input{} />{}', flatatt(final_attrs), repanier.apps.REPANIER_SETTINGS_CURRENCY_DISPLAY)
return format_html('<input{} />&nbsp;{}', flatatt(final_attrs), repanier.apps.REPANIER_SETTINGS_CURRENCY_DISPLAY)
else:
return format_html('{}<input{} />', repanier.apps.REPANIER_SETTINGS_CURRENCY_DISPLAY, flatatt(final_attrs))
return format_html('{}&nbsp;<input{} />', repanier.apps.REPANIER_SETTINGS_CURRENCY_DISPLAY, flatatt(final_attrs))
class FormMoneyField(DecimalField):
......
......@@ -100,10 +100,6 @@ class Configuration(TranslatableModel):
max_length=100,
default=EMPTY_STRING,
blank=True),
offer_customer_mail_subject=models.CharField(_("offer customer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
offer_customer_mail=HTMLField(_("offer customer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -121,10 +117,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
offer_producer_mail_subject=models.CharField(_("offer producer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
offer_producer_mail=HTMLField(_("offer producer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -140,10 +132,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
order_customer_mail_subject=models.CharField(_("order customer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
order_customer_mail=HTMLField(_("order customer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -162,10 +150,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
cancel_order_customer_mail_subject=models.CharField(_("cancelled order customer object"),
max_length=100,
default=EMPTY_STRING,
blank=True),
cancel_order_customer_mail=HTMLField(_("cancelled order customer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -178,10 +162,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
order_staff_mail_subject=models.CharField(_("order staff mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
order_staff_mail=HTMLField(_("order staff mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -199,10 +179,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
order_producer_mail_subject=models.CharField(_("order producer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
order_producer_mail=HTMLField(_("order producer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -216,10 +192,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
invoice_customer_mail_subject=models.CharField(_("invoice customer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
invoice_customer_mail=HTMLField(_("invoice customer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......@@ -239,10 +211,6 @@ class Configuration(TranslatableModel):
{{ signature }}
""",
blank=False),
invoice_producer_mail_subject=models.CharField(_("invoice producer mail subject"),
max_length=100,
default=EMPTY_STRING,
blank=True),
invoice_producer_mail=HTMLField(_("invoice producer mail"),
help_text=EMPTY_STRING,
configuration='CKEDITOR_SETTINGS_MODEL2',
......
......@@ -169,15 +169,15 @@ class Customer(models.Model):
if last_customer_invoice.exists():
if balance.amount >= 30:
return '<a href="' + urlresolvers.reverse('customer_invoice_view', args=(0,)) + '?customer=' + str(
self.id) + '" target="_blank" >' + (
self.id) + '" >' + (
'<span style="color:#32CD32">%s</span>' % (balance,)) + '</a>'
elif balance.amount >= -10:
return '<a href="' + urlresolvers.reverse('customer_invoice_view', args=(0,)) + '?customer=' + str(
self.id) + '" target="_blank" >' + (
self.id) + '" >' + (
'<span style="color:#696969">%s</span>' % (balance,)) + '</a>'
else:
return '<a href="' + urlresolvers.reverse('customer_invoice_view', args=(0,)) + '?customer=' + str(
self.id) + '" target="_blank" >' + (
self.id) + '" >' + (
'<span style="color:#FF0000">%s</span>' % (balance,)) + '</a>'
else:
if balance.amount >= 30:
......
......@@ -6,7 +6,10 @@ from django.core import urlresolvers
from django.core.cache import cache
from django.db import models
from django.db.models import F
from django.db.models.signals import post_init
from django.dispatch import receiver
from django.utils import timezone
from django.utils import translation
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from djangocms_text_ckeditor.fields import HTMLField
......@@ -78,11 +81,11 @@ class Permanence(TranslatableModel):
link = []
for p in self.producers.all():
link.append(
'<a href=%s?producer=%d target="_blank" class="addlink">&nbsp;%s</a>' % (
'<a href=%s?producer=%d>&nbsp;%s</a>' % (
changelist_url, p.id, p.short_profile_name))
return ", ".join(link)
return '<div class="wrap-text">%s</div>' % ", ".join(link)
elif self.status == PERMANENCE_PRE_OPEN:
return ", ".join([p.short_profile_name + " (" + p.phone1 + ")" for p in self.producers.all()])
return '<div class="wrap-text">%s</div>' % ", ".join([p.short_profile_name + " (" + p.phone1 + ")" for p in self.producers.all()])
elif self.status in [PERMANENCE_OPENED, PERMANENCE_CLOSED]:
close_offeritem_changelist_url = urlresolvers.reverse(
'admin:repanier_offeritemclosed_changelist',
......@@ -116,9 +119,9 @@ class Permanence(TranslatableModel):
label = ('%s ' % (p.short_profile_name,)).replace(' ', '&nbsp;')
offeritem_changelist_url = close_offeritem_changelist_url
link.append(
'<a href="%s?permanence=%s&producer=%d" target="_blank" class="addlink">%s</a>' % (
'<a href="%s?permanence=%s&producer=%d">%s</a>' % (
offeritem_changelist_url, self.id, p.id, label))
return ", ".join(link)
return '<div class="wrap-text">%s</div>' % ", ".join(link)
elif self.status == PERMANENCE_SEND:
send_offeritem_changelist_url = urlresolvers.reverse(
'admin:repanier_offeritemsend_changelist',
......@@ -137,16 +140,16 @@ class Permanence(TranslatableModel):
if pi is not None:
label = '%s (%s) %s' % (p.short_profile_name, pi.get_total_price_with_tax(), LOCK_UNICODE)
link.append(
'<a href="%s?permanence=%d&producer=%d" target="_blank" class="addlink">&nbsp;%s</a>' % (
'<a href="%s?permanence=%d&producer=%d">&nbsp;%s</a>' % (
changelist_url, self.id, p.id, label.replace(' ', '&nbsp;')
))
else:
link.append(
'<a href="%s?permanence=%d&producer=%d" target="_blank" class="addlink">&nbsp;%s</a>' % (
'<a href="%s?permanence=%d&producer=%d">&nbsp;%s</a>' % (
changelist_url, self.id, p.id, p.short_profile_name.replace(' ', '&nbsp;')
))
return ", ".join(link)
return '<div class="wrap-text">%s</div>' % ", ".join(link)
elif self.status in [PERMANENCE_DONE, PERMANENCE_ARCHIVED]:
link = []
for pi in invoice.ProducerInvoice.objects.filter(permanence_id=self.id).select_related(
......@@ -157,15 +160,15 @@ class Permanence(TranslatableModel):
pi.get_to_be_paid_display()
)
link.append(
'<a href="%s?producer=%d" target="_blank"%s>%s</a>'
'<a href="%s?producer=%d" target="_blank" %s>%s</a>'
% (
urlresolvers.reverse('producer_invoice_view', args=(pi.id,)),
pi.producer_id,
EMPTY_STRING if not pi.to_be_paid else ' class="addlink"',
EMPTY_STRING if not pi.to_be_paid else '',
label.replace(' ', '&nbsp;')))
producers = ", ".join(link)
msg_html = """
<button
<div class="wrap-text"><button
onclick="django.jQuery('#id_get_producers_%d').toggle();
if(django.jQuery(this).html()=='%s'){
django.jQuery(this).html('%s')
......@@ -174,7 +177,7 @@ class Permanence(TranslatableModel):
};
return false;"
>%s</button>
<div id="id_get_producers_%d" style="display:none;">%s</div>
<div id="id_get_producers_%d" style="display:none;">%s</div></div>
""" % (
self.id, _("Show"), _("Hide"), _("Show"), _("Show"), self.id, producers
)
......@@ -186,7 +189,7 @@ class Permanence(TranslatableModel):
producerinvoice__permanence_id=self.id).only(
'short_profile_name')])
else:
return _("No offer")
return '<div class="wrap-text">%s</div>' % _("No offer")
return "?"
get_producers.short_description = (_("producers in this permanence"))
......@@ -212,7 +215,7 @@ class Permanence(TranslatableModel):
ci.customer.short_basket_name, ci.total_price_with_tax,
ci.get_is_order_confirm_send_display())
link.append(
'<a href="%s?permanence=%d&customer=%d" target="_blank" class="addlink">%s</a>'
'<a href="%s?permanence=%d&customer=%d" target="_blank">%s</a>'
% (changelist_url, self.id, ci.customer_id, label.replace(' ', '&nbsp;')))
customers = ", ".join(link)
elif self.status == PERMANENCE_DONE:
......@@ -225,7 +228,7 @@ class Permanence(TranslatableModel):
ci.get_is_order_confirm_send_display()
)
link.append(
'<a href="%s?customer=%d" target="_blank" >%s</a>'
'<a href="%s?customer=%d" target="_blank">%s</a>'
% (
urlresolvers.reverse('customer_invoice_view', args=(ci.id,)),
ci.customer_id,
......@@ -240,7 +243,7 @@ class Permanence(TranslatableModel):
'short_basket_name')])
if len(customers) > 0:
msg_html = """
<button
<div class="wrap-text"><button
onclick="django.jQuery('#id_get_customers_%d').toggle();
if(django.jQuery(this).html()=='%s'){
django.jQuery(this).html('%s')
......@@ -249,13 +252,13 @@ class Permanence(TranslatableModel):
};
return false;"
>%s</button>
<div id="id_get_customers_%d" style="display:none;">%s</div>
<div id="id_get_customers_%d" style="display:none;">%s</div></div>
""" % (
self.id, _("Show"), _("Hide"), _("Show"), _("Show"), self.id, customers
)
return msg_html
else:
return _("No purchase")
return '<div class="wrap-text">%s</div>' % _("No purchase")