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 passlib import context
from datetime import datetime
# 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.
"""
name = db.Column(db.String(80), primary_key=True, nullable=False)
@ -29,7 +40,7 @@ class Domain(db.Model):
return self.name
class Address(db.Model):
class Address(Base):
""" Abstraction for a mail address (localpart and domain).
"""
__abstract__ = True

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

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

@ -18,8 +18,12 @@ User list
<tr>
<th>Actions</th>
<th>Address</th>
<th>Name</th>
<th>Forward</th>
<th>Reply</th>
<th>Quota</th>
<th>Created</th>
<th>Last edit</th>
</tr>
{% for user in domain.users %}
<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>
</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.created_at }}</td>
<td>{{ user.updated_at or '' }}</td>
</tr>
{% endfor %}
</tbody>

Loading…
Cancel
Save