Skip to content

Commit

Permalink
comment out sharing service counter to handle picletype error
Browse files Browse the repository at this point in the history
  • Loading branch information
noamoss committed Jun 21, 2016
1 parent e4eb8c2 commit 69036b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ class SharedItem(db.Model):
shares_count = db.Column(Integer)
feed_title= db.Column(String)
project= db.Column(String,nullable=False)
service_share_counter = db.Column(PickleType)
#service_share_counter = db.Column(PickleType)

def __init__(self, full_url, bitly, shares_count,feed_title,project):
self.full_url=full_url
self.bitly = bitly
self.shares_count = 1
self.feed_title = feed_title
self.project = project
sharing_services_list = list(sharing_services.keys())
self.service_share_counter=dict.fromkeys(sharing_services_list,0)
#sharing_services_list = list(sharing_services.keys())
#self.service_share_counter=dict.fromkeys(sharing_services_list,0)

def add_share(self,service):
self.shares_count+=1
self.service_share_counter[service]+=1
#def add_share(self,service):
# self.shares_count+=1
# self.service_share_counter[service]+=1
6 changes: 3 additions & 3 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ def share_item(service=None, title=None, project=None, link=None):
service = request.args.get('service')
link=urllib.parse.unquote_plus(request.args.get('link'))
feed_title = request.args.get('title',title)
project_name = get_project_by_feed_url(link)
project = get_project_by_feed_url(link)
locate_link = SharedItem.query.filter_by(full_url=link).first()
if locate_link is not None: #if it is not the first time item/link is shared
bitly_link=locate_link.bitly
feed_title=locate_link.feed_title
project=locate_link.project

locate_link.add_share(service)
#locate_link.add_share(service)
else: # if item/link wasn't shared before -
bitlyconnection = bitlyapi.Connection(BITLY_USER, BITLY_KEY)
bitly_link = bitlyconnection.shorten(link)['url']
Expand All @@ -286,7 +286,7 @@ def share_item(service=None, title=None, project=None, link=None):
project=project,
shares_count=1,
)
new_item.service_share_counter[service] = 1
#new_item.service_share_counter[service] = 1
db.session.add(new_item)
db.session.commit() # save changes to db

Expand Down

0 comments on commit 69036b7

Please sign in to comment.