mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-25 07:47:05 +00:00
Calculate and display mailbox sizes in user list
This commit is contained in:
parent
c5c7de8b2b
commit
f68ef70b94
@ -132,10 +132,27 @@ def get_mail_users_ex(env, with_archived=False):
|
|||||||
for email, privileges, quota in c.fetchall():
|
for email, privileges, quota in c.fetchall():
|
||||||
active_accounts.add(email)
|
active_accounts.add(email)
|
||||||
|
|
||||||
|
(user, domain) = email.split('@')
|
||||||
|
box_size = 0
|
||||||
|
box_count = 0
|
||||||
|
box_quota = ''
|
||||||
|
try:
|
||||||
|
with open('/home/user-data/mail/mailboxes/%s/%s/maildirsize' % (domain, user), 'r') as f:
|
||||||
|
box_quota = f.readline()
|
||||||
|
for line in f.readlines():
|
||||||
|
(size, count) = line.split(' ')
|
||||||
|
box_size += int(size)
|
||||||
|
box_count += int(count)
|
||||||
|
except:
|
||||||
|
box_size = '?'
|
||||||
|
|
||||||
user = {
|
user = {
|
||||||
"email": email,
|
"email": email,
|
||||||
"privileges": parse_privs(privileges),
|
"privileges": parse_privs(privileges),
|
||||||
"quota": quota,
|
"quota": quota,
|
||||||
|
"box_quota": box_quota,
|
||||||
|
"box_size": '%iK' % int(box_size / 1024),
|
||||||
|
"box_count": box_count,
|
||||||
"status": "active",
|
"status": "active",
|
||||||
}
|
}
|
||||||
users.append(user)
|
users.append(user)
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="35%">Email Address</th>
|
<th width="35%">Email Address</th>
|
||||||
|
<th>Box Size</th>
|
||||||
<th>Quota</th>
|
<th>Quota</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -55,6 +56,7 @@
|
|||||||
<tr id="user-template">
|
<tr id="user-template">
|
||||||
<td class='address'>
|
<td class='address'>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="box-size"></td>
|
||||||
<td class="quota">
|
<td class="quota">
|
||||||
</td>
|
</td>
|
||||||
<td class='actions'>
|
<td class='actions'>
|
||||||
@ -161,6 +163,7 @@ function show_users() {
|
|||||||
n.attr('data-email', user.email);
|
n.attr('data-email', user.email);
|
||||||
n.attr('data-quota', user.quota);
|
n.attr('data-quota', user.quota);
|
||||||
n.find('.address').text(user.email);
|
n.find('.address').text(user.email);
|
||||||
|
n.find('.box-size').text(user.box_size);
|
||||||
n.find('.quota').text((user.quota == '0') ? 'unlimited' : user.quota);
|
n.find('.quota').text((user.quota == '0') ? 'unlimited' : user.quota);
|
||||||
n2.find('.restore_info tt').text(user.mailbox);
|
n2.find('.restore_info tt').text(user.mailbox);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user