diff --git a/caotek_mesavoirs/templates/doc_view.pt b/caotek_mesavoirs/templates/doc_view.pt
index b105550..8563b82 100644
--- a/caotek_mesavoirs/templates/doc_view.pt
+++ b/caotek_mesavoirs/templates/doc_view.pt
@@ -10,7 +10,9 @@
Page text goes here.
- Dernière modification le ${modif_le}
+ Dernière modification le ${modif_le}
+ Tags : ${tags}
+
diff --git a/caotek_mesavoirs/views/default.py b/caotek_mesavoirs/views/default.py
index d281ec1..1160045 100644
--- a/caotek_mesavoirs/views/default.py
+++ b/caotek_mesavoirs/views/default.py
@@ -103,32 +103,33 @@ def doc_edit(request):
message = ""
themes = get_docs_themes(request)
+ tags = get_docs_tags(request)
if doc_id == '0':
titre = "Nouveau doc"
- intitule = ""
- texte = ""
- theme = ""
+ # nouveau
+ doc = {}
+ doc['intitule'] = ''
+ doc['texte'] = ''
+ doc['theme'] = ''
+ doc['tag1'] = ''
+ doc['tag2'] = ''
else:
titre = "Modifier : %s" % str(doc_id)
doc = get_docs(request, doc_id)
- intitule = doc.intitule
- texte = doc.texte
- theme = doc.theme
if 'form.submitted' in request.params:
- intitule = request.params["intitule"]
- texte = request.params["texte"]
- theme = request.params["theme"]
-
- if len(intitule) > 0 and len(texte) > 0:
+ new_values = {}
+ for param, db_value in doc.items():
+ if param in request.params and request.params[param] != db_value:
+ new_values[param] = request.params[param]
+
+ if new_values:
update_doc(request, doc_id, intitule, texte, theme)
if doc_id != '0':
return HTTPFound(location=request.route_url('doc_view', doc_id=doc_id))
else:
return HTTPFound(location=request.route_url('archives',theme=theme))
- else:
- message = "Veuillez saisir un intitule et un texte."
if 'form.deleted' in request.params:
if doc_id != '0':
@@ -141,10 +142,9 @@ def doc_edit(request):
'url': url,
'message': message,
'doc_id': doc_id,
- 'intitule': intitule,
- 'texte': texte,
- 'theme': theme,
+ 'doc': doc,
'themes': themes,
+ 'tags': tags,
}
@view_config(route_name='doc_search', renderer='../templates/doc_search.pt')
@@ -184,8 +184,10 @@ def doc_view(request):
# si anonyme, interdire de voir les memo
return HTTPFound(location=request.route_url('home'))
- intitule = doc.intitule
url_retour = request.route_url('archives',theme=doc.theme)
+ tags = doc.tag1
+ if doc.tag2:
+ tags += ', ' + doc.tag2
# insèrer le path de static/img
texte = doc.texte.replace('static/img/', "%s/static/img/" % request.application_url)
@@ -199,10 +201,11 @@ def doc_view(request):
texte = markdowner.convert(texte)
return {
- 'page_title': intitule,
+ 'page_title': doc.intitule,
+ 'doc_id': doc_id,
'texte': texte,
'modif_le': doc.modif_le.strftime('%d/%m/%Y'),
- 'doc_id': doc_id,
+ 'tags': tags,
'url_retour':url_retour
}