diff --git a/CHANGES.md b/CHANGES.md index 8b13789..e3bb183 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1 +1,23 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.1] - 2017-04-04 +### Fixed +- Fixed bookmark editing API where the last remaining tag on a +Bookmark wouldn't get deleted +- Fixed bookmark deletion API where bookmarks without existing tags +weren't getting deleted +- Fixed bookmark editing API where bookmarks without tags counldn't +be deleted + +## 0.1.0 - 2017-04-03 +### Added +- First versioned release +- Added CHANGELOG +- Started using SemVer diff --git a/crestify/__init__.py b/crestify/__init__.py index 133ba86..78f9647 100644 --- a/crestify/__init__.py +++ b/crestify/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from flask import Flask from flask_assets import Environment -from flask.ext.script import Manager -from flask.ext import restful +from flask_script import Manager +import flask_restful as restful from flask_debugtoolbar import DebugToolbarExtension -from flask.ext.cors import CORS +from flask_cors import CORS import os import errno from raven.contrib.flask import Sentry diff --git a/crestify/models.py b/crestify/models.py index d364e3d..a280060 100644 --- a/crestify/models.py +++ b/crestify/models.py @@ -6,7 +6,7 @@ from sqlalchemy_utils.types import TSVectorType from sqlalchemy.ext.associationproxy import association_proxy from flask_security import UserMixin, RoleMixin -from flask.ext.migrate import Migrate, MigrateCommand +from flask_migrate import Migrate, MigrateCommand from crestify import manager from sqlalchemy.dialects import postgresql diff --git a/crestify/services/bookmark.py b/crestify/services/bookmark.py index 07205b6..75c6e1e 100644 --- a/crestify/services/bookmark.py +++ b/crestify/services/bookmark.py @@ -70,8 +70,8 @@ def edit(id, user_id, title=None, description=None, tags=None): edit_bookmark.description = description[:256] if tags != "" or tags is not None: if type(tags) is unicode: - ls1 = edit_bookmark.tags - ls2 = tags.split(',') + ls1 = edit_bookmark.tags or [] + ls2 = tags.split(',') or [] # Compute deltas between new and current tags added_tags = set(ls1 + ls2) - set(ls1) removed_tags = set(ls1 + ls2) - set(ls2) @@ -97,11 +97,11 @@ def edit(id, user_id, title=None, description=None, tags=None): def api_edit(id, tags, user_id): edit_bookmark = Bookmark.query.get(id) + ls1 = edit_bookmark.tags or [] + ls2 = tags + added_tags = None + removed_tags = None if tags != ['']: - added_tags = None - removed_tags = None - ls1 = edit_bookmark.tags - ls2 = tags if ls1: added_tags = set(ls1 + ls2) - set(ls1) removed_tags = set(ls1 + ls2) - set(ls2) @@ -117,13 +117,16 @@ def api_edit(id, tags, user_id): db.session.add(new_tag) else: get_tag.count += 1 - if removed_tags: - for tag in removed_tags: - get_tag = Tag.query.filter_by(text=tag, - user=user_id).first() - if not get_tag: - pass - else: - get_tag.count -= 1 edit_bookmark.tags = ls2 + else: + removed_tags = set(edit_bookmark.tags) + edit_bookmark.tags = [] + if removed_tags: + for tag in removed_tags: + get_tag = Tag.query.filter_by(text=tag, + user=user_id).first() + if not get_tag: + pass + else: + get_tag.count -= 1 db.session.commit() diff --git a/crestify/views/apiservice.py b/crestify/views/apiservice.py index 5244eeb..1d06456 100644 --- a/crestify/views/apiservice.py +++ b/crestify/views/apiservice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from flask import request from crestify import api, redis, hashids -from flask.ext.restful import Resource, reqparse +from flask_restful import Resource, reqparse from crestify.models import Bookmark, User, Tag, db from crestify.services import bookmark from crestify.tasks import bookmark_tasks