<commit_before># coding: utf-8
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_noop as _
from modoboa.lib import events
from modoboa.lib.webutils import static_url

def menu(**kwargs):
    import views

    if kwargs["target"] != "top_menu_middle":
        return []
    return [
        {"name"  : "demo",
         "label" : _("Test messages"),
         "img" : static_url("pics/demo.png"),
         "class" : "topdropdown",
         "menu"  : [
                {"name"  : "sendvirus",
                 "label" :  _("Send virus"),
                 "img" : static_url("pics/send-receive.png"),
                 "url"   : reverse(views.send_virus)},
                {"name"  : "sendspam",
                 "label" :  _("Send spam"),
                 "img" : static_url("pics/send-receive.png"),
                 "url"   : reverse(views.send_spam)}
                ]
         }
        ]

events.register("UserMenuDisplay", menu)<commit_msg>Do not register events if application is not activated.<commit_after># coding: utf-8
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_noop as _
from modoboa.lib import events
from modoboa.lib.webutils import static_url

def menu(**kwargs):
    import views

    if kwargs["target"] != "top_menu_middle":
        return []
    return [
        {"name"  : "demo",
         "label" : _("Test messages"),
         "img" : static_url("pics/demo.png"),
         "class" : "topdropdown",
         "menu"  : [
                {"name"  : "sendvirus",
                 "label" :  _("Send virus"),
                 "img" : static_url("pics/send-receive.png"),
                 "url"   : reverse(views.send_virus)},
                {"name"  : "sendspam",
                 "label" :  _("Send spam"),
                 "img" : static_url("pics/send-receive.png"),
                 "url"   : reverse(views.send_spam)}
                ]
         }
        ]

if 'demo' in settings.INSTALLED_APPS:
    events.register("UserMenuDisplay", menu)
{'fraction_non_alphanumeric': 0.138395002402691, 'fraction_numerical': 0.0009610764055742432, 'mean_word_length': 1.9406779661016949, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4577716', 'n_tokens_mistral': 636, 'n_tokens_neox': 615, 'n_words': 133}