mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-07 00:15:10 +01:00
Create public tag page, better retrieval of PublicTag page
This commit is contained in:
43
digimarks.py
43
digimarks.py
@@ -12,6 +12,7 @@ from utilkit import datetimeutil
|
|||||||
|
|
||||||
from flask import Flask, abort, redirect, render_template, request, url_for
|
from flask import Flask, abort, redirect, render_template, request, url_for
|
||||||
from flask_peewee.db import Database
|
from flask_peewee.db import Database
|
||||||
|
#from flask_peewee.utils import get_object_or_404
|
||||||
from peewee import *
|
from peewee import *
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -338,16 +339,48 @@ def tag(userkey, tag):
|
|||||||
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.tags.contains(tag))
|
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.tags.contains(tag))
|
||||||
tags = get_tags_for_user(userkey)
|
tags = get_tags_for_user(userkey)
|
||||||
pageheader = 'tag: ' + tag
|
pageheader = 'tag: ' + tag
|
||||||
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, action=pageheader)
|
message = request.args.get('message')
|
||||||
|
|
||||||
|
try:
|
||||||
|
publictag = PublicTag.get(PublicTag.userkey == userkey, PublicTag.tag == tag)
|
||||||
|
except PublicTag.DoesNotExist:
|
||||||
|
publictag = None
|
||||||
|
|
||||||
|
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, tag=tag, publictag=publictag, action=pageheader, message=message)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/pub/<tagkey>')
|
@app.route('/pub/<tagkey>')
|
||||||
def publictag(tagkey):
|
def publictag(tagkey):
|
||||||
""" Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
|
""" Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
|
||||||
this_tag = get_object_or_404(PublicTag.get(PublicTag.tagkey == tagkey))
|
#this_tag = get_object_or_404(PublicTag.select().where(PublicTag.tagkey == tagkey))
|
||||||
print this_tag
|
try:
|
||||||
bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, tags.contains(this_tag.tag))
|
this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
|
||||||
return render_template('publicbookmarks.html', bookmarks=bookmarks, tag=tag)
|
bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, Bookmark.tags.contains(this_tag.tag))
|
||||||
|
return render_template('publicbookmarks.html', bookmarks=bookmarks, tag=tag, action=this_tag.tag)
|
||||||
|
except PublicTag.DoesNotExist:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/<userkey>/<tag>/makepublic', methods=['GET', 'POST'])
|
||||||
|
def addpublictag(userkey, tag):
|
||||||
|
#user = get_object_or_404(User.get(User.key == userkey))
|
||||||
|
user = User.get(User.key == userkey)
|
||||||
|
try:
|
||||||
|
publictag = PublicTag.get(PublicTag.userkey == userkey, PublicTag.tag == tag)
|
||||||
|
except PublicTag.DoesNotExist:
|
||||||
|
publictag = None
|
||||||
|
if not publictag:
|
||||||
|
newpublictag = PublicTag()
|
||||||
|
newpublictag.generate_key()
|
||||||
|
newpublictag.userkey = userkey
|
||||||
|
newpublictag.tag = tag
|
||||||
|
newpublictag.save()
|
||||||
|
|
||||||
|
message = 'Public link to this tag created'
|
||||||
|
return redirect(url_for('tag', userkey=userkey, tag=tag, message=message))
|
||||||
|
else:
|
||||||
|
message = 'Public link already existed'
|
||||||
|
return redirect(url_for('tag', userkey=userkey, tag=tag, message=message))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<systemkey>/adduser')
|
@app.route('/<systemkey>/adduser')
|
||||||
|
|||||||
@@ -6,6 +6,22 @@
|
|||||||
{% block pageheader %}{{ action }}{% endblock %}
|
{% block pageheader %}{{ action }}{% endblock %}
|
||||||
{% block pagecontent %}
|
{% block pagecontent %}
|
||||||
|
|
||||||
|
{% if tag and not publictag %}
|
||||||
|
<div class="row">
|
||||||
|
<form action="{{ url_for('addpublictag', userkey=userkey, tag=tag) }}" method="POST">
|
||||||
|
<div class="input-field col l2 m2 s4">
|
||||||
|
<p class="left-align"><button class="btn btn-large waves-effect waves-light" type="submit" name="submit">Create public page <i class="material-icons right">tag</i></button></p>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if tag and publictag %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12"><a href="{{ url_for('publictag', tagkey=publictag.tagkey) }}">Public link</a></div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if message %}
|
{% if message %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
|
|||||||
Reference in New Issue
Block a user