1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-07 00:15:10 +01:00

Introduce url_hash field (used for editing etc) and edit form

This commit is contained in:
2016-07-08 15:12:52 +02:00
parent cff1a417e8
commit c94f161c21
2 changed files with 24 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ class Bookmark(db.Model):
url = CharField()
created_date = DateTimeField(default=datetime.datetime.now)
#image = CharField(default='')
url_hash = CharField()
tags = CharField()
class Meta:
@@ -53,15 +54,26 @@ class Bookmark(db.Model):
# if exitcode == 0:
# self.image = os.path.join(MEDIA_URL, filename)
def sethash(self):
self.url_hash = hashlib.md5(self.url).hexdigest()
@app.route('/')
def index():
return object_list('index.html', Bookmark.select())
@app.route('/<userkey>/')
def bookmarks(userkey):
return object_list('bookmarks.html', Bookmark.select())
@app.route('/<userkey>/edit/<urlhash>')
def editbookmark(urlhash):
# bookmark = getbyurlhash()
return render_template('edit.html')
@app.route('/<userkey>/add/')
def add(userkey):
password = request.args.get('password')
@@ -73,6 +85,7 @@ def add(userkey):
tags = ''
if url:
bookmark = Bookmark(url=url, title=title, tags=tags)
bookmark.sethash()
#bookmark.fetch_image()
bookmark.save()
return redirect(url)

11
templates/edit.html Normal file
View File

@@ -0,0 +1,11 @@
<h1>Edit/add bookmark</h1>
<form action="{{ SERVERURI }}/{{ FORMACTION }}">
<label>Title</label> <input type="text" name="title" value="{{ title }}" />
<label>URL</label> <input type="text" name="url" value="{{ url }}" />
<label>Tags</label> <input type="text" name="tags" value="{{ tags }}" />
<input type="submit" value="Save" />
</form>