added creator and editor to entries

This commit is contained in:
2022-09-29 17:18:55 +02:00
parent 5e83c7258b
commit f61e5ef81f
5 changed files with 41 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
"""init
Revision ID: 91bc91a0dfc5
Revises: 6da5ee6785ff
Create Date: 2022-09-29 13:47:36.479683
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '91bc91a0dfc5'
down_revision = '6da5ee6785ff'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('entries', sa.Column('creator', sa.Unicode(length=50), nullable=True))
op.add_column('entries', sa.Column('editor', sa.Unicode(length=50), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('entries', 'editor')
op.drop_column('entries', 'creator')
# ### end Alembic commands ###

View File

@@ -21,7 +21,9 @@ class BlogRecord(Base):
title = Column(Unicode(255), unique=True, nullable=False)
body = Column(UnicodeText, default='')
created = Column(DateTime, default=datetime.datetime.now)
creator = Column(Unicode(50), default='')
edited = Column(DateTime, default=datetime.datetime.now)
editor = Column(Unicode(50), default='')
topic_id = Column(ForeignKey('topics.topic'), nullable=False)
topic = relationship('Topics', backref='topic_pages')
tag = Column(Unicode(25))

View File

@@ -165,7 +165,6 @@
<b>Méditation Sunyata Paris</b><br>
116 bd Maréchal Foch<br>
93160 NOISY LE GRAND<br>
<br>
<span class="label label-danger">RER A</span>&nbsp;station Bry sur Marne<br>
<span class="label label-primary">Bus 220</span>&nbsp;arrêt Verdun<br>
</div>

View File

@@ -40,18 +40,17 @@
<table id="users_list" class="table table-condensed">
{% for entry in items %}
<tr>
<td>{{ entry.tag }}</td>
<td>{{ entry.edited.strftime("%d-%m-%Y") }}</td>
<td>{{ entry.editor }}</td>
<td>
<a href="{{ request.route_url('blog', id=entry.id, slug=entry.slug) }}">{{ entry.title }}</a>
</td>
<td>{{ entry.author }}</td>
<td>{{ entry.edited.strftime("%d-%m-%Y") }}</td>
{% if entry.status == 'brouillon' %}
<td><span class="label label-danger">{{ entry.status }}</span></td>
{% else %}
<td> </td>
{% endif %}
</td>
<td>{{ entry.tag }}</td>
{% if entry.status == 'brouillon' %}
<td><span class="label label-danger">{{ entry.status }}</span></td>
{% else %}
<td> </td>
{% endif %}
</tr>
{% endfor %}
</table>

View File

@@ -93,7 +93,8 @@ def blog_edit(request):
if blog_id == '0':
form.populate_obj(entry)
entry.topic_id = topic
entry.creator = request.authenticated_userid
entry.editor = entry.creator
request.dbsession.add(entry)
return HTTPFound(location=request.route_url('topic', topic=topic))
@@ -101,6 +102,7 @@ def blog_edit(request):
del form.id # SECURITY: prevent overwriting of primary key
form.populate_obj(entry)
entry.edited = datetime.datetime.now()
entry.editor = request.authenticated_userid
return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug))
if 'form.deleted' in request.params: