Esempio n. 1
0
def createTags(tags, article):
    tagList = tags.split(',')
    results = []
    for tag in tagList:
        m = TagModel()
        m.publish(tag, article)
        SystemInfoModel.increamentTagCount(tag)
        results.append(str(m.tagname))
    return results
Esempio n. 2
0
def updateTags(tags, article):
    tagList = tags.split(',')
    olds = article.tags
    tagNames = [tag.tagname for tag in olds]
    results = []
    out = []
    for tag in olds:
        if tag.tagname not in tagList:
            out.append(tag)
    for tag in tagList:
        if tag not in tagNames:
            m = TagModel()
            m.publish(tag, article)
            SystemInfoModel.increamentTagCount(tag)
        results.append(tag)
    #
    db.delete(out)
    for tag in out:
        SystemInfoModel.decrementTagCount(tag.tagname)
    return results