Commit 6c47d07a authored by Patrick's avatar Patrick

Display a pop up and better use of colors when a confirmed order is upgraded

parent fbf3db27
This diff is collapsed.
......@@ -179,14 +179,14 @@ class Customer(models.Model):
else:
return '<a href="' + urlresolvers.reverse('customer_invoice_view', args=(0,)) + '?customer=' + str(
self.id) + '" target="_blank" >' + (
'<span style="color:#FF0000">%s</span>' % (balance,)) + '</a>'
'<span style="color:red">%s</span>' % (balance,)) + '</a>'
else:
if balance.amount >= 30:
return '<span style="color:#32CD32">%s</span>' % (balance,)
elif balance.amount >= -10:
return '<span style="color:#696969">%s</span>' % (balance,)
else:
return '<span style="color:#FF0000">%s</span>' % (balance,)
return '<span style="color:red">%s</span>' % (balance,)
get_balance.short_description = _("balance")
get_balance.allow_tags = True
......
......@@ -254,29 +254,40 @@ class CustomerInvoice(models.Model):
self.delta_transport.amount = DECIMAL_ZERO
def cancel_confirm_order(self):
self.is_order_confirm_send = False
producer_invoice_buyinggroup = ProducerInvoice.objects.filter(
producer__represent_this_buyinggroup=True,
permanence_id=self.permanence_id,
).order_by('?').first()
if producer_invoice_buyinggroup is None:
producer_buyinggroup = producer.Producer.objects.filter(
represent_this_buyinggroup=True
).order_by('?').first()
producer_invoice_buyinggroup = ProducerInvoice.objects.create(
producer_id=producer_buyinggroup.id,
if self.delta_price_with_tax.amount != DECIMAL_ZERO \
or self.delta_vat.amount != DECIMAL_ZERO\
or self.delta_transport.amount != DECIMAL_ZERO:
producer_invoice_buyinggroup = ProducerInvoice.objects.filter(
producer__represent_this_buyinggroup=True,
permanence_id=self.permanence_id,
status=self.permanence.status
)
producer_invoice_buyinggroup.delta_price_with_tax.amount -= self.delta_price_with_tax.amount
producer_invoice_buyinggroup.delta_vat.amount -= self.delta_vat.amount
producer_invoice_buyinggroup.delta_transport.amount -= self.delta_transport.amount
producer_invoice_buyinggroup.save()
).order_by('?').first()
if producer_invoice_buyinggroup is None:
producer_buyinggroup = producer.Producer.objects.filter(
represent_this_buyinggroup=True
).order_by('?').first()
producer_invoice_buyinggroup = ProducerInvoice.objects.create(
producer_id=producer_buyinggroup.id,
permanence_id=self.permanence_id,
status=self.permanence.status
)
producer_invoice_buyinggroup.delta_price_with_tax.amount -= self.delta_price_with_tax.amount
producer_invoice_buyinggroup.delta_vat.amount -= self.delta_vat.amount
producer_invoice_buyinggroup.delta_transport.amount -= self.delta_transport.amount
producer_invoice_buyinggroup.save()
self.delta_price_with_tax.amount = DECIMAL_ZERO
self.delta_vat.amount = DECIMAL_ZERO
self.delta_transport = DECIMAL_ZERO
self.delta_price_with_tax.amount = DECIMAL_ZERO
self.delta_vat.amount = DECIMAL_ZERO
self.delta_transport = DECIMAL_ZERO
if self.is_order_confirm_send:
# Change of confirmation status
self.is_order_confirm_send = False
return True
else:
# No change of confirmation status
return False
def __str__(self):
return '%s, %s' % (self.customer, self.permanence)
......
......@@ -245,7 +245,7 @@ class Producer(models.Model):
elif balance.amount > 30:
return '<a href="' + urlresolvers.reverse('producer_invoice_view', args=(0,)) + '?producer=' + str(
self.id) + '" target="_blank" >' + (
'<span style="color:#FF0000">%s</span>' % (balance,)) + '</a>'
'<span style="color:red">%s</span>' % (balance,)) + '</a>'
else:
return '<a href="' + urlresolvers.reverse('producer_invoice_view', args=(0,)) + '?producer=' + str(
self.id) + '" target="_blank" >' + (
......@@ -256,7 +256,7 @@ class Producer(models.Model):
elif balance.amount == 0:
return '<span style="color:#32CD32">%s</span>' % (balance,)
elif balance.amount > 30:
return '<span style="color:#FF0000">%s</span>' % (balance,)
return '<span style="color:red">%s</span>' % (balance,)
else:
return '<span style="color:#696969">%s</span>' % (balance,)
......@@ -274,7 +274,7 @@ class Producer(models.Model):
return '<span style="color:#32CD32">%s</span>' % (
number_format(producer_last_invoice.total_price_with_tax, 2))
elif producer_last_invoice.total_price_with_tax > 30:
return '<span style="color:#FF0000">%s</span>' % (
return '<span style="color:red">%s</span>' % (
number_format(producer_last_invoice.total_price_with_tax, 2))
else:
return '<span style="color:#696969">%s</span>' % (
......
......@@ -91,7 +91,7 @@
{% if permanence %}
<li id="li_my_basket" style="display:none;" class="dropdown">
{% if delivery_id %}
<a href="{% url "basket_view" permanence.id delivery_id %}" class="btn btn-info"><span id="my_basket"></span></a>
<a href="{% url "basket_delivery_view" permanence.id delivery_id %}" class="btn btn-info"><span id="my_basket"></span></a>
{% else %}
<a href="{% url "basket_view" permanence.id %}" class="btn btn-info"><span id="my_basket"></span></a>
{% endif %}
......
......@@ -93,7 +93,7 @@
{% if permanence %}
<li id="li_my_basket" style="display:none;" class="dropdown">
{% if delivery_id %}
<a href="{% url "basket_view" permanence.id delivery_id %}" class="btn btn-info"><span id="my_basket"></span></a>
<a href="{% url "basket_delivery_view" permanence.id delivery_id %}" class="btn btn-info"><span id="my_basket"></span></a>
{% else %}
<a href="{% url "basket_view" permanence.id %}" class="btn btn-info"><span id="my_basket"></span></a>
{% endif %}
......
{% load i18n l10n %}
{% trans "Your order is no longer confirmed because you just changed it." %}
<br/>{% trans "Do not forget to confirm it again." %}
<br/><br/>{% trans "An unconfirmed order will be canceled." %}
<br/>{% trans "You can increase the order quantities as long as the orders are open." %}
This diff is collapsed.
......@@ -605,7 +605,7 @@ def payment_message(customer, permanence):
# other_order_not_invoiced = REPANIER_MONEY_ZERO
if customer_invoice.customer_id != customer_invoice.customer_who_pays_id:
customer_payment_needed = '<font color="green">%s</font>' % (
customer_payment_needed = '<font color="#51a351">%s</font>' % (
_('Invoices for this delivery point are sent to %(name)s who is responsible for collecting the payments.') % {
'name': customer_invoice.customer_who_pays.long_basket_name
}
......@@ -646,7 +646,7 @@ def payment_message(customer, permanence):
else:
if customer.balance.amount != DECIMAL_ZERO:
customer_payment_needed = '<br/><font color="green">%s.</font>' % (_('Your account balance is sufficient'))
customer_payment_needed = '<br/><font color="#51a351">%s.</font>' % (_('Your account balance is sufficient'))
else:
customer_payment_needed = EMPTY_STRING
else:
......@@ -1060,7 +1060,12 @@ def update_or_create_purchase(customer=None, offer_item_id=None, q_order=None, v
).only("id", "with_delivery_point", "status").order_by('?').first()
if customer_invoice is not None and permanence is not None:
order_amount = customer_invoice.get_total_price_with_tax()
customer_invoice.cancel_confirm_order()
status_changed = customer_invoice.cancel_confirm_order()
if apps.REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS and status_changed:
html = render_to_string(
'repanier/communication_confirm_order.html')
option_dict = {'id': "#communication", 'html': html}
to_json.append(option_dict)
customer_invoice.save()
my_basket(customer_invoice.is_order_confirm_send, order_amount, to_json)
if basket:
......@@ -1082,7 +1087,7 @@ def my_basket(is_order_confirm_send, order_amount, to_json):
msg_html = '<span class="glyphicon glyphicon-shopping-cart"></span> %s&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-exclamation-sign"></span>&nbsp;<span class="glyphicon glyphicon-floppy-remove"></span></a>' % (
order_amount,)
else:
msg_html = '<span class="glyphicon glyphicon-shopping-cart"></span> %s&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-floppy-saved"></span></a>' % (
msg_html = '<span class="glyphicon glyphicon-shopping-cart"></span> %s&nbsp;&nbsp;&nbsp;<font color="#32CD32"><span class="glyphicon glyphicon-floppy-saved"></span></font></a>' % (
order_amount,)
option_dict = {'id': "#my_basket", 'html': msg_html}
to_json.append(option_dict)
......@@ -1206,7 +1211,7 @@ def my_order_confirmation(permanence, customer_invoice, is_basket=False,
<div class="panel panel-default">
<div class="panel-heading">
%s
<p><font color="green">%s</font><p/>
<p><font color="#51a351">%s</font><p/>
%s
</div>
</div>
......
......@@ -71,10 +71,12 @@ urlpatterns = [
# url(r'^order/(?P<permanence_id>\d+)/(?P<delivery_id>\d+)/$', OrderView.as_view(), name='order_view'),
# url(r'^order/(?P<permanence_id>\d+)/$', OrderView.as_view(), {'delivery_id': 0}, name='order_view'),
url(r'^order/(?P<permanence_id>\d+)/(?P<delivery_id>\d+)/$', never_cache(OrderView.as_view()), name='order_view'),
url(r'^order/(?P<permanence_id>\d+)/$', never_cache(OrderView.as_view()), {'delivery_id': 0}, name='order_view'),
url(r'^order/(?P<permanence_id>\d+)/(?P<delivery_id>\d+)/$', never_cache(OrderView.as_view()),
name='order_delivery_view'),
url(r'^order/(?P<permanence_id>\d+)/$', never_cache(OrderView.as_view()), {'delivery_id': 0},
name='order_view'),
url(r'^basket/(?P<permanence_id>\d+)/(?P<delivery_id>\d+)/$', never_cache(OrderView.as_view()), {'basket': True},
name='basket_view'),
name='basket_delivery_view'),
url(r'^basket/(?P<permanence_id>\d+)/$', never_cache(OrderView.as_view()), {'delivery_id': 0, 'basket': True},
name='basket_view'),
url(r'^like/(?P<permanence_id>\d+)/(?P<delivery_id>\d+)/$', never_cache(OrderView.as_view()), {'like': True},
......
......@@ -160,7 +160,7 @@ def order_init_ajax(request):
else:
count_activity = None
html = render_to_string(
'repanier/communication.html',
'repanier/communication_permanence_board.html',
{'permanence_boards': permanence_boards, 'count_activity': count_activity})
option_dict = {'id': "#communication", 'html': html}
to_json.append(option_dict)
......
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