Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhamaniasad committed Mar 4, 2018
2 parents be35402 + c6f5ce8 commit 7353979
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
22 changes: 22 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions crestify/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion crestify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 17 additions & 14 deletions crestify/services/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()
2 changes: 1 addition & 1 deletion crestify/views/apiservice.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7353979

Please sign in to comment.