added change in doc's tags
This commit is contained in:
@@ -39,9 +39,14 @@ def get_docs_bytopic(request, topic, logged_in):
|
|||||||
results = request.dbsession.execute(query, {'topic': topic}).fetchall()
|
results = request.dbsession.execute(query, {'topic': topic}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_d_tags(request):
|
def get_docs_tags(request, doc_id):
|
||||||
query = "SELECT * FROM d_tags;"
|
query = "SELECT * FROM docs_tags WHERE doc_id=:doc_id;"
|
||||||
results = request.dbsession.execute(query).fetchall()
|
results = request.dbsession.execute(query, {'doc_id': doc_id}).fetchall()
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_d_tags(request, topic):
|
||||||
|
query = "SELECT * FROM d_tags WHERE topic=:topic;"
|
||||||
|
results = request.dbsession.execute(query, {'topic': topic}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_d_topics(request, logged_in):
|
def get_d_topics(request, logged_in):
|
||||||
@@ -82,3 +87,13 @@ def delete_doc(request, doc_id):
|
|||||||
query = "delete from docs where doc_id = :doc_id;"
|
query = "delete from docs where doc_id = :doc_id;"
|
||||||
execute_query(request, query, {'doc_id': doc_id})
|
execute_query(request, query, {'doc_id': doc_id})
|
||||||
|
|
||||||
|
def change_doc_tag(request, action, doc_id, tag):
|
||||||
|
"""ajouter une tag dans le doc"""
|
||||||
|
if action == 'ADD':
|
||||||
|
query = "INSERT INTO docs_tags (`doc_id`,`tag`) VALUES (:doc_id, :tag);"
|
||||||
|
execute_query(request, query, {'doc_id': doc_id, 'tag': tag})
|
||||||
|
else:
|
||||||
|
query = "DELETE FROM docs_tags WHERE doc_id=:doc_id AND tag=:tag;"
|
||||||
|
execute_query(request, query, {'doc_id': doc_id, 'tag': tag})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ def includeme(config):
|
|||||||
config.add_route('doc_edit', '/doc_edit/{topic}/{doc_id}')
|
config.add_route('doc_edit', '/doc_edit/{topic}/{doc_id}')
|
||||||
config.add_route('doc_view', '/doc_view/{doc_id}')
|
config.add_route('doc_view', '/doc_view/{doc_id}')
|
||||||
config.add_route('doc_search', '/doc_search')
|
config.add_route('doc_search', '/doc_search')
|
||||||
|
config.add_route('tag_change', '/tag_change/{action}/{topic}/{doc_id}/{tag}')
|
||||||
# portfolio
|
# portfolio
|
||||||
config.add_route('actif_edit', '/actif_edit/{no_id}')
|
config.add_route('actif_edit', '/actif_edit/{no_id}')
|
||||||
config.add_route('actif2_edit', '/actif2_edit/{no_id}')
|
config.add_route('actif2_edit', '/actif2_edit/{no_id}')
|
||||||
|
|||||||
@@ -24,22 +24,6 @@
|
|||||||
<textarea class="form-control monospace-font" rows="15" cols="40" id="texte" name="texte">${doc.texte}</textarea>
|
<textarea class="form-control monospace-font" rows="15" cols="40" id="texte" name="texte">${doc.texte}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label col-xs-2" for="tag1">Tag 1</label>
|
|
||||||
<div class="col-xs-6">
|
|
||||||
<select class="form-control" id="tag1" name="tag1">
|
|
||||||
<div tal:repeat="item tags">
|
|
||||||
<option value="${item.tag}" tal:attributes="selected doc.tag1==item.tag and 'selected' or None">${item.tag}</option>
|
|
||||||
</div>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label col-xs-2" for="tag2">Tag 2</label>
|
|
||||||
<div class="col-xs-6">
|
|
||||||
<input type="text" class="form-control" name="tag2" value="${doc.tag2}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2" for="tag2">Statut</label>
|
<label class="control-label col-xs-2" for="tag2">Statut</label>
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
@@ -68,6 +52,28 @@
|
|||||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br />
|
||||||
|
<h3>Tags</h3>
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<tbody>
|
||||||
|
<tr tal:repeat="ligne tags">
|
||||||
|
<td>${ligne.tag}</td>
|
||||||
|
<td><a href="/tag_change/DEL/${doc.topic}/${ligne.doc_id}/${ligne.tag}">[ supprimer ]</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<tbody>
|
||||||
|
<tr tal:repeat="ligne d_tags">
|
||||||
|
<td>${ligne.tag}</td>
|
||||||
|
<td><a href="/tag_change/ADD/${doc.topic}/${doc.doc_id}/${ligne.tag}">[ ajouter ]</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def doc_edit(request):
|
|||||||
return HTTPFound(location=request.route_url('home'))
|
return HTTPFound(location=request.route_url('home'))
|
||||||
|
|
||||||
message = ""
|
message = ""
|
||||||
tags = get_d_tags(request)
|
|
||||||
statuts = ['private', 'public']
|
statuts = ['private', 'public']
|
||||||
|
|
||||||
if doc_id == '0':
|
if doc_id == '0':
|
||||||
@@ -56,10 +56,14 @@ def doc_edit(request):
|
|||||||
doc['tag1'] = ''
|
doc['tag1'] = ''
|
||||||
doc['tag2'] = ''
|
doc['tag2'] = ''
|
||||||
doc['statut'] = 'private'
|
doc['statut'] = 'private'
|
||||||
|
tags = {}
|
||||||
else:
|
else:
|
||||||
titre = "Modifier : %s" % str(doc_id)
|
titre = "Modifier : %s" % str(doc_id)
|
||||||
doc = get_docs(request, doc_id)
|
doc = get_docs(request, doc_id)
|
||||||
|
tags = get_docs_tags(request, doc.doc_id)
|
||||||
|
|
||||||
|
d_tags = get_d_tags(request, topic)
|
||||||
|
|
||||||
if 'form.submitted' in request.params:
|
if 'form.submitted' in request.params:
|
||||||
new_values = {}
|
new_values = {}
|
||||||
for param, db_value in doc.items():
|
for param, db_value in doc.items():
|
||||||
@@ -88,6 +92,7 @@ def doc_edit(request):
|
|||||||
'doc': doc,
|
'doc': doc,
|
||||||
'topic': topic,
|
'topic': topic,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
|
'd_tags': d_tags,
|
||||||
'statuts': statuts,
|
'statuts': statuts,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,3 +152,16 @@ def doc_view(request):
|
|||||||
'tags': tags,
|
'tags': tags,
|
||||||
'url_retour':url_retour,
|
'url_retour':url_retour,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@view_config(route_name='tag_change')
|
||||||
|
def tag_change(request):
|
||||||
|
|
||||||
|
logged_in = request.authenticated_userid
|
||||||
|
action = request.matchdict['action']
|
||||||
|
topic = request.matchdict['topic']
|
||||||
|
doc_id = request.matchdict['doc_id']
|
||||||
|
tag = request.matchdict['tag']
|
||||||
|
|
||||||
|
change_doc_tag(request, action, doc_id, tag)
|
||||||
|
|
||||||
|
return HTTPFound(location=request.route_url('doc_edit', topic=topic, doc_id=doc_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user