added new fields to table entries
This commit is contained in:
Binary file not shown.
@@ -157,10 +157,9 @@ def update_topic(request, topic, new_values):
|
|||||||
s += ",%s=:%s" % (param, param)
|
s += ",%s=:%s" % (param, param)
|
||||||
else:
|
else:
|
||||||
s = "%s=:%s" % (param, param)
|
s = "%s=:%s" % (param, param)
|
||||||
|
|
||||||
if topic == '0':
|
if topic == '0':
|
||||||
query = "INSERT INTO topics (topic, topic_name, topic_quote) VALUES ('{0}', '{1}', '{2}')".format(
|
query = "INSERT INTO topics (topic, topic_name, topic_language, topic_quote) VALUES ('{0}', '{1}', '{2}', '{3}')".format(
|
||||||
topic, new_values['topic_name'], new_values['topic_quote'].replace("'","''"))
|
topic, new_values['topic_name'], new_values['topic_language'], new_values['topic_quote'].replace("'","''"))
|
||||||
else:
|
else:
|
||||||
new_values['topic'] = topic
|
new_values['topic'] = topic
|
||||||
query = "UPDATE topics SET %s WHERE topic = :topic;" % s
|
query = "UPDATE topics SET %s WHERE topic = :topic;" % s
|
||||||
|
|||||||
@@ -16,24 +16,31 @@
|
|||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>{{ entry.author }}</strong> - Publié le <strong>{{ entry.create_date }}</strong><br>
|
||||||
|
</p>
|
||||||
<hr/>
|
<hr/>
|
||||||
<p>{{ body_html | safe }}</p>
|
<p>{{ body_html | safe }}</p>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
|
{% if entry.source_link != '' %}
|
||||||
|
<ul>
|
||||||
|
<li><b>Source</b> : <a href="{{ entry.source_link }}">{{ entry.source_title }}</a> - {{ entry.source_site }}</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% if entry.related %}
|
||||||
|
<ul>
|
||||||
|
<li><b>Contenu corrélé</b> : <a href="{{ request.route_url('blog', id=related.id, slug=related.title) }}">{{ related.title }}</a> - {{ related.author }}</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Auteur : <strong>{{ entry.author }}</strong><br>
|
|
||||||
Publié le : <strong>{{ entry.create_date }}</strong><br>
|
|
||||||
{% if request.authenticated_userid %}
|
{% if request.authenticated_userid %}
|
||||||
Topic - Tag : <strong>{{ entry.topic_id }}</strong> - <strong>{{ entry.tag }}</strong><br>
|
Topic - Tag : <strong>{{ entry.topic_id }}</strong> - <strong>{{ entry.tag }}</strong><br>
|
||||||
Statut : <strong>{{ entry.status }}</strong>
|
Language : <strong>{{ entry.language }}</strong><br>
|
||||||
|
Statut : <strong>{{ entry.status }}</strong><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<script>
|
|
||||||
const anchors = document.querySelectorAll('a');
|
|
||||||
anchors.forEach((a) => {
|
|
||||||
a.setAttribute('target', '__blank');
|
|
||||||
a.setAttribute('rel', 'noopener noreferrer');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,21 @@
|
|||||||
<input class="form-control" name="author" type="text" value="{{entry.author}}" required>
|
<input class="form-control" name="author" type="text" value="{{entry.author}}" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label for="author">Source lien</label>
|
||||||
|
<input class="form-control" name="source_link" type="text" value="{{entry.source_link}}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label for="author">Source titre</label>
|
||||||
|
<input class="form-control" name="source_title" type="text" value="{{entry.source_title}}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label for="author">Contenu corrélé</label>
|
||||||
|
<input class="form-control" name="related" type="text" value="{{entry.related}}">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label required-field" for="status">Statut</label>
|
<label class="form-label required-field" for="status">Statut</label>
|
||||||
<select class="form-control" id="status" name="status" value="{{ entry.status}}">
|
<select class="form-control" id="status" name="status" value="{{ entry.status}}">
|
||||||
@@ -52,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Topic : <strong>{{ entry.topic_id }}</strong><br>
|
Topic : <strong>{{ entry.topic_id }}</strong> - <strong>{{ entry.language }}</strong><br>
|
||||||
{% if blog_id != '0' %}
|
{% if blog_id != '0' %}
|
||||||
Modifié le : <strong>{{ entry.edit_date }}</strong>
|
Modifié le : <strong>{{ entry.edit_date }}</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -16,6 +16,16 @@
|
|||||||
<input class="form-control" name="topic_name" type="text" value="{{entry.topic_name}}" required>
|
<input class="form-control" name="topic_name" type="text" value="{{entry.topic_name}}" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label required-field" for="topic_language">Language</label>
|
||||||
|
<select class="form-control" id="language" name="topic_language" value="{{ entry.topic_language }}">
|
||||||
|
<option value="fr"
|
||||||
|
{% if entry.topic_language == "fr" %} selected {% endif %}>fr</option>
|
||||||
|
<option value="vn"
|
||||||
|
{% if entry.topic_language == "vn" %} selected {% endif %}>vn</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label required-field" for="topic_quote">Citation</label>
|
<label class="form-label required-field" for="topic_quote">Citation</label>
|
||||||
<textarea class="form-control monospace-font" id="topic_quote" name="topic_quote" required rows="10" cols="35">
|
<textarea class="form-control monospace-font" id="topic_quote" name="topic_quote" required rows="10" cols="35">
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Topic</th>
|
<th>Topic</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Langue</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
{{ entry.topic_name }}
|
{{ entry.topic_name }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{ entry.topic_language }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import datetime #<- will be used to set default dates on models
|
|||||||
from ..models.entries import *
|
from ..models.entries import *
|
||||||
from webhelpers2.text import urlify #<- will generate slugs
|
from webhelpers2.text import urlify #<- will generate slugs
|
||||||
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
|
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
||||||
@view_config(route_name='blog', renderer='cao_sunyata:templates/blog.jinja2')
|
@view_config(route_name='blog', renderer='cao_sunyata:templates/blog.jinja2')
|
||||||
@@ -21,10 +22,14 @@ def blog(request):
|
|||||||
body = entry.body.replace('static/', "%s/static/" % request.application_url)
|
body = entry.body.replace('static/', "%s/static/" % request.application_url)
|
||||||
# convertir de markdown en HTML
|
# convertir de markdown en HTML
|
||||||
body_html = markdown.markdown(body, extensions=['footnotes'])
|
body_html = markdown.markdown(body, extensions=['footnotes'])
|
||||||
|
# lire le contenu correle
|
||||||
|
if entry.related != '0':
|
||||||
|
related = get_entries_by_id(request, entry.related)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': entry.title,
|
'page_title': entry.title,
|
||||||
'entry': entry,
|
'entry': entry,
|
||||||
|
'related': related,
|
||||||
'body_html': body_html,
|
'body_html': body_html,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +85,8 @@ def blog_edit(request):
|
|||||||
entry['topic_id'] = topic
|
entry['topic_id'] = topic
|
||||||
entry['tag'] = ''
|
entry['tag'] = ''
|
||||||
entry['author'] = ''
|
entry['author'] = ''
|
||||||
|
entry['source_link'] = ''
|
||||||
|
entry['related'] = '0'
|
||||||
entry['status'] = ''
|
entry['status'] = ''
|
||||||
entry['creator'] = request.authenticated_userid
|
entry['creator'] = request.authenticated_userid
|
||||||
entry['editor'] = ''
|
entry['editor'] = ''
|
||||||
@@ -105,9 +112,26 @@ def blog_edit(request):
|
|||||||
# interdire le car '/' dans le titre à cause du slug
|
# interdire le car '/' dans le titre à cause du slug
|
||||||
new_values['title'] = new_values['title'].replace('/','.')
|
new_values['title'] = new_values['title'].replace('/','.')
|
||||||
elif param == 'body':
|
elif param == 'body':
|
||||||
new_values['body'] = new_values['body'].strip()
|
new_values['body'] = new_values['body'].strip()
|
||||||
|
elif param == 'source_link':
|
||||||
# import pdb;pdb.set_trace()
|
# controles du champ 'source_link'
|
||||||
|
src_link = new_values['source_link']
|
||||||
|
if src_link != '':
|
||||||
|
if src_link[:4] != 'http':
|
||||||
|
request.session.flash("Le lien dans Source est invalide !", 'danger')
|
||||||
|
return HTTPFound(location=url_retour)
|
||||||
|
# get the domain from 'source_link'
|
||||||
|
new_values['source_site'] = urlparse(src_link).netloc
|
||||||
|
elif param == 'related':
|
||||||
|
# lire le contenu correle
|
||||||
|
if new_values['related'] != '0':
|
||||||
|
related = get_entries_by_id(request, new_values['related'])
|
||||||
|
if not related:
|
||||||
|
request.session.flash("Le contenu corrélé est invalide !", 'danger')
|
||||||
|
return HTTPFound(location=url_retour)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if new_values:
|
if new_values:
|
||||||
new_values['topic_id'] = topic
|
new_values['topic_id'] = topic
|
||||||
new_values['editor'] = request.authenticated_userid
|
new_values['editor'] = request.authenticated_userid
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ def topic_edit(request):
|
|||||||
entry = {}
|
entry = {}
|
||||||
entry['topic'] = ''
|
entry['topic'] = ''
|
||||||
entry['topic_name'] = ''
|
entry['topic_name'] = ''
|
||||||
|
entry['topic_language'] = ''
|
||||||
entry['topic_quote'] = ''
|
entry['topic_quote'] = ''
|
||||||
page_title = "Nouveau topic"
|
page_title = "Nouveau topic"
|
||||||
else:
|
else:
|
||||||
@@ -309,6 +310,7 @@ def topic_edit(request):
|
|||||||
if param in request.params and request.params[param] != entry[param]:
|
if param in request.params and request.params[param] != entry[param]:
|
||||||
new_values[param] = request.params[param]
|
new_values[param] = request.params[param]
|
||||||
|
|
||||||
|
# import pdb;pdb.set_trace()
|
||||||
if new_values:
|
if new_values:
|
||||||
update_topic(request, topic, new_values)
|
update_topic(request, topic, new_values)
|
||||||
request.session.flash(u"La fiche a été mise à jour avec succès.", 'success')
|
request.session.flash(u"La fiche a été mise à jour avec succès.", 'success')
|
||||||
|
|||||||
Reference in New Issue
Block a user