ajout des tags dans doc
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user