当前位置: 首页>>代码示例>>Python>>正文


Python events.raiseQueryEvent函数代码示例

本文整理汇总了Python中modoboa.lib.events.raiseQueryEvent函数的典型用法代码示例。如果您正苦于以下问题:Python raiseQueryEvent函数的具体用法?Python raiseQueryEvent怎么用?Python raiseQueryEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了raiseQueryEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

    def handle(self, *args, **options):
        """Command entry point."""
        load_core_settings()

        if not User.objects.filter(is_superuser=True).count():
            admin = User(username="admin", is_superuser=True)
            admin.set_password("password")
            admin.save()
            ObjectAccess.objects.create(
                user=admin, content_object=admin, is_owner=True)

        exts_pool.load_all()

        superadmin = User.objects.filter(is_superuser=True).first()
        groups = PERMISSIONS.keys() + [
            role[0] for role
            in events.raiseQueryEvent("GetExtraRoles", superadmin, None)
        ]
        for groupname in groups:
            group, created = Group.objects.get_or_create(name=groupname)
            permissions = (
                PERMISSIONS.get(groupname, []) +
                events.raiseQueryEvent("GetExtraRolePermissions", groupname)
            )
            if not permissions:
                continue
            add_permissions_to_group(group, permissions)

        for extname in exts_pool.extensions.keys():
            extension = exts_pool.get_extension(extname)
            extension.load_initial_data()
            events.raiseEvent("InitialDataLoaded", extname)
开发者ID:Norcoen,项目名称:modoboa,代码行数:32,代码来源:load_initial_data.py

示例2: extra_head_content

def extra_head_content(user):
    tpl = Template("{% for sc in static_content %}{{ sc|safe }}{% endfor %}")
    return tpl.render(
        Context(
            dict(static_content=events.raiseQueryEvent("GetStaticContent", user))
            )
        )
开发者ID:Tdey,项目名称:modoboa,代码行数:7,代码来源:libextras.py

示例3: profile

def profile(request, tplname='core/user_profile.html'):
    """Profile detail/update view."""
    update_password = True
    if True in events.raiseQueryEvent("PasswordChange", request.user):
        update_password = False

    if request.method == "POST":
        form = ProfileForm(
            update_password, request.POST, instance=request.user
        )
        if form.is_valid():
            form.save()
            if update_password and form.cleaned_data["confirmation"] != "":
                request.session["password"] = encrypt(
                    form.cleaned_data["confirmation"])
            translation.activate(request.user.language)
            request.session[translation.LANGUAGE_SESSION_KEY] = (
                request.user.language)
            return render_to_json_response(_("Profile updated"))
        return render_to_json_response(
            {'form_errors': form.errors}, status=400)

    form = ProfileForm(update_password, instance=request.user)
    return render_to_json_response({
        "content": _render_to_string(request, tplname, {
            "form": form
        })
    })
开发者ID:haitao-wang,项目名称:modoboa,代码行数:28,代码来源:user.py

示例4: __init__

    def __init__(self, *args, **kwargs):
        self.mb = kwargs.pop("instance", None)
        super(AccountFormMail, self).__init__(*args, **kwargs)
        self.field_widths = {
            "quota": 3
        }
        self.extra_fields = []
        result = events.raiseQueryEvent('ExtraFormFields', 'mailform', self.mb)
        for fname, field in result:
            self.fields[fname] = field
            self.extra_fields.append(fname)
        if self.mb is not None:
            self.fields["email"].required = True
            cpt = 1
            qset = self.mb.aliasrecipient_set.filter(alias__internal=False)
            for ralias in qset:
                name = "aliases_%d" % cpt
                self._create_field(
                    lib_fields.UTF8AndEmptyUserEmailField, name,
                    ralias.alias.address)
                cpt += 1
            self.fields["email"].initial = self.mb.full_address
            self.fields["quota_act"].initial = self.mb.use_domain_quota
            if not self.mb.use_domain_quota and self.mb.quota:
                self.fields["quota"].initial = self.mb.quota
        else:
            self.fields["quota_act"].initial = True

        if len(args) and isinstance(args[0], QueryDict):
            self._load_from_qdict(
                args[0], "aliases", lib_fields.UTF8AndEmptyUserEmailField)
开发者ID:iecsp,项目名称:modoboa,代码行数:31,代码来源:account.py

示例5: import_domains

def import_domains(request):
    if request.method == "POST":
        return importdata(request)

    helptext = _("""Provide a CSV file where lines respect one of the following formats:
<ul>
  <li><em>domain; name; quota; enabled</em></li>
  <li><em>domainalias; name; targeted domain; enabled</em></li>
  %s
</ul>
<p>The first element of each line is mandatory and must be equal to one of the previous values.</p>
<p>You can use a different character as separator.</p>
""" % ''.join([unicode(hlp) for hlp in events.raiseQueryEvent('ExtraDomainImportHelp')]))

    ctx = dict(
        title=_("Import domains"),
        action_label=_("Import"),
        action_classes="submit",
        action=reverse(import_domains),
        formid="importform",
        enctype="multipart/form-data",
        target="import_target",
        helptext=helptext,
        form=ImportDataForm()
    )
    return render(request, "admin/importform.html", ctx)
开发者ID:JHei,项目名称:modoboa,代码行数:26,代码来源:import.py

示例6: uprefs_menu

def uprefs_menu(selection, user):
    entries = [
        {"name": "profile",
         "class": "ajaxlink",
         "url": "profile/",
         "label": _("Profile")},
        {"name": "preferences",
         "class": "ajaxlink",
         "url": "preferences/",
         "label": _("Preferences")},
    ]
    if user.has_mailbox:
        entries.insert(0, {"name": "forward",
                           "class": "ajaxlink",
                           "url": "forward/",
                           "label": _("Forward")})

    entries += events.raiseQueryEvent("UserMenuDisplay", "uprefs_menu", user)
    entries = sorted(entries, key=lambda e: e["label"])
    return render_to_string('common/menu.html', {
        "entries": entries,
        "css": "nav nav-list",
        "selection": selection,
        "user": user
    })
开发者ID:Tdey,项目名称:modoboa,代码行数:25,代码来源:uprefs_extras.py

示例7: __init__

    def __init__(self, *args, **kwargs):
        if "instance" in kwargs:
            self.mb = kwargs["instance"]
            del kwargs["instance"]
        else:
            self.mb = None
        super(AccountFormMail, self).__init__(*args, **kwargs)
        self.extra_fields = []
        for fname, field in events.raiseQueryEvent('ExtraFormFields', 'mailform', self.mb):
            self.fields[fname] = field
            self.extra_fields.append(fname)
        if self.mb is not None:
            self.fields["email"].required = True
            cpt = 1
            for alias in self.mb.alias_set.all():
                if len(alias.get_recipients()) >= 2:
                    continue
                name = "aliases_%d" % cpt
                self._create_field(forms.EmailField, name, alias.full_address)
                cpt += 1
            self.fields["email"].initial = self.mb.full_address            
            self.fields["quota_act"].initial = self.mb.use_domain_quota
            if not self.mb.use_domain_quota and self.mb.quota:
                self.fields["quota"].initial = self.mb.quota
        else:
            self.fields["quota_act"].initial = True

        if len(args) and isinstance(args[0], QueryDict):
            self._load_from_qdict(args[0], "aliases", forms.EmailField)
开发者ID:Marx86,项目名称:modoboa,代码行数:29,代码来源:account.py

示例8: __init__

    def __init__(self, *args, **kwargs):
        if "instance" in kwargs:
            self.mb = kwargs["instance"]
            del kwargs["instance"]
        else:
            self.mb = None
        super(AccountFormMail, self).__init__(*args, **kwargs)
        self.field_widths = {
            "quota": 3
        }
        self.extra_fields = []
        result = events.raiseQueryEvent('ExtraFormFields', 'mailform', self.mb)
        for fname, field in result:
            self.fields[fname] = field
            self.extra_fields.append(fname)
        if self.mb is not None:
            self.fields["email"].required = True
            cpt = 1
            qset = self.mb.aliasrecipient_set.select_related("alias")
            for ralias in qset:
                if ralias.alias.recipients_count >= 2:
                    continue
                name = "aliases_%d" % cpt
                self._create_field(
                    UTF8EmailField, name, ralias.alias.address)
                cpt += 1
            self.fields["email"].initial = self.mb.full_address
            self.fields["quota_act"].initial = self.mb.use_domain_quota
            if not self.mb.use_domain_quota and self.mb.quota:
                self.fields["quota"].initial = self.mb.quota
        else:
            self.fields["quota_act"].initial = True

        if len(args) and isinstance(args[0], QueryDict):
            self._load_from_qdict(args[0], "aliases", UTF8EmailField)
开发者ID:ezhishui,项目名称:modoboa,代码行数:35,代码来源:account.py

示例9: _domains

def _domains(request):
    sort_order, sort_dir = get_sort_order(request.GET, "name")
    filters = dict(
        (flt, request.GET.get(flt, None))
        for flt in ['domfilter', 'searchquery']
        + events.raiseQueryEvent('ExtraDomainFilters')
    )
    request.session['domains_filters'] = filters
    domainlist = get_domains(request.user, **filters)
    if sort_order == 'name':
        domainlist = sorted(
            domainlist,
            key=lambda d: getattr(d, sort_order), reverse=sort_dir == '-'
        )
    else:
        domainlist = sorted(domainlist, key=lambda d: d.tags[0],
                            reverse=sort_dir == '-')
    context = {
        "handle_mailboxes": parameters.get_admin(
            "HANDLE_MAILBOXES", raise_error=False),
        "auto_account_removal": parameters.get_admin("AUTO_ACCOUNT_REMOVAL")
    }
    page = get_listing_page(domainlist, request.GET.get("page", 1))
    if page is None:
        context["length"] = 0
    else:
        context["rows"] = _render_to_string(
            request, "admin/domains_table.html", {
                'domains': page.object_list,
            }
        )
        context["pages"] = [page.number]
    return render_to_json_response(context)
开发者ID:ezhishui,项目名称:modoboa,代码行数:33,代码来源:domain.py

示例10: admin_menu

def admin_menu(selection, user):
    entries = []
    if user.has_perm("admin.view_domains"):
        entries += [
            {"name" : "domains",
             "url" : reverse("modoboa.admin.views.domains"),
             "label" : _("Domains")}
            ]
    entries += \
        events.raiseQueryEvent("AdminMenuDisplay", "top_menu", user)
    if user.has_perm("admin.add_user") or user.has_perm("admin.add_alias"):
        entries += [
            {"name" : "identities",
             "url" : reverse("modoboa.admin.views.identities"),
             "label" : _("Identities")},
            ]
    if user.is_superuser:
        entries += [
            {"name" : "settings",
             "label" : _("Modoboa"),
             "url" : reverse("modoboa.admin.views.viewsettings")}
            ]

    if not len(entries):
        return ""
    return render_to_string("common/menulist.html",
                            {"entries" : entries, "selection" : selection, "user" : user})
开发者ID:juju2013,项目名称:modoboa,代码行数:27,代码来源:admin_extras.py

示例11: identity_actions

def identity_actions(user, ident):
    name = ident.__class__.__name__
    objid = ident.id
    if name == "User":
        actions = events.raiseQueryEvent("ExtraAccountActions", ident)
        actions += [
            {"name" : "delaccount",
             "url" : reverse("modoboa.admin.views.delaccount") + "?selection=%s" % objid,
             "img" : "icon-trash",
             "title" : _("Delete this account")},
            ]
    else:
        if ident.get_recipients_count() >= 2:
            actions = [
                {"name" : "deldlist",
                 "url" : reverse("modoboa.admin.views.deldlist") + "?selection=%s" % objid,
                 "img" : "icon-trash",
                 "title" : _("Delete this distribution list")},
                ]
        elif ident.extmboxes != "":
            actions = [
                {"name" : "delforward",
                 "url" : reverse("modoboa.admin.views.delforward") + "?selection=%s" % objid,
                 "img" : "icon-trash",
                 "title" : _("Delete this forward")},
                ]
        else:
            actions = [
                {"name" : "delalias",
                 "url" : reverse("modoboa.admin.views.delalias") + "?selection=%s" % objid,
                 "img" : "icon-trash",
                 "title" : _("Delete this alias")},
                ]
    return render_actions(actions)
开发者ID:juju2013,项目名称:modoboa,代码行数:34,代码来源:admin_extras.py

示例12: profile

def profile(request, tplname='core/user_profile.html'):
    update_password = True
    if True in events.raiseQueryEvent("PasswordChange", request.user):
        update_password = False

    if request.method == "POST":
        form = ProfileForm(
            update_password, request.POST, instance=request.user
        )
        if form.is_valid():
            form.save()
            if update_password and form.cleaned_data["confirmation"] != "":
                request.session["password"] = encrypt(form.cleaned_data["confirmation"])
            return ajax_simple_response(dict(
                status="ok", respmsg=_("Profile updated")
            ))
        return ajax_simple_response({
            "status": "ko",
            "errors": form.errors
        })

    form = ProfileForm(update_password, instance=request.user)
    return ajax_simple_response({
        "status": "ok",
        "content": _render_to_string(request, tplname, {
            "form": form
        })
    })
开发者ID:schiiz1,项目名称:modoboa,代码行数:28,代码来源:user.py

示例13: check_top_notifications

def check_top_notifications(request):
    """
    AJAX service to check for new top notifications to display.
    """
    return render_to_json_response(
        events.raiseQueryEvent("TopNotifications", request, True)
    )
开发者ID:whyscream,项目名称:modoboa,代码行数:7,代码来源:admin.py

示例14: uprefs_menu

def uprefs_menu(selection, user):
    entries = [
        {"name": "profile",
         "class": "ajaxnav",
         "url": "profile/",
         "label": _("Profile")},
        {"name": "preferences",
         "class": "ajaxnav",
         "url": "preferences/",
         "label": _("Preferences")},
    ]
    if user.is_superuser:
        entries.append({
            "name": "api",
            "class": "ajaxnav",
            "url": "api/",
            "label": _("API"),
        })
    entries += events.raiseQueryEvent("UserMenuDisplay", "uprefs_menu", user)
    entries = sorted(entries, key=lambda e: e["label"])
    return render_to_string('common/menu.html', {
        "entries": entries,
        "css": "nav nav-sidebar",
        "selection": selection,
        "user": user
    })
开发者ID:whyscream,项目名称:modoboa,代码行数:26,代码来源:core_tags.py

示例15: __init__

 def __init__(self, user, *args, **kwargs):
     super(DomainFormOptions, self).__init__(*args, **kwargs)
     if False in events.raiseQueryEvent("UserCanSetRole", user, "DomainAdmins"):
         self.fields = {}
         return
     if args:
         if args[0].get("create_dom_admin", "no") == "yes":
             self.fields["dom_admin_username"].required = True
             self.fields["create_aliases"].required = True
开发者ID:jmfield2,项目名称:modoboa,代码行数:9,代码来源:domain.py


注:本文中的modoboa.lib.events.raiseQueryEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。