mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
update all models.py files to python3 and django2.0
This commit is contained in:
parent
dafb613826
commit
e46b2495ce
11 changed files with 91 additions and 91 deletions
|
@ -57,12 +57,12 @@ class MCategory(mongo.Document):
|
||||||
for category_title, sites in category_groups:
|
for category_title, sites in category_groups:
|
||||||
try:
|
try:
|
||||||
category = cls.objects.get(title=category_title)
|
category = cls.objects.get(title=category_title)
|
||||||
except cls.DoesNotExist, e:
|
except cls.DoesNotExist as e:
|
||||||
print " ***> Missing category: %s" % category_title
|
print(" ***> Missing category: %s" % category_title)
|
||||||
continue
|
continue
|
||||||
category.feed_ids = [site.feed_id for site in sites]
|
category.feed_ids = [site.feed_id for site in sites]
|
||||||
category.save()
|
category.save()
|
||||||
print " ---> Reloaded category: %s" % category
|
print(" ---> Reloaded category: %s" % category)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def subscribe(cls, user_id, category_title):
|
def subscribe(cls, user_id, category_title):
|
||||||
|
@ -111,6 +111,6 @@ class MCategorySite(mongo.Document):
|
||||||
feed_id=feed_id)
|
feed_id=feed_id)
|
||||||
|
|
||||||
if not created:
|
if not created:
|
||||||
print " ---> Site is already in category: %s" % category_site
|
print(" ---> Site is already in category: %s" % category_site)
|
||||||
else:
|
else:
|
||||||
MCategory.reload_sites(category_title)
|
MCategory.reload_sites(category_title)
|
|
@ -3,7 +3,7 @@ import mongoengine as mongo
|
||||||
import httplib2
|
import httplib2
|
||||||
import pickle
|
import pickle
|
||||||
import base64
|
import base64
|
||||||
from StringIO import StringIO
|
from io import StringIO
|
||||||
from oauth2client.client import Error as OAuthError
|
from oauth2client.client import Error as OAuthError
|
||||||
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
@ -76,14 +76,14 @@ class OPMLExporter(Importer):
|
||||||
if isinstance(obj, int) and obj in self.feeds:
|
if isinstance(obj, int) and obj in self.feeds:
|
||||||
feed = self.feeds[obj]
|
feed = self.feeds[obj]
|
||||||
if verbose:
|
if verbose:
|
||||||
print " ---> Adding feed: %s - %s" % (feed['id'],
|
print(" ---> Adding feed: %s - %s" % (feed['id'],
|
||||||
feed['feed_title'][:30])
|
feed['feed_title'][:30]))
|
||||||
feed_attrs = self.make_feed_row(feed)
|
feed_attrs = self.make_feed_row(feed)
|
||||||
body.append(Element('outline', feed_attrs))
|
body.append(Element('outline', feed_attrs))
|
||||||
elif isinstance(obj, dict):
|
elif isinstance(obj, dict):
|
||||||
for folder_title, folder_objs in obj.items():
|
for folder_title, folder_objs in list(obj.items()):
|
||||||
if verbose:
|
if verbose:
|
||||||
print " ---> Adding folder: %s" % folder_title
|
print(" ---> Adding folder: %s" % folder_title)
|
||||||
folder_element = Element('outline', {'text': folder_title, 'title': folder_title})
|
folder_element = Element('outline', {'text': folder_title, 'title': folder_title})
|
||||||
body.append(self.process_outline(folder_element, folder_objs, verbose=verbose))
|
body.append(self.process_outline(folder_element, folder_objs, verbose=verbose))
|
||||||
return body
|
return body
|
||||||
|
@ -349,7 +349,7 @@ class GoogleReaderImporter(Importer):
|
||||||
folders = add_object_to_folder(feed_db.pk, category, folders)
|
folders = add_object_to_folder(feed_db.pk, category, folders)
|
||||||
# if feed_db.pk not in folders[category]:
|
# if feed_db.pk not in folders[category]:
|
||||||
# folders[category].append(feed_db.pk)
|
# folders[category].append(feed_db.pk)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.info(' *** -> Exception: %s: %s' % (e, item))
|
logging.info(' *** -> Exception: %s: %s' % (e, item))
|
||||||
|
|
||||||
return folders
|
return folders
|
||||||
|
|
|
@ -3,7 +3,7 @@ import re
|
||||||
import redis
|
import redis
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
from django.core.urlresolvers import reverse
|
from django.urls import reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.html import linebreaks
|
from django.utils.html import linebreaks
|
||||||
|
|
|
@ -16,11 +16,11 @@ from apps.analyzer.models import compute_story_score
|
||||||
from utils.story_functions import truncate_chars
|
from utils.story_functions import truncate_chars
|
||||||
from utils import log as logging
|
from utils import log as logging
|
||||||
from utils import mongoengine_fields
|
from utils import mongoengine_fields
|
||||||
from HTMLParser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from vendor.apns import APNs, Payload
|
from vendor.apns import APNs, Payload
|
||||||
from bs4 import BeautifulSoup, Tag
|
from bs4 import BeautifulSoup, Tag
|
||||||
import types
|
import types
|
||||||
import urlparse
|
import urllib.parse
|
||||||
|
|
||||||
class NotificationFrequency(enum.Enum):
|
class NotificationFrequency(enum.Enum):
|
||||||
immediately = 1
|
immediately = 1
|
||||||
|
@ -177,7 +177,7 @@ class MUserFeedNotification(mongo.Document):
|
||||||
def replace_with_newlines(element):
|
def replace_with_newlines(element):
|
||||||
text = ''
|
text = ''
|
||||||
for elem in element.recursiveChildGenerator():
|
for elem in element.recursiveChildGenerator():
|
||||||
if isinstance(elem, types.StringTypes):
|
if isinstance(elem, (str,)):
|
||||||
text += elem
|
text += elem
|
||||||
elif elem.name == 'br':
|
elif elem.name == 'br':
|
||||||
text += '\n'
|
text += '\n'
|
||||||
|
@ -289,7 +289,7 @@ class MUserFeedNotification(mongo.Document):
|
||||||
msg.attach_alternative(html, "text/html")
|
msg.attach_alternative(html, "text/html")
|
||||||
try:
|
try:
|
||||||
msg.send()
|
msg.send()
|
||||||
except BotoServerError, e:
|
except BotoServerError as e:
|
||||||
logging.user(usersub.user, '~BMStory notification by email error: ~FR%s' % e)
|
logging.user(usersub.user, '~BMStory notification by email error: ~FR%s' % e)
|
||||||
return
|
return
|
||||||
logging.user(usersub.user, '~BMStory notification by email: ~FY~SB%s~SN~BM~FY/~SB%s' %
|
logging.user(usersub.user, '~BMStory notification by email: ~FY~SB%s~SN~BM~FY/~SB%s' %
|
||||||
|
@ -310,13 +310,13 @@ class MUserFeedNotification(mongo.Document):
|
||||||
else:
|
else:
|
||||||
iframe.extract()
|
iframe.extract()
|
||||||
|
|
||||||
return unicode(soup)
|
return str(soup)
|
||||||
|
|
||||||
def extract_youtube_id(self, url):
|
def extract_youtube_id(self, url):
|
||||||
youtube_id = None
|
youtube_id = None
|
||||||
|
|
||||||
if 'youtube.com' in url:
|
if 'youtube.com' in url:
|
||||||
youtube_parts = urlparse.urlparse(url)
|
youtube_parts = urllib.parse.urlparse(url)
|
||||||
if '/embed/' in youtube_parts.path:
|
if '/embed/' in youtube_parts.path:
|
||||||
youtube_id = youtube_parts.path.replace('/embed/', '')
|
youtube_id = youtube_parts.path.replace('/embed/', '')
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ from django.conf import settings
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
from django.core.urlresolvers import reverse
|
from django.urls import reverse
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from apps.rss_feeds.models import Feed, MStory, MStarredStory
|
from apps.rss_feeds.models import Feed, MStory, MStarredStory
|
||||||
from apps.rss_feeds.tasks import SchedulePremiumSetup
|
from apps.rss_feeds.tasks import SchedulePremiumSetup
|
||||||
|
@ -91,11 +91,11 @@ class Profile(models.Model):
|
||||||
try:
|
try:
|
||||||
super(Profile, self).save(*args, **kwargs)
|
super(Profile, self).save(*args, **kwargs)
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
print " ---> Profile not saved. Table isn't there yet."
|
print(" ---> Profile not saved. Table isn't there yet.")
|
||||||
|
|
||||||
def delete_user(self, confirm=False, fast=False):
|
def delete_user(self, confirm=False, fast=False):
|
||||||
if not confirm:
|
if not confirm:
|
||||||
print " ---> You must pass confirm=True to delete this user."
|
print(" ---> You must pass confirm=True to delete this user.")
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.user(self.user, "Deleting user: %s / %s" % (self.user.email, self.user.profile.last_seen_ip))
|
logging.user(self.user, "Deleting user: %s / %s" % (self.user.email, self.user.profile.last_seen_ip))
|
||||||
|
@ -340,7 +340,7 @@ class Profile(models.Model):
|
||||||
customers = [c['customer'] for c in charges if 'customer' in c]
|
customers = [c['customer'] for c in charges if 'customer' in c]
|
||||||
for customer in customers:
|
for customer in customers:
|
||||||
if not customer:
|
if not customer:
|
||||||
print " ***> No customer!"
|
print(" ***> No customer!")
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
profile = Profile.objects.get(stripe_id=customer)
|
profile = Profile.objects.get(stripe_id=customer)
|
||||||
|
@ -530,15 +530,15 @@ class Profile(models.Model):
|
||||||
has_profile = user.profile.last_seen_ip
|
has_profile = user.profile.last_seen_ip
|
||||||
except Profile.DoesNotExist:
|
except Profile.DoesNotExist:
|
||||||
usernames.add(user.username)
|
usernames.add(user.username)
|
||||||
print " ---> Missing profile: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads)
|
print(" ---> Missing profile: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if opens is None and not reads and has_numbers:
|
if opens is None and not reads and has_numbers:
|
||||||
usernames.add(user.username)
|
usernames.add(user.username)
|
||||||
print " ---> Numerics: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads)
|
print(" ---> Numerics: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads))
|
||||||
elif not has_profile:
|
elif not has_profile:
|
||||||
usernames.add(user.username)
|
usernames.add(user.username)
|
||||||
print " ---> No IP: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads)
|
print(" ---> No IP: %-20s %-30s %-6s %-6s" % (user.username, user.email, opens, reads))
|
||||||
|
|
||||||
if not confirm: return usernames
|
if not confirm: return usernames
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ class Profile(models.Model):
|
||||||
else:
|
else:
|
||||||
user_ids = dict([(us.user_id, us.active)
|
user_ids = dict([(us.user_id, us.active)
|
||||||
for us in UserSubscription.objects.filter(feed_id=feed_id).only('user', 'active')])
|
for us in UserSubscription.objects.filter(feed_id=feed_id).only('user', 'active')])
|
||||||
profiles = Profile.objects.filter(user_id__in=user_ids.keys()).values('user_id', 'last_seen_on', 'is_premium')
|
profiles = Profile.objects.filter(user_id__in=list(user_ids.keys())).values('user_id', 'last_seen_on', 'is_premium')
|
||||||
feed = Feed.get_by_id(feed_id)
|
feed = Feed.get_by_id(feed_id)
|
||||||
|
|
||||||
if entire_feed_counted:
|
if entire_feed_counted:
|
||||||
|
@ -776,7 +776,7 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def send_forgot_password_email(self, email=None):
|
def send_forgot_password_email(self, email=None):
|
||||||
if not self.user.email and not email:
|
if not self.user.email and not email:
|
||||||
print "Please provide an email address."
|
print("Please provide an email address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.user.email and email:
|
if not self.user.email and email:
|
||||||
|
@ -797,7 +797,7 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def send_new_user_queue_email(self, force=False):
|
def send_new_user_queue_email(self, force=False):
|
||||||
if not self.user.email:
|
if not self.user.email:
|
||||||
print "Please provide an email address."
|
print("Please provide an email address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
params = dict(receiver_user_id=self.user.pk, email_type='new_user_queue')
|
params = dict(receiver_user_id=self.user.pk, email_type='new_user_queue')
|
||||||
|
@ -823,7 +823,7 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def send_upload_opml_finished_email(self, feed_count):
|
def send_upload_opml_finished_email(self, feed_count):
|
||||||
if not self.user.email:
|
if not self.user.email:
|
||||||
print "Please provide an email address."
|
print("Please provide an email address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
user = self.user
|
user = self.user
|
||||||
|
@ -840,7 +840,7 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def send_import_reader_finished_email(self, feed_count):
|
def send_import_reader_finished_email(self, feed_count):
|
||||||
if not self.user.email:
|
if not self.user.email:
|
||||||
print "Please provide an email address."
|
print("Please provide an email address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
user = self.user
|
user = self.user
|
||||||
|
@ -857,7 +857,7 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def send_import_reader_starred_finished_email(self, feed_count, starred_count):
|
def send_import_reader_starred_finished_email(self, feed_count, starred_count):
|
||||||
if not self.user.email:
|
if not self.user.email:
|
||||||
print "Please provide an email address."
|
print("Please provide an email address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
user = self.user
|
user = self.user
|
||||||
|
@ -1270,7 +1270,7 @@ class PaymentHistory(models.Model):
|
||||||
return payments, output
|
return payments, output
|
||||||
|
|
||||||
output += "\nMonthly Totals:\n"
|
output += "\nMonthly Totals:\n"
|
||||||
for m in reversed(range(months)):
|
for m in reversed(list(range(months))):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(months=m)
|
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(months=m)
|
||||||
end_time = start_date + datetime.timedelta(days=31)
|
end_time = start_date + datetime.timedelta(days=31)
|
||||||
|
@ -1286,7 +1286,7 @@ class PaymentHistory(models.Model):
|
||||||
this_mtd_sum = 0
|
this_mtd_sum = 0
|
||||||
last_mtd_count = 0
|
last_mtd_count = 0
|
||||||
this_mtd_count = 0
|
this_mtd_count = 0
|
||||||
for y in reversed(range(years)):
|
for y in reversed(list(range(years))):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(years=y)
|
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(years=y)
|
||||||
end_date = now - dateutil.relativedelta.relativedelta(years=y)
|
end_date = now - dateutil.relativedelta.relativedelta(years=y)
|
||||||
|
@ -1306,7 +1306,7 @@ class PaymentHistory(models.Model):
|
||||||
last_month_avg = 0
|
last_month_avg = 0
|
||||||
last_month_sum = 0
|
last_month_sum = 0
|
||||||
last_month_count = 0
|
last_month_count = 0
|
||||||
for y in reversed(range(years)):
|
for y in reversed(list(range(years))):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(years=y)
|
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(years=y)
|
||||||
end_time = start_date + datetime.timedelta(days=31)
|
end_time = start_date + datetime.timedelta(days=31)
|
||||||
|
@ -1330,7 +1330,7 @@ class PaymentHistory(models.Model):
|
||||||
last_ytd_sum = 0
|
last_ytd_sum = 0
|
||||||
this_ytd_count = 0
|
this_ytd_count = 0
|
||||||
last_ytd_count = 0
|
last_ytd_count = 0
|
||||||
for y in reversed(range(years)):
|
for y in reversed(list(range(years))):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
start_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y)
|
start_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y)
|
||||||
end_date = now - dateutil.relativedelta.relativedelta(years=y)
|
end_date = now - dateutil.relativedelta.relativedelta(years=y)
|
||||||
|
@ -1350,7 +1350,7 @@ class PaymentHistory(models.Model):
|
||||||
last_year_sum = 0
|
last_year_sum = 0
|
||||||
last_year_count = 0
|
last_year_count = 0
|
||||||
annual = 0
|
annual = 0
|
||||||
for y in reversed(range(years)):
|
for y in reversed(list(range(years))):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
start_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y)
|
start_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y)
|
||||||
end_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y-1) - datetime.timedelta(seconds=1)
|
end_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y-1) - datetime.timedelta(seconds=1)
|
||||||
|
@ -1370,7 +1370,7 @@ class PaymentHistory(models.Model):
|
||||||
total = cls.objects.all().aggregate(sum=Sum('payment_amount'))
|
total = cls.objects.all().aggregate(sum=Sum('payment_amount'))
|
||||||
output += "\nTotal: $%s\n" % total['sum']
|
output += "\nTotal: $%s\n" % total['sum']
|
||||||
|
|
||||||
print output
|
print(output)
|
||||||
|
|
||||||
return {'annual': annual, 'output': output}
|
return {'annual': annual, 'output': output}
|
||||||
|
|
||||||
|
@ -1399,7 +1399,7 @@ class MGiftCode(mongo.Document):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_code(gift_code=None):
|
def create_code(gift_code=None):
|
||||||
u = unicode(uuid.uuid4())
|
u = str(uuid.uuid4())
|
||||||
code = u[:8] + u[9:13]
|
code = u[:8] + u[9:13]
|
||||||
if gift_code:
|
if gift_code:
|
||||||
code = gift_code + code[len(gift_code):]
|
code = gift_code + code[len(gift_code):]
|
||||||
|
|
|
@ -24,8 +24,8 @@ class RecommendedFeed(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class RecommendedFeedUserFeedback(models.Model):
|
class RecommendedFeedUserFeedback(models.Model):
|
||||||
recommendation = models.ForeignKey(RecommendedFeed, related_name='feedback')
|
recommendation = models.ForeignKey(RecommendedFeed, related_name='feedback', on_delete=models.CASCADE)
|
||||||
user = models.ForeignKey(User, related_name='feed_feedback')
|
user = models.ForeignKey(User, related_name='feed_feedback', on_delete=models.CASCADE)
|
||||||
score = models.IntegerField(default=0)
|
score = models.IntegerField(default=0)
|
||||||
created_date = models.DateField(auto_now_add=True)
|
created_date = models.DateField(auto_now_add=True)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class MFeedFolder(mongo.Document):
|
||||||
@classmethod
|
@classmethod
|
||||||
def count_feed(cls, feed_id):
|
def count_feed(cls, feed_id):
|
||||||
feed = Feed.get_by_id(feed_id)
|
feed = Feed.get_by_id(feed_id)
|
||||||
print feed
|
print(feed)
|
||||||
found_folders = defaultdict(int)
|
found_folders = defaultdict(int)
|
||||||
user_ids = [sub['user_id'] for sub in UserSubscription.objects.filter(feed=feed).values('user_id')]
|
user_ids = [sub['user_id'] for sub in UserSubscription.objects.filter(feed=feed).values('user_id')]
|
||||||
usf = UserSubscriptionFolders.objects.filter(user_id__in=user_ids)
|
usf = UserSubscriptionFolders.objects.filter(user_id__in=user_ids)
|
||||||
|
@ -57,7 +57,7 @@ class MFeedFolder(mongo.Document):
|
||||||
if not folder_title: continue
|
if not folder_title: continue
|
||||||
found_folders[folder_title.lower()] += 1
|
found_folders[folder_title.lower()] += 1
|
||||||
# print "%-20s - %s" % (folder_title if folder_title != '' else '[Top]', sub.user_id)
|
# print "%-20s - %s" % (folder_title if folder_title != '' else '[Top]', sub.user_id)
|
||||||
print sorted(found_folders.items(), key=lambda f: f[1], reverse=True)
|
print(sorted(list(found_folders.items()), key=lambda f: f[1], reverse=True))
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -66,7 +66,7 @@ class MFeedFolder(mongo.Document):
|
||||||
if isinstance(item, int) and item == feed_id:
|
if isinstance(item, int) and item == feed_id:
|
||||||
return folder_title
|
return folder_title
|
||||||
elif isinstance(item, dict):
|
elif isinstance(item, dict):
|
||||||
for f_k, f_v in item.items():
|
for f_k, f_v in list(item.items()):
|
||||||
sub_folder_title = cls.feed_folder_parent(f_v, feed_id, f_k)
|
sub_folder_title = cls.feed_folder_parent(f_v, feed_id, f_k)
|
||||||
if sub_folder_title:
|
if sub_folder_title:
|
||||||
return sub_folder_title
|
return sub_folder_title
|
||||||
|
|
|
@ -2286,7 +2286,7 @@ class Feed(models.Model):
|
||||||
# phrase = models.CharField(max_length=500)
|
# phrase = models.CharField(max_length=500)
|
||||||
|
|
||||||
class FeedData(models.Model):
|
class FeedData(models.Model):
|
||||||
feed = AutoOneToOneField(Feed, related_name='data')
|
feed = AutoOneToOneField(Feed, related_name='data', on_delete=models.CASCADE)
|
||||||
feed_tagline = models.CharField(max_length=1024, blank=True, null=True)
|
feed_tagline = models.CharField(max_length=1024, blank=True, null=True)
|
||||||
story_count_history = models.TextField(blank=True, null=True)
|
story_count_history = models.TextField(blank=True, null=True)
|
||||||
feed_classifier_counts = models.TextField(blank=True, null=True)
|
feed_classifier_counts = models.TextField(blank=True, null=True)
|
||||||
|
@ -3251,7 +3251,7 @@ class DuplicateFeed(models.Model):
|
||||||
duplicate_address = models.CharField(max_length=764, db_index=True)
|
duplicate_address = models.CharField(max_length=764, db_index=True)
|
||||||
duplicate_link = models.CharField(max_length=764, null=True, db_index=True)
|
duplicate_link = models.CharField(max_length=764, null=True, db_index=True)
|
||||||
duplicate_feed_id = models.CharField(max_length=255, null=True, db_index=True)
|
duplicate_feed_id = models.CharField(max_length=255, null=True, db_index=True)
|
||||||
feed = models.ForeignKey(Feed, related_name='duplicate_addresses')
|
feed = models.ForeignKey(Feed, related_name='duplicate_addresses', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%s: %s / %s" % (self.feed, self.duplicate_address, self.duplicate_link)
|
return "%s: %s / %s" % (self.feed, self.duplicate_address, self.duplicate_link)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
import urlparse
|
import urllib.parse
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
import zlib
|
import zlib
|
||||||
|
@ -9,15 +9,15 @@ import re
|
||||||
import mongoengine as mongo
|
import mongoengine as mongo
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import HTMLParser
|
import html.parser
|
||||||
import tweepy
|
import tweepy
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from BeautifulSoup import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from mongoengine.queryset import Q
|
from mongoengine.queryset import Q
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.urlresolvers import reverse
|
from django.urls import reverse
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
@ -38,7 +38,7 @@ from utils.story_functions import truncate_chars, strip_tags, linkify, image_siz
|
||||||
from utils.image_functions import ImageOps
|
from utils.image_functions import ImageOps
|
||||||
from utils.scrubber import SelectiveScriptScrubber
|
from utils.scrubber import SelectiveScriptScrubber
|
||||||
from utils import s3_utils
|
from utils import s3_utils
|
||||||
from StringIO import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from apps.social.spam import detect_spammers
|
from apps.social.spam import detect_spammers
|
||||||
|
@ -68,13 +68,13 @@ class MRequestInvite(mongo.Document):
|
||||||
@classmethod
|
@classmethod
|
||||||
def blast(cls):
|
def blast(cls):
|
||||||
invites = cls.objects.filter(email_sent=None)
|
invites = cls.objects.filter(email_sent=None)
|
||||||
print ' ---> Found %s invites...' % invites.count()
|
print(' ---> Found %s invites...' % invites.count())
|
||||||
|
|
||||||
for invite in invites:
|
for invite in invites:
|
||||||
try:
|
try:
|
||||||
invite.send_email()
|
invite.send_email()
|
||||||
except:
|
except:
|
||||||
print ' ***> Could not send invite to: %s. Deleting.' % invite.username
|
print(' ***> Could not send invite to: %s. Deleting.' % invite.username)
|
||||||
invite.delete()
|
invite.delete()
|
||||||
|
|
||||||
def send_email(self):
|
def send_email(self):
|
||||||
|
@ -261,9 +261,9 @@ class MSocialProfile(mongo.Document):
|
||||||
for story in MSharedStory.objects(user_id=self.user_id).only('story_feed_id')[:500]:
|
for story in MSharedStory.objects(user_id=self.user_id).only('story_feed_id')[:500]:
|
||||||
publishers[story.story_feed_id] += 1
|
publishers[story.story_feed_id] += 1
|
||||||
feed_titles = dict((f.id, f.feed_title)
|
feed_titles = dict((f.id, f.feed_title)
|
||||||
for f in Feed.objects.filter(pk__in=publishers.keys()).only('id', 'feed_title'))
|
for f in Feed.objects.filter(pk__in=list(publishers.keys())).only('id', 'feed_title'))
|
||||||
feed_publishers = sorted([{'id': k, 'feed_title': feed_titles[k], 'story_count': v}
|
feed_publishers = sorted([{'id': k, 'feed_title': feed_titles[k], 'story_count': v}
|
||||||
for k, v in publishers.items()
|
for k, v in list(publishers.items())
|
||||||
if k in feed_titles],
|
if k in feed_titles],
|
||||||
key=lambda f: f['story_count'],
|
key=lambda f: f['story_count'],
|
||||||
reverse=True)[:20]
|
reverse=True)[:20]
|
||||||
|
@ -723,7 +723,7 @@ class MSocialProfile(mongo.Document):
|
||||||
for year in range(min_year, now.year+1):
|
for year in range(min_year, now.year+1):
|
||||||
for month in range(1, 12+1):
|
for month in range(1, 12+1):
|
||||||
if datetime.datetime(year, month, 1) < now:
|
if datetime.datetime(year, month, 1) < now:
|
||||||
key = u'%s-%s' % (year, month)
|
key = '%s-%s' % (year, month)
|
||||||
if dates.get(key) or start:
|
if dates.get(key) or start:
|
||||||
start = True
|
start = True
|
||||||
months.append((key, dates.get(key, 0)))
|
months.append((key, dates.get(key, 0)))
|
||||||
|
@ -760,7 +760,7 @@ class MSocialProfile(mongo.Document):
|
||||||
scores = []
|
scores = []
|
||||||
res = cls.objects(social_user_id=self.user_id).map_reduce(map_f, reduce_f, output='inline')
|
res = cls.objects(social_user_id=self.user_id).map_reduce(map_f, reduce_f, output='inline')
|
||||||
for r in res:
|
for r in res:
|
||||||
facet_values = dict([(k, int(v)) for k,v in r.value.iteritems()])
|
facet_values = dict([(k, int(v)) for k,v in r.value.items()])
|
||||||
facet_values[facet] = r.key
|
facet_values[facet] = r.key
|
||||||
scores.append(facet_values)
|
scores.append(facet_values)
|
||||||
scores = sorted(scores, key=lambda v: v['neg'] - v['pos'])
|
scores = sorted(scores, key=lambda v: v['neg'] - v['pos'])
|
||||||
|
@ -863,7 +863,7 @@ class MSocialSubscription(mongo.Document):
|
||||||
social_sub.calculate_feed_scores()
|
social_sub.calculate_feed_scores()
|
||||||
|
|
||||||
# Combine subscription read counts with feed/user info
|
# Combine subscription read counts with feed/user info
|
||||||
feed = dict(social_sub.canonical().items() + social_profiles[user_id].items())
|
feed = dict(list(social_sub.canonical().items()) + list(social_profiles[user_id].items()))
|
||||||
social_feeds.append(feed)
|
social_feeds.append(feed)
|
||||||
|
|
||||||
return social_feeds
|
return social_feeds
|
||||||
|
@ -1087,7 +1087,7 @@ class MSocialSubscription(mongo.Document):
|
||||||
story_hashes_and_dates = range_func(ranked_stories_keys, offset, limit, withscores=True)
|
story_hashes_and_dates = range_func(ranked_stories_keys, offset, limit, withscores=True)
|
||||||
if not story_hashes_and_dates:
|
if not story_hashes_and_dates:
|
||||||
return [], [], []
|
return [], [], []
|
||||||
story_hashes, story_dates = zip(*story_hashes_and_dates)
|
story_hashes, story_dates = list(zip(*story_hashes_and_dates))
|
||||||
if read_filter == "unread":
|
if read_filter == "unread":
|
||||||
unread_story_hashes = story_hashes
|
unread_story_hashes = story_hashes
|
||||||
else:
|
else:
|
||||||
|
@ -1114,7 +1114,7 @@ class MSocialSubscription(mongo.Document):
|
||||||
story_hashes_and_dates = range_func(ranked_stories_keys, offset, limit, withscores=True)
|
story_hashes_and_dates = range_func(ranked_stories_keys, offset, limit, withscores=True)
|
||||||
if not story_hashes_and_dates:
|
if not story_hashes_and_dates:
|
||||||
return [], [], []
|
return [], [], []
|
||||||
story_hashes, story_dates = zip(*story_hashes_and_dates)
|
story_hashes, story_dates = list(zip(*story_hashes_and_dates))
|
||||||
|
|
||||||
if read_filter == "unread":
|
if read_filter == "unread":
|
||||||
unread_feed_story_hashes = story_hashes
|
unread_feed_story_hashes = story_hashes
|
||||||
|
@ -1493,7 +1493,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def decoded_story_title(self):
|
def decoded_story_title(self):
|
||||||
h = HTMLParser.HTMLParser()
|
h = html.parser.HTMLParser()
|
||||||
return h.unescape(self.story_title)
|
return h.unescape(self.story_title)
|
||||||
|
|
||||||
def canonical(self):
|
def canonical(self):
|
||||||
|
@ -1550,7 +1550,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def trim_old_stories(cls, stories=10, days=90, dryrun=False):
|
def trim_old_stories(cls, stories=10, days=90, dryrun=False):
|
||||||
print " ---> Fetching shared story counts..."
|
print(" ---> Fetching shared story counts...")
|
||||||
stats = settings.MONGODB.newsblur.shared_stories.aggregate([{
|
stats = settings.MONGODB.newsblur.shared_stories.aggregate([{
|
||||||
"$group": {
|
"$group": {
|
||||||
"_id": "$user_id",
|
"_id": "$user_id",
|
||||||
|
@ -1564,7 +1564,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
month_ago = datetime.datetime.now() - datetime.timedelta(days=days)
|
month_ago = datetime.datetime.now() - datetime.timedelta(days=days)
|
||||||
user_ids = list(stats)
|
user_ids = list(stats)
|
||||||
user_ids = sorted(user_ids, key=lambda x:x['stories'], reverse=True)
|
user_ids = sorted(user_ids, key=lambda x:x['stories'], reverse=True)
|
||||||
print " ---> Found %s users with more than %s starred stories" % (len(user_ids), stories)
|
print(" ---> Found %s users with more than %s starred stories" % (len(user_ids), stories))
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
for stat in user_ids:
|
for stat in user_ids:
|
||||||
|
@ -1578,17 +1578,17 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
|
|
||||||
total += stat['stories']
|
total += stat['stories']
|
||||||
username = "%s (%s)" % (user and user.username or " - ", stat['_id'])
|
username = "%s (%s)" % (user and user.username or " - ", stat['_id'])
|
||||||
print " ---> %19.19s: %-20.20s %s stories" % (user and user.profile.last_seen_on or "Deleted",
|
print(" ---> %19.19s: %-20.20s %s stories" % (user and user.profile.last_seen_on or "Deleted",
|
||||||
username,
|
username,
|
||||||
stat['stories'])
|
stat['stories']))
|
||||||
if not dryrun and stat['_id']:
|
if not dryrun and stat['_id']:
|
||||||
cls.objects.filter(user_id=stat['_id']).delete()
|
cls.objects.filter(user_id=stat['_id']).delete()
|
||||||
elif not dryrun and stat['_id'] == 0:
|
elif not dryrun and stat['_id'] == 0:
|
||||||
print " ---> Deleting unshared stories (user_id = 0)"
|
print(" ---> Deleting unshared stories (user_id = 0)")
|
||||||
cls.objects.filter(user_id=stat['_id']).delete()
|
cls.objects.filter(user_id=stat['_id']).delete()
|
||||||
|
|
||||||
|
|
||||||
print " ---> Deleted %s stories in total." % total
|
print(" ---> Deleted %s stories in total." % total)
|
||||||
|
|
||||||
def unshare_story(self):
|
def unshare_story(self):
|
||||||
socialsubs = MSocialSubscription.objects.filter(subscription_user_id=self.user_id,
|
socialsubs = MSocialSubscription.objects.filter(subscription_user_id=self.user_id,
|
||||||
|
@ -1763,7 +1763,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
shared_feed_ids=shared_feed_ids)
|
shared_feed_ids=shared_feed_ids)
|
||||||
shared = 0
|
shared = 0
|
||||||
|
|
||||||
for story_hash, story_info in shared_stories_today.items():
|
for story_hash, story_info in list(shared_stories_today.items()):
|
||||||
story, _ = MStory.find_story(story_info['feed_id'], story_info['story_hash'])
|
story, _ = MStory.find_story(story_info['feed_id'], story_info['story_hash'])
|
||||||
if not story:
|
if not story:
|
||||||
logging.user(popular_user, "~FRPopular stories, story not found: %s" % story_info)
|
logging.user(popular_user, "~FRPopular stories, story not found: %s" % story_info)
|
||||||
|
@ -1774,10 +1774,10 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
|
|
||||||
if interactive:
|
if interactive:
|
||||||
feed = Feed.get_by_id(story.story_feed_id)
|
feed = Feed.get_by_id(story.story_feed_id)
|
||||||
accept_story = raw_input("%s / %s [Y/n]: " % (story.decoded_story_title, feed.title))
|
accept_story = input("%s / %s [Y/n]: " % (story.decoded_story_title, feed.title))
|
||||||
if accept_story in ['n', 'N']: continue
|
if accept_story in ['n', 'N']: continue
|
||||||
|
|
||||||
story_db = dict([(k, v) for k, v in story._data.items()
|
story_db = dict([(k, v) for k, v in list(story._data.items())
|
||||||
if k is not None and v is not None])
|
if k is not None and v is not None])
|
||||||
story_db.pop('user_id', None)
|
story_db.pop('user_id', None)
|
||||||
story_db.pop('id', None)
|
story_db.pop('id', None)
|
||||||
|
@ -1835,7 +1835,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
if drop:
|
if drop:
|
||||||
for key_name in ["C", "S"]:
|
for key_name in ["C", "S"]:
|
||||||
keys = r.keys("%s:*" % key_name)
|
keys = r.keys("%s:*" % key_name)
|
||||||
print " ---> Removing %s keys named %s:*" % (len(keys), key_name)
|
print(" ---> Removing %s keys named %s:*" % (len(keys), key_name))
|
||||||
for key in keys:
|
for key in keys:
|
||||||
r.delete(key)
|
r.delete(key)
|
||||||
for story in cls.objects.all():
|
for story in cls.objects.all():
|
||||||
|
@ -1947,7 +1947,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
'story_hash': story['story_hash'],
|
'story_hash': story['story_hash'],
|
||||||
'user_id__in': sharer_user_ids,
|
'user_id__in': sharer_user_ids,
|
||||||
}
|
}
|
||||||
if params.has_key('story_db_id'):
|
if 'story_db_id' in params:
|
||||||
params.pop('story_db_id')
|
params.pop('story_db_id')
|
||||||
shared_stories = cls.objects.filter(**params)\
|
shared_stories = cls.objects.filter(**params)\
|
||||||
.hint([('story_hash', 1)])
|
.hint([('story_hash', 1)])
|
||||||
|
@ -2331,7 +2331,7 @@ class MSharedStory(mongo.DynamicDocument):
|
||||||
try:
|
try:
|
||||||
datastream = StringIO(req.content)
|
datastream = StringIO(req.content)
|
||||||
width, height = ImageOps.image_size(datastream)
|
width, height = ImageOps.image_size(datastream)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
logging.debug(" ***> Couldn't read image: %s / %s" % (e, image_source))
|
logging.debug(" ***> Couldn't read image: %s / %s" % (e, image_source))
|
||||||
datastream = StringIO(req.content[:100])
|
datastream = StringIO(req.content[:100])
|
||||||
_, width, height = image_size(datastream)
|
_, width, height = image_size(datastream)
|
||||||
|
@ -2502,7 +2502,7 @@ class MSocialServices(mongo.Document):
|
||||||
api = self.twitter_api()
|
api = self.twitter_api()
|
||||||
try:
|
try:
|
||||||
twitter_user = api.me()
|
twitter_user = api.me()
|
||||||
except tweepy.TweepError, e:
|
except tweepy.TweepError as e:
|
||||||
api = None
|
api = None
|
||||||
|
|
||||||
if not api:
|
if not api:
|
||||||
|
@ -2528,8 +2528,8 @@ class MSocialServices(mongo.Document):
|
||||||
self.set_photo('twitter')
|
self.set_photo('twitter')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
friend_ids = list(unicode(friend.id) for friend in tweepy.Cursor(api.friends).items())
|
friend_ids = list(str(friend.id) for friend in list(tweepy.Cursor(api.friends).items()))
|
||||||
except tweepy.TweepError, e:
|
except tweepy.TweepError as e:
|
||||||
logging.user(user, "~BG~FMTwitter import ~SBfailed~SN: %s" % e)
|
logging.user(user, "~BG~FMTwitter import ~SBfailed~SN: %s" % e)
|
||||||
return
|
return
|
||||||
if not friend_ids:
|
if not friend_ids:
|
||||||
|
@ -2589,7 +2589,7 @@ class MSocialServices(mongo.Document):
|
||||||
self.save()
|
self.save()
|
||||||
return
|
return
|
||||||
|
|
||||||
facebook_friend_ids = [unicode(friend["id"]) for friend in friends["data"]]
|
facebook_friend_ids = [str(friend["id"]) for friend in friends["data"]]
|
||||||
self.facebook_friend_ids = facebook_friend_ids
|
self.facebook_friend_ids = facebook_friend_ids
|
||||||
self.facebook_refresh_date = datetime.datetime.utcnow()
|
self.facebook_refresh_date = datetime.datetime.utcnow()
|
||||||
self.facebook_picture_url = "https://graph.facebook.com/%s/picture" % self.facebook_uid
|
self.facebook_picture_url = "https://graph.facebook.com/%s/picture" % self.facebook_uid
|
||||||
|
@ -2760,7 +2760,7 @@ class MSocialServices(mongo.Document):
|
||||||
week_ago = datetime.datetime.now() - datetime.timedelta(days=days)
|
week_ago = datetime.datetime.now() - datetime.timedelta(days=days)
|
||||||
shares = MSharedStory.objects.filter(shared_date__gte=week_ago)
|
shares = MSharedStory.objects.filter(shared_date__gte=week_ago)
|
||||||
sharers = sorted(set([s.user_id for s in shares]))
|
sharers = sorted(set([s.user_id for s in shares]))
|
||||||
print " ---> %s sharing user_ids" % len(sorted(sharers))
|
print(" ---> %s sharing user_ids" % len(sorted(sharers)))
|
||||||
|
|
||||||
for user_id in sharers:
|
for user_id in sharers:
|
||||||
try:
|
try:
|
||||||
|
@ -2771,9 +2771,9 @@ class MSocialServices(mongo.Document):
|
||||||
ss = MSocialServices.objects.get(user_id=user_id)
|
ss = MSocialServices.objects.get(user_id=user_id)
|
||||||
try:
|
try:
|
||||||
ss.sync_twitter_photo()
|
ss.sync_twitter_photo()
|
||||||
print " ---> Syncing %s" % user_id
|
print(" ---> Syncing %s" % user_id)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print " ***> Exception on %s: %s" % (user_id, e)
|
print(" ***> Exception on %s: %s" % (user_id, e))
|
||||||
|
|
||||||
def sync_twitter_photo(self):
|
def sync_twitter_photo(self):
|
||||||
profile = MSocialProfile.get_user(self.user_id)
|
profile = MSocialProfile.get_user(self.user_id)
|
||||||
|
@ -2787,7 +2787,7 @@ class MSocialServices(mongo.Document):
|
||||||
try:
|
try:
|
||||||
api = self.twitter_api()
|
api = self.twitter_api()
|
||||||
me = api.me()
|
me = api.me()
|
||||||
except (tweepy.TweepError, TypeError), e:
|
except (tweepy.TweepError, TypeError) as e:
|
||||||
logging.user(user, "~FRException (%s): ~FCsetting to blank profile photo" % e)
|
logging.user(user, "~FRException (%s): ~FCsetting to blank profile photo" % e)
|
||||||
self.twitter_picture_url = None
|
self.twitter_picture_url = None
|
||||||
self.set_photo("nothing")
|
self.set_photo("nothing")
|
||||||
|
@ -2809,7 +2809,7 @@ class MSocialServices(mongo.Document):
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
else:
|
else:
|
||||||
api.update_status(status=message)
|
api.update_status(status=message)
|
||||||
except tweepy.TweepError, e:
|
except tweepy.TweepError as e:
|
||||||
user = User.objects.get(pk=self.user_id)
|
user = User.objects.get(pk=self.user_id)
|
||||||
logging.user(user, "~FRTwitter error: ~SB%s" % e)
|
logging.user(user, "~FRTwitter error: ~SB%s" % e)
|
||||||
return
|
return
|
||||||
|
@ -2823,7 +2823,7 @@ class MSocialServices(mongo.Document):
|
||||||
logging.user(user, "~FCFetching image for twitter: ~SB%s" % shared_story.image_urls[0])
|
logging.user(user, "~FCFetching image for twitter: ~SB%s" % shared_story.image_urls[0])
|
||||||
|
|
||||||
url = shared_story.image_urls[0]
|
url = shared_story.image_urls[0]
|
||||||
image_filename = os.path.basename(urlparse.urlparse(url).path)
|
image_filename = os.path.basename(urllib.parse.urlparse(url).path)
|
||||||
req = requests.get(url, stream=True)
|
req = requests.get(url, stream=True)
|
||||||
filename = "/tmp/%s-%s" % (shared_story.story_hash, image_filename)
|
filename = "/tmp/%s-%s" % (shared_story.story_hash, image_filename)
|
||||||
|
|
||||||
|
@ -2851,7 +2851,7 @@ class MSocialServices(mongo.Document):
|
||||||
website=shared_story.blurblog_permalink(),
|
website=shared_story.blurblog_permalink(),
|
||||||
message=message,
|
message=message,
|
||||||
)
|
)
|
||||||
except facebook.GraphAPIError, e:
|
except facebook.GraphAPIError as e:
|
||||||
logging.debug("---> ~SN~FMFacebook posting error, disconnecting: ~SB~FR%s" % e)
|
logging.debug("---> ~SN~FMFacebook posting error, disconnecting: ~SB~FR%s" % e)
|
||||||
self.disconnect_facebook()
|
self.disconnect_facebook()
|
||||||
return
|
return
|
||||||
|
@ -2867,8 +2867,8 @@ class MSocialServices(mongo.Document):
|
||||||
'text': shared_story.decoded_story_title,
|
'text': shared_story.decoded_story_title,
|
||||||
'url': shared_story.blurblog_permalink()
|
'url': shared_story.blurblog_permalink()
|
||||||
}])
|
}])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
4
vendor/paypal/standard/ipn/models.py
vendored
4
vendor/paypal/standard/ipn/models.py
vendored
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from six import b
|
from six import b
|
||||||
from six.moves.urllib.request import urlopen
|
from six.moves.urllib.request import urlopen
|
||||||
|
@ -11,7 +11,7 @@ from vendor.paypal.standard.ipn.signals import payment_was_flagged, payment_was_
|
||||||
|
|
||||||
class PayPalIPN(PayPalStandardBase):
|
class PayPalIPN(PayPalStandardBase):
|
||||||
"""Logs PayPal IPN interactions."""
|
"""Logs PayPal IPN interactions."""
|
||||||
format = u"<IPN: %s %s>"
|
format = "<IPN: %s %s>"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "paypal_ipn"
|
db_table = "paypal_ipn"
|
||||||
|
|
2
vendor/paypal/standard/pdt/models.py
vendored
2
vendor/paypal/standard/pdt/models.py
vendored
|
@ -26,7 +26,7 @@ except:
|
||||||
|
|
||||||
|
|
||||||
class PayPalPDT(PayPalStandardBase):
|
class PayPalPDT(PayPalStandardBase):
|
||||||
format = u"<PDT: %s %s>"
|
format = "<PDT: %s %s>"
|
||||||
|
|
||||||
amt = models.DecimalField(max_digits=64, decimal_places=2, default=0, blank=True, null=True)
|
amt = models.DecimalField(max_digits=64, decimal_places=2, default=0, blank=True, null=True)
|
||||||
cm = models.CharField(max_length=255, blank=True)
|
cm = models.CharField(max_length=255, blank=True)
|
||||||
|
|
6
vendor/zebra/models.py
vendored
6
vendor/zebra/models.py
vendored
|
@ -11,7 +11,7 @@ class StripeCustomer(models.Model, mixins.StripeMixin, mixins.StripeCustomerMixi
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s" % self.stripe_customer_id
|
return "%s" % self.stripe_customer_id
|
||||||
|
|
||||||
|
|
||||||
class StripePlan(models.Model, mixins.StripeMixin, mixins.StripePlanMixin):
|
class StripePlan(models.Model, mixins.StripeMixin, mixins.StripePlanMixin):
|
||||||
|
@ -21,7 +21,7 @@ class StripePlan(models.Model, mixins.StripeMixin, mixins.StripePlanMixin):
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s" % self.stripe_plan_id
|
return "%s" % self.stripe_plan_id
|
||||||
|
|
||||||
|
|
||||||
class StripeSubscription(models.Model, mixins.StripeMixin, mixins.StripeSubscriptionMixin):
|
class StripeSubscription(models.Model, mixins.StripeMixin, mixins.StripeSubscriptionMixin):
|
||||||
|
@ -53,7 +53,7 @@ if options.ZEBRA_ENABLE_APP:
|
||||||
plan = models.ForeignKey(Plan, on_delete=models.CASCADE)
|
plan = models.ForeignKey(Plan, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s: %s" % (self.customer, self.plan)
|
return "%s: %s" % (self.customer, self.plan)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stripe_customer(self):
|
def stripe_customer(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue