From ce9b74158c87750ccf1c8f363a59c0465e4b1277 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sat, 18 May 2024 05:44:41 +0200
Subject: [PATCH] Minor HTTP handler refactoring.

---
 plomtask/http.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/plomtask/http.py b/plomtask/http.py
index 88725fc..d5da1d7 100644
--- a/plomtask/http.py
+++ b/plomtask/http.py
@@ -94,11 +94,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         """Handle any GET request."""
         try:
             self._init_handling()
-            if self.site in {'calendar', 'day', 'process', 'process_titles',
-                             'process_descriptions', 'process_efforts',
-                             'processes', 'todo', 'condition',
-                             'condition_titles', 'condition_descriptions',
-                             'conditions'}:
+            if hasattr(self, f'do_GET_{self.site}'):
                 template = f'{self.site}.html'
                 ctx = getattr(self, f'do_GET_{self.site}')()
                 html = self.server.jinja.get_template(template).render(**ctx)
@@ -211,7 +207,7 @@ class TaskHandler(BaseHTTPRequestHandler):
             postvars = parse_qs(self.rfile.read(length).decode(),
                                 keep_blank_values=True, strict_parsing=True)
             self.form_data = InputsParser(postvars)
-            if self.site in ('day', 'process', 'todo', 'condition'):
+            if hasattr(self, f'do_POST_{self.site}'):
                 redir_target = getattr(self, f'do_POST_{self.site}')()
                 self.conn.commit()
             else:
-- 
2.30.2