Commit ae4c847c authored by Administrator's avatar Administrator
Browse files

Use cached etherpad url

parent 9f4adef4
......@@ -219,6 +219,8 @@ class Protocol(DatabaseModel):
return self.done
def get_identifier(self):
if self.pad_identifier is not None:
return self.pad_identifier
if self.date is None:
return None
return "{}-{}".format(
......
......@@ -582,5 +582,6 @@ def set_etherpad_content(protocol):
def set_etherpad_content_async(protocol_id):
with app.app_context():
protocol = Protocol.query.filter_by(id=protocol_id).first()
set_etherpad_text(protocol.get_identifier(), protocol.get_template())
identifier = protocol.get_identifier()
return set_etherpad_text(identifier, protocol.get_template())
......@@ -120,13 +120,16 @@ def get_etherpad_text(pad):
return req.text
def set_etherpad_text(pad, text, only_if_default=True):
print(pad)
if only_if_default:
current_text = get_etherpad_text(pad)
if current_text != config.EMPTY_ETHERPAD and len(current_text.strip()) > 0:
return False
file_like = BytesIO(text.encode("utf-8"))
files = {"file": file_like}
req = requests.post(get_etherpad_import_url(pad), files=files)
url = get_etherpad_import_url(pad)
print(url)
req = requests.post(url, files=files)
return req.status_code == 200
def split_terms(text, quote_chars="\"'", separators=" \t\n"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment