Add create and update date to lists

master
Pierre Jaury 9 years ago
parent 99cf0b2031
commit 949df33831

@ -2,6 +2,7 @@ from freeposte import db
from sqlalchemy.ext import declarative from sqlalchemy.ext import declarative
from passlib import context from passlib import context
from datetime import datetime
# Many-to-many association table for domain administrators # Many-to-many association table for domain administrators
@ -16,7 +17,17 @@ admins = db.Table('admin',
) )
class Domain(db.Model): class Base(db.Model):
""" Base class for all models
"""
__abstract__ = True
created_at = db.Column(db.Date, nullable=False, default=datetime.now)
updated_at = db.Column(db.Date, nullable=True, onupdate=datetime.now)
class Domain(Base):
""" A DNS domain that has mail addresses associated to it. """ A DNS domain that has mail addresses associated to it.
""" """
name = db.Column(db.String(80), primary_key=True, nullable=False) name = db.Column(db.String(80), primary_key=True, nullable=False)
@ -29,7 +40,7 @@ class Domain(db.Model):
return self.name return self.name
class Address(db.Model): class Address(Base):
""" Abstraction for a mail address (localpart and domain). """ Abstraction for a mail address (localpart and domain).
""" """
__abstract__ = True __abstract__ = True

@ -19,6 +19,8 @@ Alias list
<th>Actions</th> <th>Actions</th>
<th>Address</th> <th>Address</th>
<th>Destination</th> <th>Destination</th>
<th>Created</th>
<th>Last edit</th>
</tr> </tr>
{% for alias in domain.aliases %} {% for alias in domain.aliases %}
<tr> <tr>
@ -28,6 +30,8 @@ Alias list
</td> </td>
<td>{{ alias }}</td> <td>{{ alias }}</td>
<td>{{ alias.destination or '-' }}</td> <td>{{ alias.destination or '-' }}</td>
<td>{{ alias.created_at }}</td>
<td>{{ alias.updated_at or '' }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

@ -18,6 +18,8 @@ Domain list
<th>Domain name</th> <th>Domain name</th>
<th>Mailbox count</th> <th>Mailbox count</th>
<th>Alias count</th> <th>Alias count</th>
<th>Created</th>
<th>Last edit</th>
</tr> </tr>
{% for domain in current_user.get_managed_domains() %} {% for domain in current_user.get_managed_domains() %}
<tr> <tr>
@ -31,6 +33,8 @@ Domain list
<td>{{ domain.name }}</td> <td>{{ domain.name }}</td>
<td>{{ domain.users | count }} / {{ domain.max_users or '∞' }}</td> <td>{{ domain.users | count }} / {{ domain.max_users or '∞' }}</td>
<td>{{ domain.aliases | count }} / {{ domain.max_aliases or '∞' }}</td> <td>{{ domain.aliases | count }} / {{ domain.max_aliases or '∞' }}</td>
<td>{{ domain.created_at }}</td>
<td>{{ domain.updated_at or '' }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

@ -18,8 +18,12 @@ User list
<tr> <tr>
<th>Actions</th> <th>Actions</th>
<th>Address</th> <th>Address</th>
<th>Name</th>
<th>Forward</th> <th>Forward</th>
<th>Reply</th>
<th>Quota</th> <th>Quota</th>
<th>Created</th>
<th>Last edit</th>
</tr> </tr>
{% for user in domain.users %} {% for user in domain.users %}
<tr> <tr>
@ -33,8 +37,12 @@ User list
<a href="{{ url_for('user_delete', user_email=user.get_id()) }}" title="Delete"><i class="fa fa-trash"></i></a> <a href="{{ url_for('user_delete', user_email=user.get_id()) }}" title="Delete"><i class="fa fa-trash"></i></a>
</td> </td>
<td>{{ user }}</td> <td>{{ user }}</td>
<td>{{ user.forward or '-' }}</td> <td>{{ user.displayed_name }}</td>
<td>{% if user.forward %}<span class="label label-info">enabled</span>{% endif %}</td>
<td>{% if user.reply_subject %}<span class="label label-info">enabled</span>{% endif %}</td>
<td>{{ user.quota_bytes | filesizeformat }}</td> <td>{{ user.quota_bytes | filesizeformat }}</td>
<td>{{ user.created_at }}</td>
<td>{{ user.updated_at or '' }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

Loading…
Cancel
Save