allowed to change created date

This commit is contained in:
2023-05-29 12:20:29 +02:00
parent 8c0649678e
commit e1f5949c34
5 changed files with 12 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
from wtforms import Form, StringField, TextAreaField, SelectField, RadioField
from wtforms import Form, StringField, TextAreaField, SelectField, DateTimeField
from wtforms import IntegerField, PasswordField
from wtforms.validators import InputRequired, Length, Email
from wtforms.widgets import HiddenInput
@@ -14,10 +14,12 @@ class BlogCreateForm(Form):
author = StringField('Auteur', validators=[InputRequired(), Length(min=1, max=50)],
filters=[strip_filter])
status = SelectField('Statut', choices=[('brouillon','Brouillon'),('privé','Privé'),('publié','Publié')])
created = DateTimeField('Créé le', validators=[InputRequired()])
class BlogUpdateForm(BlogCreateForm):
id = IntegerField(widget=HiddenInput())
created = DateTimeField('Créé le', validators=[InputRequired()])
class BlogSearchForm(Form):
criteria = StringField('Critère', validators=[InputRequired(), Length(min=3, max=45)],

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

View File

@@ -35,12 +35,14 @@
{{ form.status(class_='form-control') }}
</div>
<div class="form-group">
<label class="required-field" for="created">{{ form.created.label }}</label>
{{ form.created(class_='form-control') }}
</div>
<p>
Topic : <strong>{{ entry.topic_id }}</strong><br>
{% if blog_id != '0' %}
Créé le : <strong>{{ entry.created.strftime("%d-%m-%Y - %H:%M") }}</strong>
<button class="btn btn-link" type="submit" name="form.update_created">[ Mettre à jour ]</button>
<br>
Modifié le : <strong>{{ entry.edited.strftime("%d-%m-%Y - %H:%M") }}</strong>
{% endif %}
</p>

View File

@@ -49,6 +49,8 @@ def blog_copy(request):
dup_entry.tag = entry.tag
dup_entry.author = entry.author
dup_entry.status = 'brouillon'
dup_entry.created = datetime.datetime.now()
dup_entry.edited = datetime.datetime.now()
request.dbsession.add(dup_entry)
request.session.flash("La page a été duppliquée avec succès", 'success')
@@ -69,6 +71,7 @@ def blog_edit(request):
# create a new post
entry = BlogRecord()
entry.topic_id = topic
entry.created = datetime.datetime.now()
form = BlogCreateForm(request.POST, entry)
form.tag.choices = [(row.tag, row.tag_name) for row in tags]
page_title = 'Nouvelle page'
@@ -103,12 +106,6 @@ def blog_edit(request):
entry.editor = request.authenticated_userid
return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug))
if 'form.update_created' in request.params and form.validate():
del form.id # SECURITY: prevent overwriting of primary key
form.populate_obj(entry)
entry.created = datetime.datetime.now()
return HTTPFound(location=request.route_url('blog', id=entry.id, slug=entry.slug))
if 'form.deleted' in request.params:
BlogRecordService.delete(request, blog_id)
request.session.flash("La page a été supprimée avec succès.", 'success')

View File

@@ -34,6 +34,7 @@ def home(request):
dir + '/S09.jpg',
dir + '/S12.jpg',
dir + '/S15.jpg',
dir + '/S16.jpg',
dir + '/S18.jpg',
dir + '/S21.jpg',
dir + '/S25.jpg']