Adds 'Create Copy' feature to clone a watch (#184)

pull/209/head
Matthias Langhard 3 years ago committed by GitHub
parent 54d80ddea0
commit 05f7e123ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -766,6 +766,16 @@ def changedetection_app(config=None, datastore_o=None):
return redirect(url_for('index'))
@app.route("/api/clone", methods=['GET'])
@login_required
def api_clone():
uuid = request.args.get('uuid')
datastore.clone(uuid)
flash('Cloned.')
return redirect(url_for('index'))
@app.route("/api/checknow", methods=['GET'])
@login_required
def api_watch_checknow():

@ -242,6 +242,27 @@ class ChangeDetectionStore:
self.needs_write = True
# Clone a watch by UUID
def clone(self, uuid):
with self.lock:
new_uuid = str(uuid_builder.uuid4())
_clone = deepcopy(self.data['watching'][uuid])
_clone.update({'uuid': new_uuid})
attributes_to_reset = [
'last_checked',
'last_changed',
'last_viewed',
'newest_history_key',
'previous_md5',
'history'
]
for attribute in attributes_to_reset:
_clone.update({attribute: self.generic_definition[attribute]})
self.data['watching'][new_uuid] = _clone
self.needs_write = True
def url_exists(self, url):
# Probably their should be dict...

@ -124,6 +124,8 @@ User-Agent: wonderbra 1.0") }}
<button type="submit" class="pure-button pure-button-primary">Save</button>
<a href="{{url_for('api_delete', uuid=uuid)}}"
class="pure-button button-small button-error ">Delete</a>
<a href="{{url_for('api_clone', uuid=uuid)}}"
class="pure-button button-small ">Create Copy</a>
</div>
</div>
</form>

Loading…
Cancel
Save