def filter_actions(setname, f, position, islast): actions = [ {"name": "editfilter", "url": reverse( "modoboa_sievefilters:filter_change", args=[setname, f["name"]]), "img": "fa fa-edit", "title": _("Edit filter"), "modal": True, "autowidth": True, "modalcb": "filterform_cb"}, {"name": "removefilter", "url": reverse( "modoboa_sievefilters:filter_delete", args=[setname, f["name"]]), "img": "fa fa-trash", "title": _("Remove this filter")} ] if position != 1: actions += [ {"name": "movefilter_up", "url": reverse( "modoboa_sievefilters:filter_move_up", args=[setname, f["name"]]), "img": "fa fa-chevron-up", "title": _("Move this filter up")} ] if not islast: actions += [ {"name": "movefilter_down", "url": reverse( "modoboa_sievefilters:filter_move_down", args=[setname, f["name"]]), "img": "fa fa-chevron-down", "title": _("Move this filter down")}, ] return render_actions(actions)
def domain_actions(user, domain): actions = [ {"name": "listidentities", "url": u"{0}#list/?searchquery=@{1}".format( reverse("admin:identity_list"), domain.name), "title": _("View the domain's identities"), "img": "fa fa-user"} ] if user.has_perm("admin.change_domain"): actions.append({ "name": "editdomain", "title": _("Edit {}").format(domain), "url": reverse("admin:domain_change", args=[domain.pk]), "modal": True, "modalcb": "admin.domainform_cb", "img": "fa fa-edit" }) if user.has_perm("admin.delete_domain"): actions.append({ "name": "deldomain", "url": reverse("admin:domain_delete", args=[domain.id]), "title": _("Delete %s?" % domain.name), "img": "fa fa-trash" }) responses = signals.extra_domain_actions.send( sender=None, user=user, domain=domain) for receiver, response in responses: if response: actions += response return render_actions(actions)
def calendar_actions(calendar): """Render per-calendar actions.""" actions = [{ "name": "editcalendar", "title": _("Edit %s" % calendar), "modal": True, "img": "fa fa-edit" }, { "name": "delcalendar", "title": _("Delete %s?" % calendar), "img": "fa fa-trash" }] if calendar.__class__.__name__ == 'UserCalendar': actions[0]["url"] = reverse("modoboa_radicale:user_calendar", args=[calendar.pk]) actions[0]["modalcb"] = "radicale.edit_calendar_cb" actions[1]["url"] = reverse("modoboa_radicale:user_calendar", args=[calendar.id]) else: actions[0]["url"] = reverse("modoboa_radicale:shared_calendar", args=[calendar.pk]) actions[0]["modalcb"] = "radicale.shared_calendar_cb" actions[1]["url"] = reverse("modoboa_radicale:shared_calendar", args=[calendar.id]) return render_actions(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("admin:account_delete", args=[objid]), "img": "fa fa-trash", "title": _("Delete %s?" % ident.username) }, ] else: actions = [ { "name": "delalias", "url": "{}?selection={}".format(reverse("admin:alias_delete"), objid), "img": "fa fa-trash", "title": _("Delete %s?" % ident.address) }, ] return render_actions(actions)
def domadmin_actions(daid, domid): actions = [{ "name": "removeperm", "url": "{0}?domid={1}&daid={2}".format( reverse("admin:permission_remove"), domid, daid), "img": "fa fa-trash", "title": _("Remove this permission") }] return render_actions(actions)
def filter_actions(setname, f, position, islast): actions = [{ "name": "editfilter", "url": reverse("modoboa_sievefilters:filter_change", args=[setname, f["name"]]), "img": "fa fa-edit", "title": _("Edit filter"), "modal": True, "autowidth": True, "modalcb": "filterform_cb" }, { "name": "removefilter", "url": reverse("modoboa_sievefilters:filter_delete", args=[setname, f["name"]]), "img": "fa fa-trash", "title": _("Remove this filter") }] if position != 1: actions += [{ "name": "movefilter_up", "url": reverse("modoboa_sievefilters:filter_move_up", args=[setname, f["name"]]), "img": "fa fa-chevron-up", "title": _("Move this filter up") }] if not islast: actions += [ { "name": "movefilter_down", "url": reverse("modoboa_sievefilters:filter_move_down", args=[setname, f["name"]]), "img": "fa fa-chevron-down", "title": _("Move this filter down") }, ] return render_actions(actions)
def alias_pipe_actions(alias_pipe): return render_actions([ { "name": "delaliaspipe", "url": reverse( "modoboa_alias_pipe:alias_pipe_delete", args=[alias_pipe.id] ), "img": "fa fa-trash", "title": _("Delete %s?" % alias_pipe.full_address), } ])
def identity_actions(user, ident): name = ident.__class__.__name__ objid = ident.id if name == "User": actions = [] result = core_signals.extra_account_actions.send( sender="identity_actions", account=ident) for action in result: actions += action[1] url = (reverse("admin:account_change", args=[objid]) + "?active_tab=default") actions += [ { "name": "changeaccount", "url": url, "img": "fa fa-edit", "modal": True, "modalcb": "admin.editaccount_cb", "title": _("Edit {}").format(ident.username) }, { "name": "delaccount", "url": reverse("admin:account_delete", args=[objid]), "img": "fa fa-trash", "title": _("Delete %s?") % ident.username }, ] else: actions = [ { "name": "changealias", "url": reverse("admin:alias_change", args=[objid]), "img": "fa fa-edit", "modal": True, "modalcb": "admin.aliasform_cb", "title": _("Edit {}").format(ident) }, { "name": "delalias", "url": "{}?selection={}".format(reverse("admin:alias_delete"), objid), "img": "fa fa-trash", "title": _("Delete %s?") % ident.address }, ] return render_actions(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("admin:account_delete", args=[objid]), "img": "fa fa-trash", "title": _("Delete %s?" % ident.username)}, ] else: actions = [ {"name": "delalias", "url": reverse("admin:alias_delete") + "?selection=%s" % objid, "img": "fa fa-trash", "title": _("Delete %s?" % ident.full_address)}, ] return render_actions(actions)
def domain_actions(user, domain): actions = [] if domain.__class__.__name__ == 'Domain': actions = [ {"name": "listidentities", "url": "{0}#list/?searchquery=@{1}".format( reverse("admin:identity_list"), domain.name), "title": _("View the domain's identities"), "img": "fa fa-user"} ] if user.has_perm("admin.delete_domain"): actions.append({ "name": "deldomain", "url": reverse("admin:domain_delete", args=[domain.id]), "title": _("Delete %s?" % domain.name), "img": "fa fa-trash" }) else: actions = events.raiseQueryEvent('GetDomainActions', user, domain) return render_actions(actions)
def identity_actions(user, ident): name = ident.__class__.__name__ objid = ident.id if name == "User": actions = [] result = core_signals.extra_account_actions.send( sender="identity_actions", account=ident) for action in result: actions += action[1] url = ( reverse("admin:account_change", args=[objid]) + "?active_tab=default" ) actions += [ {"name": "changeaccount", "url": url, "img": "fa fa-edit", "modal": True, "modalcb": "admin.editaccount_cb", "title": _("Edit {}").format(ident.username)}, {"name": "delaccount", "url": reverse("admin:account_delete", args=[objid]), "img": "fa fa-trash", "title": _("Delete %s?" % ident.username)}, ] else: actions = [ {"name": "changealias", "url": reverse("admin:alias_change", args=[objid]), "img": "fa fa-edit", "modal": True, "modalcb": "admin.aliasform_cb", "title": _("Edit {}").format(ident)}, {"name": "delalias", "url": "{}?selection={}".format( reverse("admin:alias_delete"), objid), "img": "fa fa-trash", "title": _("Delete %s?" % ident.address)}, ] return render_actions(actions)
def calendar_actions(calendar): """Render per-calendar actions.""" actions = [ {"name": "editcalendar", "title": _("Edit %s" % calendar), "modal": True, "img": "fa fa-edit"}, {"name": "delcalendar", "title": _("Delete %s?" % calendar), "img": "fa fa-trash"} ] if calendar.__class__.__name__ == 'UserCalendar': actions[0]["url"] = reverse( "modoboa_radicale:user_calendar", args=[calendar.pk]) actions[0]["modalcb"] = "radicale.edit_calendar_cb" actions[1]["url"] = reverse( "modoboa_radicale:user_calendar", args=[calendar.id]) else: actions[0]["url"] = reverse( "modoboa_radicale:shared_calendar", args=[calendar.pk]) actions[0]["modalcb"] = "radicale.shared_calendar_cb" actions[1]["url"] = reverse( "modoboa_radicale:shared_calendar", args=[calendar.id]) return render_actions(actions)