diff --git a/bin/packages/Tag.py b/bin/packages/Tag.py index 6b95da7e..fde6545b 100755 --- a/bin/packages/Tag.py +++ b/bin/packages/Tag.py @@ -64,6 +64,12 @@ def get_active_taxonomies(): def get_active_galaxies(): return r_serv_tags.smembers('active_galaxies') +def get_all_taxonomies_tags(): # # TODO: add + REMOVE + Update + return r_serv_tags.smembers('active_taxonomies_tags') + +def get_all_galaxies_tags(): # # TODO: add + REMOVE + Update + return r_serv_tags.smembers('active_galaxies_tags') + def is_taxonomie_tag_enabled(taxonomie, tag): if tag in r_serv_tags.smembers('active_tag_' + taxonomie): return True @@ -94,6 +100,7 @@ def enable_taxonomy(taxonomie, enable_tags=True): # activate taxonomie tags for tag in taxonomie_info.machinetags(): r_serv_tags.sadd('active_tag_{}'.format(taxonomie), tag) + #r_serv_tags.sadd('active_taxonomies_tags', tag) else: print('Error: {}, please update pytaxonomies'.format(taxonomie)) diff --git a/var/www/blueprints/tags_ui.py b/var/www/blueprints/tags_ui.py index 05d9313b..06b27a62 100644 --- a/var/www/blueprints/tags_ui.py +++ b/var/www/blueprints/tags_ui.py @@ -43,28 +43,6 @@ tags_ui = Blueprint('tags_ui', __name__, template_folder=os.path.join(os.environ # ============= ROUTES ============== -# @Tags.route("/Tags/addTags") # REVIEW: # used in showPaste -# @login_required -# @login_analyst -# def addTags(): -# -# tags = request.args.get('tags') -# tagsgalaxies = request.args.get('tagsgalaxies') -# path = request.args.get('path') -# -# list_tag = tags.split(',') -# list_tag_galaxies = tagsgalaxies.split(',') -# -# res = Tag.add_items_tags(list_tag, list_tag_galaxies, item_id=path) -# print(res) -# # error -# if res[1] != 200: -# return str(res[0]) -# # success -# return redirect(url_for('showsavedpastes.showsavedpaste', paste=path)) - - - @tags_ui.route('/tag/add_tags') @login_required @login_analyst @@ -72,8 +50,8 @@ def add_tags(): tags = request.args.get('tags') tagsgalaxies = request.args.get('tagsgalaxies') - object_id = request.args.get('object_id') # old: item_id - object_type = request.args.get('object_type') # old type + object_id = request.args.get('object_id') + object_type = request.args.get('object_type') list_tag = tags.split(',') list_tag_galaxies = tagsgalaxies.split(',') @@ -85,7 +63,19 @@ def add_tags(): return redirect(Correlate_object.get_item_url(object_type, object_id)) +@tags_ui.route('/tag/delete_tag') +@login_required +@login_analyst +def delete_tag(): + object_type = request.args.get('object_type') + object_id = request.args.get('object_id') + tag = request.args.get('tag') + + res = Tag.api_delete_obj_tags(tags=[tag], object_id=object_id, object_type=object_type) + if res[1] != 200: + return str(res[0]) + return redirect(Correlate_object.get_item_url(object_type, object_id)) # # add route : /crawlers/show_domain # @tags_ui.route('/tags/search/domain') diff --git a/var/www/modules/Tags/Flask_Tags.py b/var/www/modules/Tags/Flask_Tags.py index f2bb6101..d2252877 100644 --- a/var/www/modules/Tags/Flask_Tags.py +++ b/var/www/modules/Tags/Flask_Tags.py @@ -369,9 +369,8 @@ def get_tags_galaxy(): @Tags.route("/Tags/remove_tag") @login_required @login_analyst -def remove_tag(): +def remove_tag(): #TODO remove me , used by showpaste - #TODO verify input path = request.args.get('paste') tag = request.args.get('tag') diff --git a/var/www/templates/crawler/crawler_splash/showDomain.html b/var/www/templates/crawler/crawler_splash/showDomain.html index 0026cb25..80912dcc 100644 --- a/var/www/templates/crawler/crawler_splash/showDomain.html +++ b/var/www/templates/crawler/crawler_splash/showDomain.html @@ -79,10 +79,13 @@
+ {% include 'modals/edit_tag.html' %} {% for tag in dict_domain['tags'] %} - - {{ tag }} - + + {% endfor %}
{% include 'modals/add_tags.html' %} diff --git a/var/www/templates/modals/edit_tag.html b/var/www/templates/modals/edit_tag.html new file mode 100644 index 00000000..c7455631 --- /dev/null +++ b/var/www/templates/modals/edit_tag.html @@ -0,0 +1,49 @@ + + +