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