misc: use publik menu to advertise different channels
This commit is contained in:
parent
bd7a4aff27
commit
300e991ae3
|
@ -512,18 +512,6 @@ div#subheader a:hover {
|
|||
background: rgba(100, 100, 100, 0.9);
|
||||
}
|
||||
|
||||
a.icon-mail:before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f0e0"; /* envelope */
|
||||
padding-right: 1ex;
|
||||
}
|
||||
|
||||
a.icon-phone:before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f095 "; /* phone */
|
||||
padding-right: 1ex;
|
||||
}
|
||||
|
||||
form.contact-add p label {
|
||||
display: inline-block;
|
||||
width: 6em;
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
|
||||
{% block subheader %}
|
||||
<div id="subheader">
|
||||
{% if 'mail' in channels %}
|
||||
<a class="icon-mail" href="{% url 'home-mail' %}">{% trans 'Mail' %}</a>
|
||||
{% endif %}
|
||||
{% if 'phone' in channels %}
|
||||
<a class="icon-phone" href="{% url 'home-phone' %}">{% trans 'Phone' %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -215,16 +215,24 @@ def create_formdata(request, *args, **kwargs):
|
|||
@login_required
|
||||
def menu_json(request):
|
||||
response = HttpResponse(content_type='application/json')
|
||||
if getattr(settings, 'TEMPLATE_VARS', {}).get('site_title'):
|
||||
label = settings.TEMPLATE_VARS.get('site_title')
|
||||
else:
|
||||
label = _('Counter')
|
||||
json_str = json.dumps([{'label': force_text(label),
|
||||
'slug': 'counter',
|
||||
'url': request.build_absolute_uri(reverse('home'))
|
||||
}])
|
||||
user_groups = set([x.name for x in request.user.groups.all()])
|
||||
menu = []
|
||||
labels = {
|
||||
'mail': _('Mails'),
|
||||
'phone': _('Phone Calls'),
|
||||
}
|
||||
for channel in settings.CHANNEL_ROLES:
|
||||
channel_groups = set(settings.CHANNEL_ROLES[channel])
|
||||
if user_groups.intersection(channel_groups):
|
||||
menu.append({
|
||||
'label': force_text(labels.get(channel)),
|
||||
'slug': channel,
|
||||
'url': request.build_absolute_uri(reverse('home-%s' % channel)),
|
||||
})
|
||||
json_str = json.dumps(menu)
|
||||
for variable in ('jsonpCallback', 'callback'):
|
||||
if variable in request.GET:
|
||||
response = HttpResponse(content_type='application/javascript')
|
||||
json_str = '%s(%s);' % (request.GET[variable], json_str)
|
||||
break
|
||||
response.write(json_str)
|
||||
|
|
Loading…
Reference in New Issue