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)
|
||||
else:
|
||||
s = "%s=:%s" % (param, param)
|
||||
|
||||
if topic == '0':
|
||||
query = "INSERT INTO topics (topic, topic_name, topic_quote) VALUES ('{0}', '{1}', '{2}')".format(
|
||||
topic, new_values['topic_name'], new_values['topic_quote'].replace("'","''"))
|
||||
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_language'], new_values['topic_quote'].replace("'","''"))
|
||||
else:
|
||||
new_values['topic'] = topic
|
||||
query = "UPDATE topics SET %s WHERE topic = :topic;" % s
|
||||
|
||||
@@ -16,24 +16,31 @@
|
||||
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<strong>{{ entry.author }}</strong> - Publié le <strong>{{ entry.create_date }}</strong><br>
|
||||
</p>
|
||||
<hr/>
|
||||
<p>{{ body_html | safe }}</p>
|
||||
<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>
|
||||
Auteur : <strong>{{ entry.author }}</strong><br>
|
||||
Publié le : <strong>{{ entry.create_date }}</strong><br>
|
||||
{% if request.authenticated_userid %}
|
||||
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 %}
|
||||
</p>
|
||||
<script>
|
||||
const anchors = document.querySelectorAll('a');
|
||||
anchors.forEach((a) => {
|
||||
a.setAttribute('target', '__blank');
|
||||
a.setAttribute('rel', 'noopener noreferrer');
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,6 +34,21 @@
|
||||
<input class="form-control" name="author" type="text" value="{{entry.author}}" required>
|
||||
</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">
|
||||
<label class="form-label required-field" for="status">Statut</label>
|
||||
<select class="form-control" id="status" name="status" value="{{ entry.status}}">
|
||||
@@ -52,7 +67,7 @@
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Topic : <strong>{{ entry.topic_id }}</strong><br>
|
||||
Topic : <strong>{{ entry.topic_id }}</strong> - <strong>{{ entry.language }}</strong><br>
|
||||
{% if blog_id != '0' %}
|
||||
Modifié le : <strong>{{ entry.edit_date }}</strong>
|
||||
{% endif %}
|
||||
|
||||
@@ -16,6 +16,16 @@
|
||||
<input class="form-control" name="topic_name" type="text" value="{{entry.topic_name}}" required>
|
||||
</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">
|
||||
<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">
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<tr>
|
||||
<th>Topic</th>
|
||||
<th>Name</th>
|
||||
<th>Langue</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@@ -27,6 +28,7 @@
|
||||
{{ entry.topic_name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ entry.topic_language }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@@ -6,6 +6,7 @@ import datetime #<- will be used to set default dates on models
|
||||
from ..models.entries import *
|
||||
from webhelpers2.text import urlify #<- will generate slugs
|
||||
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')
|
||||
@@ -21,10 +22,14 @@ def blog(request):
|
||||
body = entry.body.replace('static/', "%s/static/" % request.application_url)
|
||||
# convertir de markdown en HTML
|
||||
body_html = markdown.markdown(body, extensions=['footnotes'])
|
||||
# lire le contenu correle
|
||||
if entry.related != '0':
|
||||
related = get_entries_by_id(request, entry.related)
|
||||
|
||||
return {
|
||||
'page_title': entry.title,
|
||||
'entry': entry,
|
||||
'related': related,
|
||||
'body_html': body_html,
|
||||
}
|
||||
|
||||
@@ -80,6 +85,8 @@ def blog_edit(request):
|
||||
entry['topic_id'] = topic
|
||||
entry['tag'] = ''
|
||||
entry['author'] = ''
|
||||
entry['source_link'] = ''
|
||||
entry['related'] = '0'
|
||||
entry['status'] = ''
|
||||
entry['creator'] = request.authenticated_userid
|
||||
entry['editor'] = ''
|
||||
@@ -106,8 +113,25 @@ def blog_edit(request):
|
||||
new_values['title'] = new_values['title'].replace('/','.')
|
||||
elif param == 'body':
|
||||
new_values['body'] = new_values['body'].strip()
|
||||
elif param == 'source_link':
|
||||
# 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)
|
||||
|
||||
|
||||
|
||||
# import pdb;pdb.set_trace()
|
||||
if new_values:
|
||||
new_values['topic_id'] = topic
|
||||
new_values['editor'] = request.authenticated_userid
|
||||
|
||||
@@ -293,6 +293,7 @@ def topic_edit(request):
|
||||
entry = {}
|
||||
entry['topic'] = ''
|
||||
entry['topic_name'] = ''
|
||||
entry['topic_language'] = ''
|
||||
entry['topic_quote'] = ''
|
||||
page_title = "Nouveau topic"
|
||||
else:
|
||||
@@ -309,6 +310,7 @@ def topic_edit(request):
|
||||
if param in request.params and request.params[param] != entry[param]:
|
||||
new_values[param] = request.params[param]
|
||||
|
||||
# import pdb;pdb.set_trace()
|
||||
if new_values:
|
||||
update_topic(request, topic, new_values)
|
||||
request.session.flash(u"La fiche a été mise à jour avec succès.", 'success')
|
||||
|
||||
Reference in New Issue
Block a user