From c260455d1422c096c382fe0e25672a30f32f29a8 Mon Sep 17 00:00:00 2001 From: terrtia Date: Thu, 15 Feb 2024 10:13:06 +0100 Subject: [PATCH] chg: [titles] add endpoints to get all titles --- bin/lib/objects/abstract_daterange_object.py | 10 ++++++++++ var/www/blueprints/objects_title.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/bin/lib/objects/abstract_daterange_object.py b/bin/lib/objects/abstract_daterange_object.py index 1bf7e5bc..6f31a3ae 100755 --- a/bin/lib/objects/abstract_daterange_object.py +++ b/bin/lib/objects/abstract_daterange_object.py @@ -229,6 +229,16 @@ class AbstractDaterangeObjects(ABC): def sanitize_content_to_search(self, content_to_search): return content_to_search + def get_contents_ids(self): + titles = {} + for obj_id in self.get_ids(): + obj = self.obj_class(obj_id) + content = obj.get_content() + if content not in titles: + titles[content] = [] + titles[content].append(obj.get_id()) + return titles + def search_by_content(self, content_to_search, r_pos=False, case_sensitive=True): objs = {} if case_sensitive: diff --git a/var/www/blueprints/objects_title.py b/var/www/blueprints/objects_title.py index 3cac6b31..51e566d1 100644 --- a/var/www/blueprints/objects_title.py +++ b/var/www/blueprints/objects_title.py @@ -131,3 +131,10 @@ def objects_title_search(): return render_template("search_title_result.html", dict_objects=dict_objects, search_result=search_result, dict_page=dict_page, to_search=to_search, case_sensitive=case_sensitive, type_to_search=type_to_search) + +@objects_title.route("/objects/titles/download", methods=['GET']) +@login_required +@login_analyst +def objects_title_downloads(): + return jsonify(Titles.Titles().get_contents_ids()) +