kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Validate duplicate URLs
rodzic
a58679f983
commit
c7169ebba1
|
@ -483,8 +483,13 @@ def changedetection_app(config=None, datastore_o=None):
|
||||||
def api_watch_add():
|
def api_watch_add():
|
||||||
global messages
|
global messages
|
||||||
|
|
||||||
|
url = request.form.get('url').strip()
|
||||||
|
if datastore.url_exists(url):
|
||||||
|
messages.append({'class': 'error', 'message': 'The URL {} already exists'.format(url)})
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
# @todo add_watch should throw a custom Exception for validation etc
|
# @todo add_watch should throw a custom Exception for validation etc
|
||||||
new_uuid = datastore.add_watch(url=request.form.get('url').strip(), tag=request.form.get('tag').strip())
|
new_uuid = datastore.add_watch(url=url, tag=request.form.get('tag').strip())
|
||||||
# Straight into the queue.
|
# Straight into the queue.
|
||||||
update_q.put(new_uuid)
|
update_q.put(new_uuid)
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class ChangeDetectionStore:
|
||||||
def url_exists(self, url):
|
def url_exists(self, url):
|
||||||
|
|
||||||
# Probably their should be dict...
|
# Probably their should be dict...
|
||||||
for watch in self.data['watching']:
|
for watch in self.data['watching'].values():
|
||||||
if watch['url'] == url:
|
if watch['url'] == url:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue