本文整理汇总了Python中modoboa.lib.webutils.ajax_response函数的典型用法代码示例。如果您正苦于以下问题:Python ajax_response函数的具体用法?Python ajax_response怎么用?Python ajax_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ajax_response函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: submitfilter
def submitfilter(request, setname, okmsg, tplname, tplctx, update=False, sc=None):
form = build_filter_form_from_qdict(request)
if form.is_valid():
if sc is None:
sc = SieveClient(user=request.user.username,
password=request.session["password"])
fset = sc.getscript(setname, format="fset")
conditions, actions = form.tofilter()
match_type = form.cleaned_data["match_type"]
if match_type == "all":
match_type = "anyof"
conditions = [("true",)]
fltname = form.cleaned_data["name"].encode("utf-8")
if not update:
fset.addfilter(fltname, conditions, actions,
match_type)
else:
oldname = request.POST["oldname"].encode("utf-8")
fset.updatefilter(
oldname, fltname, conditions, actions, match_type
)
try:
sc.pushscript(fset.name, str(fset))
except SieveClientError as e:
return ajax_response(request, "ko", respmsg=str(e))
return ajax_response(request, respmsg=okmsg, ajaxnav=True)
tplctx = build_filter_ctx(tplctx, form)
return ajax_response(request, status="ko", template=tplname, **tplctx)
开发者ID:schiiz1,项目名称:modoboa,代码行数:28,代码来源:views.py
示例2: removefilter
def removefilter(request, setname, fname):
sc = SieveClient(user=request.user.username,
password=request.session["password"])
fset = sc.getscript(setname, format="fset")
if fset.removefilter(fname.encode("utf-8")):
sc.pushscript(fset.name, str(fset))
return ajax_response(request, respmsg=_("Filter removed"))
return ajax_response(request, "ko", respmsg=_("Failed to remove filter"))
开发者ID:schiiz1,项目名称:modoboa,代码行数:8,代码来源:views.py
示例3: release
def release(request, mail_id):
"""Release message selection.
:param str mail_id: message unique identifier
"""
mail_id = check_mail_id(request, mail_id)
msgrcpts = []
wrapper = get_wrapper()
mb = Mailbox.objects.get(user=request.user) \
if request.user.group == 'SimpleUsers' else None
for mid in mail_id:
r, i = mid.split()
if mb is not None and r != mb.full_address \
and not r in mb.alias_addresses:
continue
msgrcpts += [wrapper.get_recipient_message(r, i)]
if mb is not None and parameters.get_admin("USER_CAN_RELEASE") == "no":
# FIXME : can't use this syntax because extra SQL (using
# .extra() for postgres) is not propagated (the 'tables'
# parameter is lost somewhere...)
#
# msgrcpts.update(rs='p')
for msgrcpt in msgrcpts:
msgrcpt.rs = 'p'
msgrcpt.save()
message = ungettext("%(count)d request sent",
"%(count)d requests sent",
len(mail_id)) % {"count": len(mail_id)}
return ajax_response(
request, "ok", respmsg=message,
url=QuarantineNavigationParameters(request).back_to_listing()
)
amr = AMrelease()
error = None
for rcpt in msgrcpts:
result = amr.sendreq(rcpt.mail.mail_id, rcpt.mail.secret_id, rcpt.rid.email)
if result:
rcpt.rs = 'R'
rcpt.save()
else:
error = result
break
if not error:
message = ungettext("%(count)d message released successfully",
"%(count)d messages released successfully",
len(mail_id)) % {"count": len(mail_id)}
else:
message = error
return ajax_response(
request, "ko" if error else "ok", respmsg=message,
url=QuarantineNavigationParameters(request).back_to_listing()
)
开发者ID:Marx86,项目名称:modoboa,代码行数:54,代码来源:views.py
示例4: release
def release(request, mail_id):
"""Release message selection.
:param str mail_id: message unique identifier
"""
mail_id = check_mail_id(request, mail_id)
msgrcpts = []
wrapper = get_wrapper()
mb = Mailbox.objects.get(user=request.user) \
if request.user.group == 'SimpleUsers' else None
for mid in mail_id:
r, i = mid.split()
if mb is not None and r != mb.full_address \
and not r in mb.alias_addresses:
continue
msgrcpts += [wrapper.get_recipient_message(r, i)]
if mb is not None and parameters.get_admin("USER_CAN_RELEASE") == "no":
for msgrcpt in msgrcpts:
wrapper.set_msgrcpt_status(
msgrcpt.rid.email, msgrcpt.mail.mail_id, 'p'
)
message = ungettext("%(count)d request sent",
"%(count)d requests sent",
len(mail_id)) % {"count": len(mail_id)}
return ajax_response(
request, "ok", respmsg=message,
url=QuarantineNavigationParameters(request).back_to_listing()
)
amr = AMrelease()
error = None
for rcpt in msgrcpts:
result = amr.sendreq(
rcpt.mail.mail_id, rcpt.mail.secret_id, rcpt.rid.email
)
if result:
wrapper.set_msgrcpt_status(rcpt.rid.email, rcpt.mail.mail_id, 'R')
else:
error = result
break
if not error:
message = ungettext("%(count)d message released successfully",
"%(count)d messages released successfully",
len(mail_id)) % {"count": len(mail_id)}
else:
message = error
return ajax_response(
request, "ko" if error else "ok", respmsg=message,
url=QuarantineNavigationParameters(request).back_to_listing()
)
开发者ID:masbog,项目名称:modoboa,代码行数:51,代码来源:views.py
示例5: delattachment
def delattachment(request):
if not "compose_mail" in request.session or not "name" in request.GET or not request.GET["name"]:
return ajax_response(request, "ko", respmsg=_("Bad query"))
error = None
for att in request.session["compose_mail"]["attachments"]:
if att["tmpname"] == request.GET["name"]:
request.session["compose_mail"]["attachments"].remove(att)
fullpath = os.path.join(settings.MEDIA_ROOT, "webmail", att["tmpname"])
try:
os.remove(fullpath)
except OSError, e:
error = _("Failed to remove attachment: ") + str(e)
break
request.session.modified = True
return ajax_response(request)
开发者ID:jmfield2,项目名称:modoboa,代码行数:16,代码来源:views.py
示例6: download_filters_set
def download_filters_set(request, name):
sc = SieveClient(user=request.user.username,
password=request.session["password"])
try:
script = sc.getscript(name)
except SieveClientError, e:
return ajax_response(request, "ko", respmsg=str(e))
开发者ID:schiiz1,项目名称:modoboa,代码行数:7,代码来源:views.py
示例7: new_filters_set
def new_filters_set(request, tplname="common/generic_modal_form.html"):
ctx = {"title": _("Create a new filters set"),
"formid": "newfiltersset",
"action_label": _("Create"),
"action_classes": "submit",
"action": reverse(new_filters_set),
"withmenu": False,
"withunseen": False}
if request.method == "POST":
form = FiltersSetForm(request.POST)
error = None
if form.is_valid():
sc = SieveClient(user=request.user.username,
password=request.session["password"])
try:
sc.pushscript(form.cleaned_data["name"], "# Empty script",
form.cleaned_data["active"])
except SieveClientError, e:
error = str(e)
else:
return ajax_simple_response({
"status": "ok",
"url": form.cleaned_data["name"],
"active": form.cleaned_data["active"],
"respmsg": _("Filters set created")
})
ctx["form"] = form
ctx["error"] = error
return ajax_response(request, status="ko", template=tplname, **ctx)
开发者ID:schiiz1,项目名称:modoboa,代码行数:30,代码来源:views.py
示例8: newfolder
def newfolder(request, tplname="webmail/folder.html"):
mbc = IMAPconnector(user=request.user.username,
password=request.session["password"])
ctx = {"title": _("Create a new mailbox"),
"formid": "mboxform",
"action": reverse(newfolder),
"action_label": _("Create"),
"action_classes": "submit",
"withunseen": False,
"selectonly": True,
"mboxes": mbc.getmboxes(request.user),
"hdelimiter": mbc.hdelimiter}
if request.method == "POST":
form = FolderForm(request.POST)
if form.is_valid():
pf = request.POST.get("parent_folder", None)
mbc.create_folder(form.cleaned_data["name"], pf)
return ajax_simple_response(dict(
status="ok", respmsg=_("Mailbox created"), newmb=form.cleaned_data["name"], parent=pf
))
ctx["form"] = form
ctx["selected"] = None
return ajax_response(request, status="ko", template=tplname, **ctx)
ctx["form"] = FolderForm()
ctx["selected"] = None
return _render(request, tplname, ctx)
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:29,代码来源:views.py
示例9: process_exception
def process_exception(self, request, exception):
if not isinstance(exception, ModoboaException):
return None
if not request.is_ajax():
return _render_error(request, user_context=dict(error=str(exception)))
return ajax_response(request, status="ko", respmsg=unicode(exception), norefresh=True)
开发者ID:Tdey,项目名称:modoboa,代码行数:8,代码来源:middleware.py
示例10: delfolder
def delfolder(request):
name = request.GET.get("name", None)
if name is None:
raise BadRequest(_("Invalid request"))
mbc = IMAPconnector(user=request.user.username, password=request.session["password"])
mbc.delete_folder(name)
WebmailNavigationParameters(request).remove("mbox")
return ajax_response(request)
开发者ID:jmfield2,项目名称:modoboa,代码行数:8,代码来源:views.py
示例11: release
def release(request, mail_id):
mail_id = check_mail_id(request, mail_id)
if request.user.group == 'SimpleUsers':
mb = Mailbox.objects.get(user=request.user)
msgrcpts = get_wrapper().get_recipient_messages(mb.full_address, mail_id)
if parameters.get_admin("USER_CAN_RELEASE") == "no":
# FIXME : can't use this syntax because extra SQL (using
# .extra() for postgres) is not propagated (the 'tables'
# parameter is lost somewhere...)
#
# msgrcpts.update(rs='p')
for msgrcpt in msgrcpts:
msgrcpt.rs = 'p'
msgrcpt.save()
message = ungettext("%(count)d request sent",
"%(count)d requests sent",
len(mail_id)) % {"count": len(mail_id)}
return ajax_response(request, "ok", respmsg=message,
url=__back_to_listing(request))
else:
msgrcpts = []
wrapper = get_wrapper()
for mid in mail_id:
r, i = mid.split()
msgrcpts += [wrapper.get_recipient_message(r, i)]
amr = AMrelease()
error = None
for rcpt in msgrcpts:
result = amr.sendreq(rcpt.mail.mail_id, rcpt.mail.secret_id, rcpt.rid.email)
if result:
rcpt.rs = 'R'
rcpt.save()
else:
error = result
break
if not error:
message = ungettext("%(count)d message released successfully",
"%(count)d messages released successfully",
len(mail_id)) % {"count": len(mail_id)}
else:
message = error
return ajax_response(request, "ko" if error else "ok", respmsg=message,
url=__back_to_listing(request))
开发者ID:schiiz1,项目名称:modoboa,代码行数:45,代码来源:views.py
示例12: move_filter
def move_filter(request, setname, fname, direction):
sc = SieveClient(user=request.user.username,
password=request.session["password"])
try:
fset = sc.getscript(setname, format="fset")
fset.movefilter(fname.encode("utf-8"), direction)
sc.pushscript(setname, str(fset))
except (SieveClientError), e:
return ajax_response(request, "ko", respmsg=str(e))
开发者ID:schiiz1,项目名称:modoboa,代码行数:9,代码来源:views.py
示例13: process_exception
def process_exception(self, request, exception):
if not isinstance(exception, (WebmailError, ImapError)):
return None
json = request.GET.get("json", False) if request.method == "GET" \
else request.POST.get("json", False)
if json:
return ajax_response(request, status="ko",
respmsg=str(exception), norefresh=True)
return _render_error(request, user_context=dict(error=str(exception)))
开发者ID:Tdey,项目名称:modoboa,代码行数:9,代码来源:middleware.py
示例14: move_filter
def move_filter(request, setname, fname, direction):
sc = SieveClient(user=request.user.username,
password=request.session["password"])
fset = sc.getscript(setname, format="fset")
fset.movefilter(fname.encode("utf-8"), direction)
sc.pushscript(setname, str(fset))
return ajax_response(
request, template="sievefilters/guieditor.html", fs=fset
)
开发者ID:Marx86,项目名称:modoboa,代码行数:9,代码来源:views.py
示例15: savefs
def savefs(request, name):
if not "scriptcontent" in request.POST:
return
sc = SieveClient(user=request.user.username, password=request.session["password"])
try:
sc.pushscript(name, request.POST["scriptcontent"])
except SieveClientError, e:
error = str(e)
return ajax_response(request, "ko", respmsg=error)
开发者ID:JHei,项目名称:modoboa,代码行数:9,代码来源:views.py
示例16: delfolder
def delfolder(request):
name = request.GET.get("name", None)
if name is None:
raise WebmailError(_("Bad request"))
mbc = IMAPconnector(user=request.user.username,
password=request.session["password"])
mbc.delete_folder(name)
if request.session.has_key("mbox"):
del request.session["mbox"]
return ajax_response(request)
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:10,代码来源:views.py
示例17: editfolder
def editfolder(request, tplname="webmail/folder.html"):
mbc = IMAPconnector(user=request.user.username,
password=request.session["password"])
ctx = {"title" : _("Edit mailbox"),
"formid" : "mboxform",
"action" : reverse(editfolder),
"action_label" : _("Update"),
"action_classes" : "submit",
"withunseen" : False,
"selectonly" : True,
"hdelimiter": mbc.hdelimiter}
if request.method == "POST":
form = FolderForm(request.POST)
if form.is_valid():
pf = request.POST.get("parent_folder", None)
ctx["selected"] = pf
oldname, oldparent = separate_mailbox(request.POST["oldname"], sep=mbc.hdelimiter)
res = dict(status="ok", respmsg=_("Mailbox updated"))
if form.cleaned_data["name"] != oldname \
or (pf != oldparent):
newname = form.cleaned_data["name"] if pf is None \
else "%s.%s" % (pf, form.cleaned_data["name"])
mbc.rename_folder(request.POST["oldname"], newname)
res["oldmb"] = oldname
res["newmb"] = form.cleaned_data["name"]
res["oldparent"] = oldparent
res["newparent"] = pf
if "mbox" in request.session:
del request.session["mbox"]
return ajax_simple_response(res)
ctx["mboxes"] = mbc.getmboxes(request.user)
ctx["form"] = form
return ajax_response(request, status="ko", template=tplname, **ctx)
name = request.GET.get("name", None)
if name is None:
raise WebmailError(_("Invalid request"))
shortname, parent = separate_mailbox(name, sep=mbc.hdelimiter)
ctx["mboxes"] = mbc.getmboxes(request.user, until_mailbox=parent)
ctx["form"] = FolderForm()
ctx["form"].fields["oldname"].initial = name
ctx["form"].fields["name"].initial = shortname
ctx["selected"] = parent
return _render(request, tplname, ctx)
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:46,代码来源:views.py
示例18: toggle_filter_state
def toggle_filter_state(request, setname, fname):
sc = SieveClient(user=request.user.username,
password=request.session["password"])
try:
fset = sc.getscript(setname, format="fset")
if fset.is_filter_disabled(fname):
ret = fset.enablefilter(fname)
newstate = _("yes")
color = "green"
else:
ret = fset.disablefilter(fname)
newstate = _("no")
color = "red"
if not ret:
pass
sc.pushscript(setname, str(fset))
except SieveClientError, e:
return ajax_response(request, "ko", respmsg=str(e))
开发者ID:juju2013,项目名称:modoboa,代码行数:18,代码来源:views.py
示例19: editaccount
def editaccount(request, accountid, tplname="common/tabforms.html"):
account = User.objects.get(pk=accountid)
if not request.user.can_access(account):
raise PermDeniedException
mb = None
if account.has_mailbox:
mb = account.mailbox_set.all()[0]
instances = dict(general=account, mail=mb, perms=account)
events.raiseEvent("FillAccountInstances", request.user, account, instances)
ctx = dict(
title=account.username,
formid="accountform",
action=reverse(editaccount, args=[accountid]),
action_label=_("Update"),
action_classes="submit"
)
if request.method == "POST":
classes = {}
form = AccountForm(request.user, request.POST,
instances=instances, classes=classes)
account.oldgroup = account.group
if form.is_valid(mandatory_only=True):
form.save_general_form()
if form.is_valid(optional_only=True):
events.raiseEvent("AccountModified", account, form.account)
form.save()
return ajax_simple_response(
dict(status="ok", respmsg=_("Account updated"))
)
transaction.rollback()
ctx["tabs"] = form
return ajax_response(request, status="ko", template=tplname, **ctx)
ctx["tabs"] = AccountForm(request.user, instances=instances)
active_tab_id = request.GET.get("active_tab", "default")
if active_tab_id != "default":
ctx["tabs"].active_id = active_tab_id
return render(request, tplname, ctx)
开发者ID:juju2013,项目名称:modoboa,代码行数:42,代码来源:views.py
示例20: delete
def delete(request, mail_id):
mail_id = check_mail_id(request, mail_id)
if request.user.group == 'SimpleUsers':
mb = Mailbox.objects.get(user=request.user)
msgrcpts = get_wrapper().get_recipient_messages(mb.full_address, mail_id)
#msgrcpts.update(rs='D')
for msgrcpt in msgrcpts:
msgrcpt.rs = 'D'
msgrcpt.save()
else:
wrapper = get_wrapper()
for mid in mail_id:
r, i = mid.split()
msgrcpt = wrapper.get_recipient_message(r, i)
msgrcpt.rs = 'D'
msgrcpt.save()
message = ungettext("%(count)d message deleted successfully",
"%(count)d messages deleted successfully",
len(mail_id)) % {"count": len(mail_id)}
return ajax_response(request, respmsg=message,
url=__back_to_listing(request))
开发者ID:schiiz1,项目名称:modoboa,代码行数:22,代码来源:views.py
注:本文中的modoboa.lib.webutils.ajax_response函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论