mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
End of ticket #14
This commit is contained in:
@@ -294,7 +294,17 @@ def process(request):
|
||||
def search(request):
|
||||
if not request.GET.has_key("pattern"):
|
||||
return
|
||||
filter = "&msgs.from_addr LIKE '%%%s%%'" % request.GET["pattern"]
|
||||
if request.GET.has_key("criteria"):
|
||||
criteria = request.GET["criteria"].split(',')
|
||||
else:
|
||||
criteria = ["from_addr"]
|
||||
filter = ""
|
||||
pattern = re.escape(request.GET["pattern"])
|
||||
for c in criteria:
|
||||
if filter != "":
|
||||
filter += " OR "
|
||||
filter += "msgs.%s LIKE '%%%s%%'" % (c, pattern)
|
||||
filter = "&(%s)" % filter
|
||||
cursor = lookup(filter)
|
||||
ctx = {"status" : "ok", "content" : render_listing(request, cursor)}
|
||||
return HttpResponse(simplejson.dumps(ctx),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% load i18n %}
|
||||
{% load amextras %}
|
||||
{% block html_head %}
|
||||
<script src="/static/js/mootools-more.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/static/stylesheets/box.css" />
|
||||
<style type="text/css">
|
||||
form {
|
||||
@@ -45,6 +46,17 @@ td {
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#searchbox img {
|
||||
float: left;
|
||||
margin-top: 4px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#searchparams {
|
||||
background: white;
|
||||
padding: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -104,9 +116,13 @@ window.addEvent("domready", function() {
|
||||
|
||||
{% url extensions.amavis_quarantine.main.search as s_url %}
|
||||
$("searchfield").addEvent("change", function(event) {
|
||||
var criteria = "";
|
||||
$$("input[name=scriteria]:checked").each(function(obj) {
|
||||
criteria = obj.value;
|
||||
});
|
||||
new Request.JSON({url: "{{ s_url }}", onSuccess: function(resp) {
|
||||
$("listing").set("html", resp.content);
|
||||
}}).get({"pattern" : $("searchfield").value});
|
||||
}}).get({"pattern" : $("searchfield").value, "criteria" : criteria});
|
||||
});
|
||||
|
||||
$("searchfield").addEvent("click", function(event) {
|
||||
@@ -118,6 +134,16 @@ window.addEvent("domready", function() {
|
||||
$("searchfield").set("value", "{% trans "Search..." %}");
|
||||
}
|
||||
});
|
||||
|
||||
var myFx = new Fx.Slide($("searchparams")).hide();
|
||||
$("searchopts").addEvent("click", function(event) {
|
||||
myFx.cancel();
|
||||
myFx.toggle();
|
||||
});
|
||||
$$("input[name=scriteria]").addEvent("click", function(event) {
|
||||
myFx.cancel();
|
||||
myFx.toggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -132,15 +158,23 @@ window.addEvent("domready", function() {
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="searchbox">
|
||||
<input type="text" name="searchfield" id="searchfield" value="{% trans "Search..." %}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="menubar" class="menu2">
|
||||
{% quar_menu "" perms %}
|
||||
|
||||
<div id="searchbox">
|
||||
<img src="/static/pics/search.png" id="searchopts" />
|
||||
<input type="text" name="searchfield" id="searchfield" value="{% trans "Search..." %}" />
|
||||
<div id="searchparams">
|
||||
<input type="radio" name="scriteria" value="from_addr" checked>{% trans "From address" %}<br/>
|
||||
<input type="radio" name="scriteria" value="subject">{% trans "Subject" %}<br/>
|
||||
<input type="radio" name="scriteria" value="from_addr,subject">{% trans "Both" %}<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="form-container">
|
||||
{% url extensions.amavis_quarantine.main.process as actionurl %}
|
||||
<form method="POST" action="{{ actionurl }}" id="quarlistingform">
|
||||
<input type="hidden" name="pagenum" id="pagenum" value="{{ current_page }}" />
|
||||
@@ -149,4 +183,5 @@ window.addEvent("domready", function() {
|
||||
{{ content }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 935 B |
@@ -136,14 +136,18 @@ body {
|
||||
}
|
||||
|
||||
#content2 {
|
||||
|
||||
|
||||
}
|
||||
|
||||
#menubar {
|
||||
margin-left: 20px;
|
||||
display: table;
|
||||
margin-bottom: 15px;
|
||||
width: 730px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#form-container {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
||||
#menu2 {
|
||||
|
||||
Reference in New Issue
Block a user