mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Introduce url_hash field (used for editing etc) and edit form
This commit is contained in:
13
digimarks.py
13
digimarks.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user