Commit 4021606f authored by Patrick's avatar Patrick

Don't use cms_menus for user menu and put it on right side of the navbar

parent 422696fb
......@@ -90,64 +90,64 @@ class PermanenceMenu(Menu):
if max_counter <= 0:
break
if REPANIER_SETTINGS_INVOICE and not request.user.is_staff:
if separator:
submenu_id = self.append_separator(nodes, master_id, submenu_id)
submenu_id += 1
node = NavigationNode(
'<span id="my_balance">%s</span>' % _('My balance'),
reverse('customer_invoice_view', args=(0,)),
id=submenu_id, parent_id=master_id,
visible=True
)
nodes.append(node)
# if REPANIER_SETTINGS_INVOICE and not request.user.is_staff:
# if separator:
# submenu_id = self.append_separator(nodes, master_id, submenu_id)
# submenu_id += 1
# node = NavigationNode(
# '<span id="my_balance">%s</span>' % _('My balance'),
# reverse('customer_invoice_view', args=(0,)),
# id=submenu_id, parent_id=master_id,
# visible=True
# )
# nodes.append(node)
# for node in nodes:
# logging.debug('Node before : %s' % node.get_menu_title())
# for attr in (x for x in dir(node) if not x.startswith('__')):
# logging.debug('%s => %s' % (attr, getattr(node, attr)))
master_id = 3
node = NavigationNode(
"%s" % _('Group'),
"/",
id=master_id,
visible=True
)
nodes.append(node)
submenu_id = master_id + 1
node = NavigationNode(
_('Send mail to coordinators'),
reverse('send_mail_to_coordinators_view'),
id=submenu_id, parent_id=master_id,
visible=True
)
nodes.append(node)
submenu_id += 1
if REPANIER_SETTINGS_DISPLAY_WHO_IS_WHO:
node = NavigationNode(
_('Send mail to all members'),
reverse('send_mail_to_all_members_view'),
id=submenu_id, parent_id=master_id,
visible=True
)
nodes.append(node)
submenu_id += 1
node = NavigationNode(
_('Who is who'),
reverse('who_is_who_view'),
id=submenu_id, parent_id=master_id,
visible=True
)
nodes.append(node)
submenu_id += 1
node = NavigationNode(
_('Me'),
reverse('me_view'),
id=submenu_id, parent_id=master_id,
visible=True
)
nodes.append(node)
# master_id = 3
# node = NavigationNode(
# "%s" % _('Group'),
# "/",
# id=master_id,
# visible=True
# )
# nodes.append(node)
# submenu_id = master_id + 1
# node = NavigationNode(
# _('Send mail to coordinators'),
# reverse('send_mail_to_coordinators_view'),
# id=submenu_id, parent_id=master_id,
# visible=True
# )
# nodes.append(node)
# submenu_id += 1
# if REPANIER_SETTINGS_DISPLAY_WHO_IS_WHO:
# node = NavigationNode(
# _('Send mail to all members'),
# reverse('send_mail_to_all_members_view'),
# id=submenu_id, parent_id=master_id,
# visible=True
# )
# nodes.append(node)
# submenu_id += 1
# node = NavigationNode(
# _('Who is who'),
# reverse('who_is_who_view'),
# id=submenu_id, parent_id=master_id,
# visible=True
# )
# nodes.append(node)
# submenu_id += 1
# node = NavigationNode(
# _('Me'),
# reverse('me_view'),
# id=submenu_id, parent_id=master_id,
# visible=True
# )
# nodes.append(node)
return nodes
......
This diff is collapsed.
......@@ -80,28 +80,7 @@
</ul>
{# <!-- Right Nav Section --> #}
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li id="li_my_name" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans "Welkom" %} {% if user %}{{ user.username }}{% else %}<span id="my_name"></span>{% endif %}
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{% url "logout_form" %}">{% trans "Logout" %}</a></li>
</ul>
</li>
{% if permanence %}
<li id="li_my_basket" style="display:none;" class="dropdown">
{% if delivery_id %}
<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 %}
</li>
{% endif %}
{% else %}
<li class="dropdown">
<a href="{% url "login_form" %}">{% trans "Login" %}</a>
</li>
{% endif %}
{% repanier_user permanence_id=permanence.id delivery_id=delivery.id %}
{% repanier_display_languages as display_languages %}
{% if display_languages %}
<li class="dropdown">
......@@ -110,8 +89,6 @@
{% language_chooser "native" %}
</ul>
</li>
{% else %}
&nbsp;{{ repanier_display_languages }}&nbsp;
{% endif %}
</ul>
</div>
......
......@@ -82,28 +82,7 @@
</ul>
{# <!-- Right Nav Section --> #}
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li id="li_my_name" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans "Welkom" %} {% if user %}{{ user.username }}{% else %}<span id="my_name"></span>{% endif %}
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{% url "logout_form" %}">{% trans "Logout" %}</a></li>
</ul>
</li>
{% if permanence %}
<li id="li_my_basket" style="display:none;" class="dropdown">
{% if delivery_id %}
<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 %}
</li>
{% endif %}
{% else %}
<li class="dropdown">
<a href="{% url "login_form" %}">{% trans "Login" %}</a>
</li>
{% endif %}
{% repanier_user permanence_id=permanence.id delivery_id=delivery.id %}
{% repanier_display_languages as display_languages %}
{% if display_languages %}
<li class="dropdown">
......@@ -112,8 +91,6 @@
{% language_chooser "native" %}
</ul>
</li>
{% else %}
&nbsp;{{ repanier_display_languages }}&nbsp;
{% endif %}
</ul>
</div>
......
......@@ -307,24 +307,24 @@
</div>
{% endif %}
</div>
{% addtoblock "lastjs" %}
<script type="text/javascript">
$(document).ready(function () {
lien = '{% url 'my_balance' %}';
$.ajax({
url: lien,
cache: false,
async: false,
success: function (result) {
$("#my_balance").html(result);
},
error: function (result) {
$("#my_balance").html("{% trans "Retry7" %}");
}
});
});
</script>
{% endaddtoblock %}
{#{% addtoblock "lastjs" %}#}
{# <script type="text/javascript">#}
{# $(document).ready(function () {#}
{# lien = '{% url 'my_balance' %}';#}
{# $.ajax({#}
{# url: lien,#}
{# cache: false,#}
{# async: false,#}
{# success: function (result) {#}
{# $("#my_balance").html(result);#}
{# },#}
{# error: function (result) {#}
{# $("#my_balance").html("{% trans "Retry7" %}");#}
{# }#}
{# });#}
{# });#}
{# </script>#}
{#{% endaddtoblock %}#}
{% addtoblock "lastjs" %}
{% if not next_customer_invoice_id %}
<script type="text/javascript">
......
{% extends 'cms_subpage.html' %}
{% extends 'cms_page.html' %}
{% load static cms_tags sekizai_tags i18n l10n %}
{% block sub_content %}
{% if update == "Ok" %}<p class="bg-success" style="color: #cec7c7"><strong>{% trans "Update done." %}</strong></p>{% endif %}
......
{% extends 'base.html' %}
{% extends 'cms_page.html' %}
{% load cms_tags sekizai_tags i18n l10n thumbnail filer_tags filer_image_tags %}
{% block base_content %}
<div class="container-repanier">
<div class="container">
{% block sub_content %}
{#<div class="container-repanier">#}
{#<div class="container">#}
{% if is_anonymous %}
<div class="row">
<div class="panel panel-danger">
......@@ -276,8 +276,8 @@
</div>
</div>
{% endif %} {# not is_anonymous or display_anonymous_order_form #}
</div>
</div>
{#</div>#}
{#</div>#}
{% endblock %}
{% block footer %}
<div class="visible-xs">
......
......@@ -135,24 +135,24 @@
<div class="hidden-xs">
<br/>
</div>
{% addtoblock "lastjs" %}
<script type="text/javascript">
$(document).ready(function () {
lien = '{% url 'my_balance' %}';
$.ajax({
url: lien,
cache: false,
async: false,
success: function (result) {
$("#my_balance").html(result);
},
error: function (result) {
$("#my_balance").html("{% trans "Retry7" %}");
}
});
});
</script>
{% endaddtoblock %}
{#{% addtoblock "lastjs" %}#}
{# <script type="text/javascript">#}
{# $(document).ready(function () {#}
{# lien = '{% url 'my_balance' %}';#}
{# $.ajax({#}
{# url: lien,#}
{# cache: false,#}
{# async: false,#}
{# success: function (result) {#}
{# $("#my_balance").html(result);#}
{# },#}
{# error: function (result) {#}
{# $("#my_balance").html("{% trans "Retry7" %}");#}
{# }#}
{# });#}
{# });#}
{# </script>#}
{#{% endaddtoblock %}#}
{% addtoblock "lastjs" %}
<script type="text/javascript">
$(document).ready(function () {
......
{% extends 'cms_subpage.html' %}
{% extends 'cms_page.html' %}
{% load cms_tags sekizai_tags i18n l10n %}
{% block sub_content %}
{% if update == '2' %}<p class="bg-success">{% trans "The mail has been send" %}</p>{% endif %}
......
{% extends 'cms_subpage.html' %}
{% extends 'cms_page.html' %}
{% load cms_tags sekizai_tags i18n l10n %}
{% block sub_content %}
{% if update == '1' %}<p class="bg-danger">{% trans "Which coordinator(s) have you selected ?" %}</p>{% endif %}
......
......@@ -63,18 +63,18 @@
//store old value of "select" to restore it when Ajax calls fails
$(this).data('oldValue', $(this).val());
});
lien = '{% url 'my_balance' %}';
$.ajax({
url: lien,
cache: false,
async: false,
success: function (result) {
$("#my_balance").html(result);
},
error: function (result) {
$("#my_balance").html("{% trans "Retry7" %}");
}
});
{# lien = '{% url 'my_balance' %}';#}
{# $.ajax({#}
{# url: lien,#}
{# cache: false,#}
{# async: false,#}
{# success: function (result) {#}
{# $("#my_balance").html(result);#}
{# },#}
{# error: function (result) {#}
{# $("#my_balance").html("{% trans "Retry7" %}");#}
{# }#}
{# });#}
});
</script>
{% endaddtoblock %}
......
{% extends 'cms_subpage.html' %}
{% extends 'cms_page.html' %}
{% load cms_tags sekizai_tags i18n l10n %}
{% block search %}
<form id="search_form" class="form-horizontal" class="navbar-form" role="search" method="post">
......
......@@ -2,10 +2,13 @@
from __future__ import unicode_literals
from django import template
from django.conf import settings
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from repanier.const import EMPTY_STRING, PERMANENCE_CLOSED
from repanier.models import PermanenceBoard
from repanier.const import EMPTY_STRING, PERMANENCE_CLOSED, DECIMAL_ZERO
from repanier.models import PermanenceBoard, CustomerInvoice
from repanier.tools import sint
register = template.Library()
......@@ -17,6 +20,88 @@ def repanier_home(*args, **kwargs):
return REPANIER_SETTINGS_HOME_SITE
@register.simple_tag(takes_context=True)
def repanier_user(context, *args, **kwargs):
from repanier.apps import REPANIER_SETTINGS_INVOICE, REPANIER_SETTINGS_DISPLAY_WHO_IS_WHO
request = context["request"]
user = request.user
if user.is_authenticated:
p_permanence_id = sint(kwargs.get('permanence_id', -1))
p_delivery_id = sint(kwargs.get('delivery_id', -1))
nodes = ["""
<li id="li_my_name" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">%s %s<b class="caret"></b></a>
<ul class="dropdown-menu">
""" % (
_('Welkom'),
user.username or '<span id = "my_name"></ span>'
)]
if not user.is_staff:
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse('send_mail_to_coordinators_view'),
_('Send mail to coordinators')
))
if REPANIER_SETTINGS_DISPLAY_WHO_IS_WHO:
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse('send_mail_to_all_members_view'),
_('Send mail to all members')
))
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse('who_is_who_view'),
_('Who is who')
))
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse('my_profile_view'),
_('My profile')
))
if REPANIER_SETTINGS_INVOICE and not request.user.is_staff:
last_customer_invoice = CustomerInvoice.objects.filter(
customer__user_id=request.user.id,
invoice_sort_order__isnull=False) \
.only("balance", "date_balance") \
.order_by('-invoice_sort_order').first()
if last_customer_invoice is not None:
if last_customer_invoice.balance < DECIMAL_ZERO:
my_balance = _('My balance : <font color="red">%(balance)s</font> at %(date)s') % {
'balance': last_customer_invoice.balance,
'date' : last_customer_invoice.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
else:
my_balance = _('My balance : <font color="green">%(balance)s</font> at %(date)s') % {
'balance': last_customer_invoice.balance,
'date' : last_customer_invoice.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
else:
my_balance = _('My balance')
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse("customer_invoice_view", args=(0,)),
my_balance
))
nodes.append('<li class="divider"></li>')
nodes.append('<li><a href="%s">%s</a></li>' % (
reverse("logout_form"), _("Logout")
))
nodes.append('</ul></li>')
if p_permanence_id > 0:
nodes.append('<li id="li_my_basket" style="display:none;" class="dropdown">')
if p_delivery_id > 0:
nodes.append('<a href="%s" class="btn btn-info"><span id="my_basket"></span></a>' %
reverse("basket_delivery_view", args=(p_permanence_id, p_delivery_id))
)
else:
nodes.append('<a href="%s" class="btn btn-info"><span id="my_basket"></span></a>' %
reverse("basket_view", args=(p_permanence_id,))
)
nodes.append('</li>')
else:
nodes = ['<li class="dropdown"><a href="%s">%s</a></li>' % (
reverse("login_form"),
_("Login")
)]
return mark_safe("".join(nodes))
@register.simple_tag(takes_context=False)
def repanier_display_languages(*args, **kwargs):
from django.conf import settings
......
......@@ -128,7 +128,7 @@ urlpatterns = [
url(r'^coordinators/$', send_mail_to_coordinators_view, name='send_mail_to_coordinators_view'),
url(r'^members/$', send_mail_to_all_members_view, name='send_mail_to_all_members_view'),
url(r'^who/$', who_is_who_view, name='who_is_who_view'),
url(r'^me/$', me_view, name='me_view'),
url(r'^me/$', me_view, name='my_profile_view'),
# url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
url(r'^rest/permanences/$', permanences_rest, name='permanences_rest'),
url(r'^rest/permanence/(?P<permanence_id>\d+)/(?P<producer_name>.*)/(?P<reference>.*)/$',
......
......@@ -63,16 +63,16 @@ def order_init_ajax(request):
if customer_invoice is None:
raise Http404
my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax(), to_json)
if customer.balance.amount < 0:
my_balance = _('My balance : <font color="red">%(balance)s</font> at %(date)s') % {
'balance': customer.balance,
'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
else:
my_balance = _('My balance : <font color="green">%(balance)s</font> at %(date)s') % {
'balance': customer.balance,
'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
option_dict = {'id': "#my_balance", 'html': my_balance}
to_json.append(option_dict)
# if customer.balance.amount < 0:
# my_balance = _('My balance : <font color="red">%(balance)s</font> at %(date)s') % {
# 'balance': customer.balance,
# 'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
# else:
# my_balance = _('My balance : <font color="green">%(balance)s</font> at %(date)s') % {
# 'balance': customer.balance,
# 'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
# option_dict = {'id': "#my_balance", 'html': my_balance}
# to_json.append(option_dict)
basket = sboolean(request.GET.get('ba', False))
from repanier.apps import REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS, \
REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM, \
......
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