Beispiel #1
0
def papers(tag_id):
    if not tag_id:
        tags = Tag.select().paginate(0, 1)
    else:
        tags = Tag.select().where(Tag.id == tag_id)
    tag = tags[0]
    papers = Paper.select().where(Paper.tag == tag)
    return render_template("papers.html", tag=tag, papers=papers)
Beispiel #2
0
def get_papers(tag_id):
    if tag_id:
        tags = Tag.select().where(Tag.id == tag_id)
    else:
        tags = Tag.select().paginate(0, 1)
    papers = Paper.select().where(
        Paper.tag << tags).dicts()  #.paginate(0, 100)
    response = {'papers': list(papers)}
    return jsonify(response)
Beispiel #3
0
def user2ag():
    user = User.select()[0]
    if not user.user_agent or not user.mac_address and request.endpoint not in (
            'user2code', 'static'):
        return redirect(url_for('user2code'))
    tags = Tag.select()
    g.tags = tags
Beispiel #4
0
 def getTags():
     tags = []
     for tag in Tag.select():
         tags.append("'" + tag.tag.replace("'", "\\'") + "'")
     
     data = "[" + ",".join(tags) + "];"
     
     return data
Beispiel #5
0
 def addTag(self, noteId, strTag):
     count = Tag.select().where(Tag.tag == strTag).count()
     if (count == 0):
         dbTag = Tag()
         dbTag.creationDate = dbTag.modificationDate = datetime.date.today()
         dbTag.tag = strTag
         dbTag.save()
     else:
         dbTag = Tag.get(Tag.tag == strTag)
         
     note = Note.get(Note.id == noteId)
     noteTag = NoteTag()
     noteTag.note = note
     noteTag.tag = dbTag
     noteTag.creationDate = noteTag.modificationDate = datetime.date.today()
     noteTag.save() 
     
     self.view.execute_script("notesMD.tags = " + RuntimeSettings.getTags())
Beispiel #6
0
def index():
    tags = Tag.select().paginate(0, 1)
    tag = tags[0]
    papers = Paper.select().where(Paper.tag == tag)
    return render_template("papers.html", tag=tag, papers=papers)
Beispiel #7
0
def get_tags():
    tags = Tag.select().dicts()
    response = {'tags': list(tags)}
    return jsonify(response)