PEP 8, PEP 328. I feel better now.

pull/1/head
Andromeda Yelton 2013-06-03 12:31:39 -04:00
parent 4354d3abee
commit ad69580b2d
64 changed files with 609 additions and 345 deletions

View File

@ -1,23 +1,41 @@
"""
external library imports
"""
import pickle
"""
django imports"""
from django import forms
from django.contrib.auth.models import User
from django.contrib.admin import ModelAdmin
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.models import User
from djcelery.admin import (
TaskState,
WorkerState,
TaskMonitor,
WorkerMonitor,
IntervalSchedule,
CrontabSchedule,
PeriodicTask,
PeriodicTaskAdmin
)
from notification.admin import NoticeTypeAdmin, NoticeSettingAdmin, NoticeAdmin
from notification.models import (
NoticeType,
NoticeSetting,
Notice,
ObservedItem,
NoticeQueueBatch
)
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
from regluit.core import models
"""
regluit imports
"""
from regluit import payment
from regluit.core import models
from regluit.core.lookups import PublisherNameLookup, WorkLookup, OwnerLookup
from djcelery.admin import TaskState, WorkerState, TaskMonitor, WorkerMonitor, \
IntervalSchedule, CrontabSchedule, PeriodicTask, PeriodicTaskAdmin
from notification.admin import NoticeTypeAdmin, NoticeSettingAdmin, NoticeAdmin
from notification.models import NoticeType, NoticeSetting, Notice, ObservedItem, NoticeQueueBatch
import pickle
class RegluitAdmin(AdminSite):
login_template = 'registration/login.html'

View File

@ -1,16 +1,16 @@
import logging
from django.contrib import auth
from django.contrib.auth.models import User, AnonymousUser
from django.conf.urls.defaults import url
from django.db.models import Q
from tastypie import fields
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.resources import ModelResource, Resource, Bundle
from tastypie.utils import trailing_slash
from tastypie.authentication import ApiKeyAuthentication, Authentication
from django.conf.urls.defaults import url
from django.contrib import auth
from django.contrib.auth.models import User, AnonymousUser
from django.db.models import Q
from regluit.core import models
logger = logging.getLogger(__name__)

View File

@ -1,13 +1,23 @@
"""
external library imports
"""
import json
from regluit.utils.localdatetime import now
from decimal import Decimal
"""
django imports
"""
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
"""
regluit imports
"""
import regluit.core.isbn
from regluit.core import bookloader, models
import regluit.core.isbn
from regluit.utils.localdatetime import now
class ApiTests(TestCase):
work_id=None

View File

@ -1,9 +1,10 @@
from django.conf.urls.defaults import *
from tastypie.api import Api
from regluit.api.views import ApiHelpView
from django.conf.urls.defaults import *
from django.views.generic.base import TemplateView
from regluit.api import resources
from regluit.api.views import ApiHelpView
v1_api = Api(api_name='v1')
v1_api.register(resources.UserResource())

View File

@ -1,14 +1,15 @@
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from tastypie.models import ApiKey
from django.contrib import auth
from django.contrib.auth.models import User
from django.db.models import Q
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.views.generic.base import TemplateView
from regluit.core import models
import regluit.core.isbn
from tastypie.models import ApiKey
from regluit.core import models
def isbn(request,isbn):
if len(isbn)==10:

View File

@ -1,6 +1,11 @@
import logging
from social_auth.backends.pipeline.social import social_auth_user, load_extra_data
from social_auth.backends.pipeline.social import (
social_auth_user,
load_extra_data
)
from social_auth.models import UserSocialAuth
from regluit.core.models import TWITTER, FACEBOOK
logger = logging.getLogger(__name__)

View File

@ -1,29 +1,33 @@
"""
external library imports
"""
import json
import logging
import requests
from xml.etree import ElementTree
from itertools import izip, islice
from datetime import timedelta
from itertools import izip, islice
from xml.etree import ElementTree
from django.db.models import Q
"""
django imports
"""
from django.conf import settings
from django.db import IntegrityError
from django.contrib.comments.models import Comment
from django.db import IntegrityError
from django.db.models import Q
"""
regluit imports
"""
import regluit
from regluit.core import models
from regluit.utils.localdatetime import now
import regluit.core.isbn
from regluit.core import models
from regluit.utils.localdatetime import now
logger = logging.getLogger(__name__)
def add_by_oclc(isbn, work=None):
# this is indirection in case we have a data source other than google
return add_by_oclc_from_google(isbn)

View File

@ -1,19 +1,28 @@
import re
"""
external library imports
"""
import httplib
import json
import logging
import oauth2 as oauth
import re
from itertools import islice
from requests import request
from urllib import urlencode
from urlparse import urlparse, urlunparse, urljoin
import httplib
import oauth2 as oauth
from requests import request
from xml.etree import ElementTree as ET
"""
django imports
"""
import django.utils.encoding
"""
regluit imports
"""
import regluit.core
from regluit.core import bookloader
from regluit.core import models
from regluit.core import bookloader, models
# import parse_qsl from cgi if it doesn't exist in urlparse
try:

View File

@ -1,14 +1,14 @@
import mechanize
import requests
import csv
import httplib
import HTMLParser
import httplib
import logging
import mechanize
import re
import requests
from datetime import datetime
from regluit.core import models
logger = logging.getLogger(__name__)
class LibraryThingException(Exception):

View File

@ -1,7 +1,6 @@
from django.core.management.base import BaseCommand
from regluit.core import models
from regluit.core import bookloader
from regluit.core import models, bookloader
class Command(BaseCommand):

View File

@ -1,14 +1,14 @@
from django.core.management.base import BaseCommand
import django
from regluit.core.models import Campaign
from regluit.payment.models import Transaction
from django.db.models import Q, F, Count, Sum, Max
from django.contrib.auth.models import User
from regluit.payment.manager import PaymentManager
from decimal import Decimal as D
import django
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from django.db.models import Q, F, Count, Sum, Max
from regluit.core.models import Campaign
from regluit.experimental.gutenberg import unicode_csv
from regluit.payment.models import Transaction
from regluit.payment.manager import PaymentManager
def amazon_payments(fname=r"/Users/raymondyee/Downloads/All-Activity-Jan-01-2012-Jul-17-2012.csv"):
r0 = unicode_csv.UnicodeReader(f=open(fname), encoding="iso-8859-1")

View File

@ -1,11 +1,15 @@
# code modified from http://stackoverflow.com/questions/4734645/is-there-a-tool-to-check-database-integrity-in-django/4736176#4736176
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import NoArgsCommand
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from optparse import make_option
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import (
BaseCommand,
CommandError,
NoArgsCommand
)
from django.db import models
def model_name(model):
return '%s.%s' % (model._meta.app_label, model._meta.object_name)

View File

@ -1,7 +1,8 @@
from django.core.management.base import BaseCommand
from django.db.models import Q, F
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE
from regluit.core import models
from django.db.models import Q, F
class Command(BaseCommand):
help = "Do some integrity checks on our Payments"

View File

@ -1,7 +1,8 @@
from django.core.management.base import BaseCommand
from regluit.core import models
from django.db.models import Q, F
from regluit.core import models
class Command(BaseCommand):
help = "Do a few integrity checks on Works, Editions, and Identifiers"

View File

@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand
from regluit.core import models, bookloader
class Command(BaseCommand):

View File

@ -4,6 +4,7 @@ print user emails
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from regluit.core import models
class Command(BaseCommand):

View File

@ -3,6 +3,7 @@ print user emails
"""
from django.core.management.base import BaseCommand
from regluit.core import models, signals
class Command(BaseCommand):

View File

@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand
from regluit.core import models, bookloader
class Command(BaseCommand):

View File

@ -1,8 +1,10 @@
from django.core.management.base import BaseCommand
from regluit.core.goodreads import GoodreadsClient
from django.conf import settings
from itertools import islice
from django.conf import settings
from django.core.management.base import BaseCommand
from regluit.core.goodreads import GoodreadsClient
class Command(BaseCommand):
help = "list books on given user bookshelf"
args = "<user_id shelf_name max_books>"

View File

@ -1,11 +1,11 @@
from django.core.management.base import BaseCommand
from regluit.core.goodreads import GoodreadsClient
from regluit.core import tasks, bookloader
from django.conf import settings
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from regluit.core import tasks, bookloader
from regluit.core.goodreads import GoodreadsClient
#from regluit.core.goodreads import load_shelf_into_wishlist
from regluit.core import tasks
class Command(BaseCommand):
help = "list books on given user bookshelf"

View File

@ -4,6 +4,7 @@ set the 'pledged' badge for people who've pledged
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from regluit.core.models import Badge
from regluit.payment.models import Transaction

View File

@ -1,8 +1,8 @@
from django.core.management.base import BaseCommand
from regluit.core import librarything
from regluit.core import tasks
from django.conf import settings
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from regluit.core import librarything, tasks
class Command(BaseCommand):
help = "load Librarything books into wishlist"

View File

@ -1,8 +1,8 @@
from django.core.management.base import BaseCommand
from regluit.core import librarything
from regluit.core import tasks
from django.conf import settings
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from regluit.core import librarything, tasks
class Command(BaseCommand):
help = "load Librarything books into wishlist"

View File

@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand
import pickle
import notification
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Displays currently queues notices from django-notification"

View File

@ -4,6 +4,7 @@ Load the Gutenberg editions
"""
from django.core.management.base import BaseCommand
from regluit.core import models
from regluit.test import booktests

View File

@ -4,6 +4,7 @@ list works with no isbn
from django.core.management.base import BaseCommand
from django.db.models import Count
from regluit.core import models
class Command(BaseCommand):

View File

@ -1,17 +1,26 @@
from django.core.management.base import BaseCommand
import django
"""
external library imports
"""
import sys
from regluit.core.models import Campaign
from regluit.payment.models import Transaction
from django.db.models import Q, F, Count, Sum, Max
from django.contrib.auth.models import User
from regluit.payment.manager import PaymentManager
from decimal import Decimal as D
from collections import defaultdict
from decimal import Decimal as D
"""
django imports
"""
import django
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.db.models import Q, F, Count, Sum, Max
"""
regluit imports
"""
from regluit.core.models import Campaign
from regluit.experimental.gutenberg import unicode_csv
from regluit.payment.models import Transaction
from regluit.payment.manager import PaymentManager
# http://stackoverflow.com/questions/2348317/how-to-write-a-pager-for-python-iterators/2350904#2350904
def grouper(iterable, page_size):

View File

@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand
from django.db.models import Q, F, Count, Sum
from regluit.core.models import Campaign
STATS_TEMPLATE = """Total Pledged: {0} by {1} Pledgers

View File

@ -1,13 +1,12 @@
from decimal import Decimal
from random import randint, randrange
from datetime import timedelta
from regluit.utils.localdatetime import now
from decimal import Decimal as D
from random import randint, randrange
from django.conf import settings
from django.core.management.base import BaseCommand
from regluit.core.models import Work, Campaign
from django.conf import settings
from regluit.utils.localdatetime import now
class Command(BaseCommand):
help = "creates random campaigns for any works that lack one for testing"

View File

@ -1,16 +1,14 @@
"""
a command that creates a given number of random tasks to test out celery
"""
from django.core.management.base import BaseCommand
from regluit.core import tasks
from regluit.core.models import CeleryTask
import random
from django.core.management.base import BaseCommand
from regluit.core import tasks
from regluit.core.models import CeleryTask
random.seed()
class Command(BaseCommand):

View File

@ -4,10 +4,12 @@ The signature of both problems is a work with only one related edition, a single
This script goes through all singleton works and attempts to add_related. 'xx' works are excluded from being source works
"""
from itertools import islice
from django.core.management.base import BaseCommand
from django.db.models import Count
from regluit.core import models, bookloader
from itertools import islice
class Command(BaseCommand):
help = "add and merge editions for singleton works"

View File

@ -6,7 +6,6 @@ affected.
from django.core.management.base import BaseCommand
from regluit.test import booktests
class Command(BaseCommand):
help = "Dispose of the Frankenworks and recluster the works. Print out email addresses of those whose wishlists have been affected."
args = "<do>"

View File

@ -1,36 +1,52 @@
'''
external library imports
'''
import binascii
import logging
import hashlib
import re
import random
import logging
import urllib
import hashlib
from regluit.utils.localdatetime import now, date_today
from regluit.utils import crypto
from ckeditor.fields import RichTextField
from datetime import timedelta
from decimal import Decimal
from notification import models as notification
from ckeditor.fields import RichTextField
from postmonkey import PostMonkey, MailChimpException
from django.db import models
from django.db.models import F, Q, get_model
'''
django imports
'''
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.conf import settings
from django.db import models
from django.db.models import F, Q, get_model
from django.utils.translation import ugettext_lazy as _
'''
regluit imports
'''
import regluit
import regluit.core.isbn
from regluit.core.signals import successful_campaign, unsuccessful_campaign, wishlist_added
import binascii
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE, TRANSACTION_STATUS_COMPLETE, TRANSACTION_STATUS_CANCELED, TRANSACTION_STATUS_ERROR, TRANSACTION_STATUS_FAILED, TRANSACTION_STATUS_INCOMPLETE
from regluit.core.signals import (
successful_campaign,
unsuccessful_campaign,
wishlist_added
)
from regluit.utils import crypto
from regluit.utils.localdatetime import now, date_today
from django.db.models import Q
from regluit.payment.parameters import (
TRANSACTION_STATUS_ACTIVE,
TRANSACTION_STATUS_COMPLETE,
TRANSACTION_STATUS_CANCELED,
TRANSACTION_STATUS_ERROR,
TRANSACTION_STATUS_FAILED,
TRANSACTION_STATUS_INCOMPLETE
)
pm = PostMonkey(settings.MAILCHIMP_API_KEY)

View File

@ -1,29 +1,37 @@
from django.db.models import get_model
from django.db.utils import DatabaseError
from django.db.models import signals
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.dispatch import Signal
from django.contrib.sites.models import Site
from django.conf import settings
from django.utils.translation import ugettext_noop as _
"""
external library imports
"""
import datetime
from regluit.utils.localdatetime import now
from notification import models as notification
from social_auth.signals import pre_update
from social_auth.backends.facebook import FacebookBackend
from tastypie.models import create_api_key
from regluit.payment.signals import transaction_charged, transaction_failed, pledge_modified, pledge_created
import registration.signals
import django.dispatch
import itertools
import logging
from tastypie.models import create_api_key
"""
django imports
"""
import django.dispatch
import registration.signals
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.db.models import get_model, signals
from django.db.models.signals import post_save
from django.db.utils import DatabaseError
from django.dispatch import Signal
from django.utils.translation import ugettext_noop as _
from notification import models as notification
from social_auth.signals import pre_update
from social_auth.backends.facebook import FacebookBackend
"""
regluit imports
"""
from regluit.payment.signals import transaction_charged, transaction_failed, pledge_modified, pledge_created
from regluit.utils.localdatetime import now
logger = logging.getLogger(__name__)
# get email from Facebook registration

View File

@ -1,24 +1,35 @@
from time import sleep
from datetime import timedelta
"""
external library imports
"""
import logging
logger = logging.getLogger(__name__)
from celery.task import task
from datetime import timedelta
from time import sleep
from django.contrib.auth.models import User
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.core.mail import send_mail
from notification.engine import send_all
from notification import models as notification
from regluit.core import bookloader, models
from regluit.core import goodreads, librarything
"""
regluit imports
"""
from regluit.core import (
bookloader,
models,
goodreads,
librarything
)
from regluit.core.models import Campaign
from regluit.core.signals import deadline_impending
from regluit.utils.localdatetime import now, date_today
from django.core.mail import send_mail
from notification.engine import send_all
from notification import models as notification
logger = logging.getLogger(__name__)
@task
def populate_edition(isbn):

View File

@ -1,34 +1,58 @@
from decimal import Decimal as D
"""
external library imports
"""
from datetime import datetime, timedelta
from regluit.utils.localdatetime import now, date_today
from decimal import Decimal as D
from math import factorial
from time import sleep, mktime
from urlparse import parse_qs, urlparse
from celery.task import chord
from celery.task.sets import TaskSet
from django.test import TestCase
from django.test.client import Client
from django.utils import unittest
from django.test.utils import override_settings
from django.db import IntegrityError
from django.contrib.auth.models import User
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.comments.models import Comment
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.db import IntegrityError
from django.http import Http404
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
from django.utils import unittest
from regluit.payment.models import Transaction
from regluit.core.models import Campaign, Work, UnglueitError, Edition, RightsHolder, Claim, Key, Ebook, Premium, Subject, Publisher
from regluit.core import bookloader, models, search, goodreads, librarything
from regluit.core import isbn
from regluit.payment.parameters import PAYMENT_TYPE_AUTHORIZATION
"""
regluit imports
"""
from regluit.core import (
isbn,
bookloader,
models,
search,
goodreads,
librarything,
tasks
)
from regluit.core.models import (
Campaign,
Work,
UnglueitError,
Edition,
RightsHolder,
Claim,
Key,
Ebook,
Premium,
Subject,
Publisher
)
from regluit.frontend.views import safe_get_work
from regluit.core import tasks
from celery.task.sets import TaskSet
from celery.task import chord
from time import sleep, mktime
from math import factorial
from urlparse import parse_qs, urlparse
from regluit.payment.models import Transaction
from regluit.payment.parameters import PAYMENT_TYPE_AUTHORIZATION
from regluit.utils.localdatetime import now, date_today
class BookLoaderTests(TestCase):
def setUp(self):

View File

@ -1,8 +1,10 @@
from regluit.core.models import Campaign
from django.http import HttpResponse
import traceback
from django.db import transaction
import time
import traceback
from django.db import transaction
from django.http import HttpResponse
from regluit.core.models import Campaign
def test_read(request):

1
fabfile.py vendored
View File

@ -1,4 +1,5 @@
from fabric.api import run, local, env, cd
from regluit.sysadmin import aws
# allow us to use our ssh config files (e.g., ~/.ssh/config)

View File

@ -1,27 +1,53 @@
"""
external library imports
"""
import logging
from datetime import timedelta
from decimal import Decimal as D
"""
django imports
"""
from django import forms
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.forms import AuthenticationForm
from django.conf import settings
from django.conf.global_settings import LANGUAGES
from django.contrib.auth.models import User
from django.contrib.auth.forms import AuthenticationForm
from django.core.validators import validate_email
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.forms.widgets import RadioSelect
from django.forms.extras.widgets import SelectDateWidget
from django.utils.translation import ugettext_lazy as _
from decimal import Decimal as D
from selectable.forms import AutoCompleteSelectMultipleWidget,AutoCompleteSelectMultipleField
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
from selectable.forms import (
AutoCompleteSelectMultipleWidget,
AutoCompleteSelectMultipleField,
AutoCompleteSelectWidget,
AutoCompleteSelectField
)
from regluit.core.models import UserProfile, RightsHolder, Claim, Campaign, Premium, Ebook, Edition, PledgeExtra, Work, Press
from regluit.core.models import TWITTER, FACEBOOK, GRAVATAR
"""
regluit imports
"""
from regluit.core.models import (
UserProfile,
RightsHolder,
Claim,
Campaign,
Premium,
Ebook,
Edition,
PledgeExtra,
Work,
Press,
TWITTER,
FACEBOOK,
GRAVATAR
)
from regluit.core.lookups import OwnerLookup, WorkLookup, PublisherNameLookup
from regluit.utils.localdatetime import now
import logging
logger = logging.getLogger(__name__)
class EditionForm(forms.ModelForm):

View File

@ -5,6 +5,7 @@ To use this filter, put "{% load truncatechars %}" at the beginning of your temp
then {{ myvariable|truncatechars:num }}
"""
import unicodedata
from django.template.base import Library
from django.template.defaultfilters import stringfilter
from django.utils.translation import get_language_info

View File

@ -5,6 +5,7 @@ To use this filter, put "{% load truncatechars %}" at the beginning of your temp
then {{ myvariable|truncatechars:num }}
"""
import unicodedata
from django import template
from django.template.base import Library
from django.template.defaultfilters import stringfilter

View File

@ -1,10 +1,11 @@
"""
{{ raw|urldecode }}
"""
from django.template.defaultfilters import stringfilter
from django.template.base import Library
from urllib import unquote
from django.template.base import Library
from django.template.defaultfilters import stringfilter
register = Library()
@register.filter()

View File

@ -1,24 +1,33 @@
"""
external library imports
"""
import json
import re
import time
from datetime import timedelta
from decimal import Decimal as D
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.core import mail
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.conf import settings
from django.core import mail
from notification.models import Notice
"""
regluit imports
"""
from regluit.core.models import Work, Campaign, RightsHolder, Claim
from regluit.payment.models import Transaction
from regluit.payment.manager import PaymentManager
from regluit.payment.stripelib import StripeClient, TEST_CARDS, ERROR_TESTING, card
from notification.models import Notice
from decimal import Decimal as D
from regluit.utils.localdatetime import now
from datetime import timedelta
import time
import json
class WishlistTests(TestCase):

View File

@ -1,11 +1,11 @@
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.views.generic.base import TemplateView
from django.views.generic import ListView, DetailView
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required
from django.contrib.sites.models import Site
from django.views.generic import ListView, DetailView
from django.views.generic.base import TemplateView
from django.views.generic.simple import direct_to_template
from django.views.decorators.csrf import csrf_exempt
from regluit.core.feeds import SupporterWishlistFeed
from regluit.core.models import Campaign

View File

@ -1,5 +1,5 @@
'''
imports not from django or regluit
external library imports
'''
import re
import sys
@ -23,9 +23,9 @@ django imports
'''
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib.auth.views import login
from django.contrib.comments import Comment
from django.contrib.sites.models import Site
@ -36,10 +36,13 @@ from django.core.mail import EmailMessage
from django.core.urlresolvers import reverse
from django.db.models import Q, Count, Sum
from django.forms import Select
from django.forms.models import modelformset_factory
from django.forms.models import inlineformset_factory
from django.http import HttpResponseRedirect, Http404
from django.http import HttpResponse, HttpResponseNotFound
from django.forms.models import modelformset_factory, inlineformset_factory
from django.http import (
HttpResponseRedirect,
Http404,
HttpResponse,
HttpResponseNotFound
)
from django.shortcuts import render, render_to_response, get_object_or_404
from django.template import TemplateDoesNotExist
from django.template.loader import render_to_string
@ -54,10 +57,14 @@ from django.views.generic.base import TemplateView
'''
regluit imports
'''
from regluit.core import tasks
from regluit.core import models, bookloader, librarything
from regluit.core import userlists
from regluit.core import goodreads
from regluit.core import (
tasks,
models,
bookloader,
librarything,
userlists,
goodreads
)
from regluit.core.bookloader import merge_works, detach_edition
from regluit.core.goodreads import GoodreadsClient
from regluit.core.search import gluejar_search

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:

View File

@ -1,12 +1,22 @@
from regluit.payment.models import PaymentResponse
from django.http import HttpResponseForbidden
from datetime import timedelta
from regluit.utils.localdatetime import now, zuluformat
"""
external library imports
"""
import datetime
import time
from datetime import timedelta
"""
django imports
"""
from django.http import HttpResponseForbidden
"""
regluit imports
"""
from regluit.payment.models import PaymentResponse
from regluit.utils.localdatetime import now, zuluformat
class ProcessorError(Exception):
"""An abstraction around payment processor exceptions"""
def __init__(self, message=None, original_exception=None):

View File

@ -1,12 +1,11 @@
from datetime import timedelta
from django.contrib.auth.models import User
from django.conf import settings
from django.contrib.auth.models import User
from regluit.payment.parameters import *
from regluit.payment import baseprocessor
from regluit.payment.baseprocessor import BasePaymentRequest
from regluit.payment.parameters import *
def pledge_transaction(t,user,amount):
"""commit <amount> from a <user>'s credit to a specified transaction <t>"""

View File

@ -1,6 +1,7 @@
from django import forms
import logging
from django import forms
logger = logging.getLogger(__name__)
class StripePledgeForm(forms.Form):

View File

@ -1,7 +1,8 @@
from pprint import pprint
from django.core.management.base import BaseCommand
import regluit
from pprint import pprint
class Command(BaseCommand):
help = "clear all transactions"

View File

@ -1,7 +1,9 @@
from django.core.management.base import BaseCommand
from regluit.payment import stripelib
from decimal import Decimal as D
from django.core.management.base import BaseCommand
from regluit.payment import stripelib
class Command(BaseCommand):
help = "create a credit card record and charge it -- for testing"

View File

@ -1,7 +1,8 @@
from pprint import pprint
from django.core.management.base import BaseCommand
import regluit
from pprint import pprint
class Command(BaseCommand):
help = "show current status of transactions"

View File

@ -1,23 +1,32 @@
from regluit.payment.models import Transaction, Receiver, PaymentResponse, Account
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.conf import settings
from regluit.payment.parameters import *
from regluit.payment.signals import transaction_charged, pledge_modified, pledge_created
from regluit.payment import credit
import uuid
import traceback
from regluit.utils.localdatetime import now
from dateutil.relativedelta import relativedelta
"""
external library imports
"""
import logging
import traceback
import urllib
import urlparse
import uuid
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from decimal import Decimal as D
from xml.dom import minidom
import urllib, urlparse
from datetime import timedelta
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
"""
regluit imports
"""
from regluit.payment import credit
from regluit.payment.models import Transaction, Receiver, PaymentResponse, Account
from regluit.payment.parameters import *
from regluit.payment.signals import transaction_charged, pledge_modified, pledge_created
from regluit.utils.localdatetime import now
logger = logging.getLogger(__name__)

View File

@ -1,19 +1,29 @@
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
from django.db.models import Q
from regluit.payment.parameters import *
from regluit.payment.signals import credit_balance_added, pledge_created
from regluit.utils.localdatetime import now
from django.db.models.signals import post_save, post_delete
from decimal import Decimal
"""
external library imports
"""
import datetime
import uuid
import urllib
import logging
from decimal import Decimal
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Q
from django.db.models.signals import post_save, post_delete
"""
regluit imports
"""
from regluit.payment.parameters import *
from regluit.payment.signals import credit_balance_added, pledge_created
from regluit.utils.localdatetime import now
logger = logging.getLogger(__name__)
# in fitting stripe -- here are possible fields to fit in with Transaction

View File

@ -1,4 +1,5 @@
from notification import models as notification
from django.dispatch import Signal
transaction_charged = Signal(providing_args=["transaction"])

View File

@ -1,27 +1,41 @@
# https://github.com/stripe/stripe-python
# https://stripe.com/docs/api?lang=python#top
"""
external library imports
"""
import logging
import json
from datetime import datetime, timedelta
from pytz import utc
from itertools import islice
import re
from django.conf import settings
from django.http import HttpResponse
from django.core.mail import send_mail
from regluit.payment.models import Account, Transaction, PaymentResponse
from regluit.payment.parameters import PAYMENT_HOST_STRIPE
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE, TRANSACTION_STATUS_COMPLETE, TRANSACTION_STATUS_ERROR, PAYMENT_TYPE_AUTHORIZATION, TRANSACTION_STATUS_CANCELED
from regluit.payment import baseprocessor
from regluit.payment.signals import transaction_charged, transaction_failed
from regluit.utils.localdatetime import now, zuluformat
import stripe
from datetime import datetime, timedelta
from itertools import islice
from pytz import utc
"""
django imports
"""
from django.conf import settings
from django.core.mail import send_mail
from django.http import HttpResponse
"""
regluit imports
"""
from regluit.payment import baseprocessor
from regluit.payment.models import Account, Transaction, PaymentResponse
from regluit.payment.parameters import (
PAYMENT_HOST_STRIPE,
TRANSACTION_STATUS_ACTIVE,
TRANSACTION_STATUS_COMPLETE,
TRANSACTION_STATUS_ERROR,
PAYMENT_TYPE_AUTHORIZATION,
TRANSACTION_STATUS_CANCELED
)
from regluit.payment.signals import transaction_charged, transaction_failed
from regluit.utils.localdatetime import now, zuluformat
# as of 2012.11.05
STRIPE_EVENT_TYPES = ['account.updated', 'account.application.deauthorized',
'charge.succeeded', 'charge.failed', 'charge.refunded', 'charge.disputed',

View File

@ -1,30 +1,35 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
external library imports
"""
from django.test import TestCase
from django.utils import unittest
from django.conf import settings
from django.contrib.auth.models import User
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction, Account
from regluit.core.models import Campaign, Wishlist, Work
from regluit.core.signals import handle_transaction_charged
from regluit.payment.parameters import *
import traceback
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import logging
import os
from decimal import Decimal as D
from regluit.utils.localdatetime import now
import time
import traceback
from datetime import timedelta
from decimal import Decimal as D
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
"""
django imports
"""
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.test import TestCase
from django.utils import unittest
"""
regluit imports
"""
from regluit.core.models import Campaign, Wishlist, Work
from regluit.core.signals import handle_transaction_charged
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction, Account
from regluit.payment.parameters import *
from regluit.utils.localdatetime import now
def setup_selenium():
# Set the display window for our xvfb

View File

@ -1,5 +1,6 @@
from django.conf.urls.defaults import *
from django.conf import settings
from django.conf.urls.defaults import *
from regluit.payment.views import StripeView
urlpatterns = patterns(

View File

@ -1,34 +1,45 @@
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction
from regluit.core.models import Campaign, Wishlist
"""
external library imports
"""
import logging
import traceback
import uuid
from regluit.payment.stripelib import STRIPE_PK
from regluit.payment.forms import StripePledgeForm
from decimal import Decimal as D
from unittest import TestResult
"""
django imports
"""
from django.conf import settings
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.contrib.auth.models import User
from django.contrib.sites.models import RequestSite
from regluit.payment.parameters import *
from django.http import HttpResponse, HttpRequest, HttpResponseRedirect, HttpResponseBadRequest
from django.views.decorators.csrf import csrf_exempt
from django.test.utils import setup_test_environment
from django.core.urlresolvers import reverse
from django.http import (
HttpResponse,
HttpRequest,
HttpResponseRedirect,
HttpResponseBadRequest
)
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.test.utils import setup_test_environment
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.edit import FormView
from django.views.generic.base import TemplateView
from unittest import TestResult
"""
regluit imports
"""
from regluit.core.models import Campaign, Wishlist
from regluit.payment.forms import StripePledgeForm
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction
from regluit.payment.parameters import *
from regluit.payment.stripelib import STRIPE_PK
from regluit.payment.tests import PledgeTest, AuthorizeTest
import uuid
from decimal import Decimal as D
from regluit.utils.localdatetime import now
import traceback
import logging
logger = logging.getLogger(__name__)
# parameterize some test recipients
@ -36,7 +47,6 @@ TEST_RECEIVERS = ['seller_1317463643_biz@gmail.com', 'buyer5_1325740224_per@gmai
#TEST_RECEIVERS = ['seller_1317463643_biz@gmail.com', 'Buyer6_1325742408_per@gmail.com']
#TEST_RECEIVERS = ['glueja_1317336101_biz@gluejar.com', 'rh1_1317336251_biz@gluejar.com', 'RH2_1317336302_biz@gluejar.com']
'''
http://BASE/querycampaign?id=2

View File

@ -1,6 +1,7 @@
from os.path import dirname, realpath, join
import regluit
import datetime
from os.path import dirname, realpath, join
import regluit
from regluit.payment.parameters import PAYMENT_HOST_PAYPAL, PAYMENT_HOST_AMAZON
PROJECT_DIR = dirname(dirname(realpath(__file__)))

View File

@ -1,20 +1,30 @@
from regluit.core import librarything, bookloader, models, tasks
"""
external library imports
"""
import datetime
import json
import logging
import warnings
from collections import OrderedDict, defaultdict, namedtuple
from datetime import datetime
from itertools import izip, islice, repeat
"""
django imports
"""
import django
from django.db.models import Q, F
from regluit.core import bookloader
from django.contrib.comments.models import Comment
from django.db.models import Q, F
import warnings
import datetime
"""
regluit imports
"""
from regluit import experimental
from regluit.core import librarything, bookloader, models, tasks
from regluit.experimental import bookdata
from datetime import datetime
import json
import logging
logger = logging.getLogger(__name__)
def dictset(itertuple):

View File

@ -1,19 +1,29 @@
from regluit.core import models
from regluit.payment.models import Transaction, PaymentResponse, Receiver
from regluit.payment.manager import PaymentManager
"""
external library imports
"""
import logging
import os
import re
import time
import unittest
from regluit.payment import stripelib
from selenium import selenium, webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
"""
django imports
"""
import django
from django.conf import settings
from selenium import selenium, webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
import logging
import os
"""
regluit imports
"""
from regluit.core import models
from regluit.payment import stripelib
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction, PaymentResponse, Receiver
def setup_selenium():
# Set the display window for our xvfb

View File

@ -1,7 +1,8 @@
from regluit.core import models
from itertools import izip
from django.db.models import Count
from itertools import izip
from regluit.core import models
def list_popular():
"""Compare calculating popular works using QuerySets + distinct() and order_by() with an alternate approach """

View File

@ -1,9 +1,11 @@
import notification.urls
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from frontend.forms import ProfileForm
from frontend.views import superlogin
from django.views.generic.simple import direct_to_template
from regluit.admin import admin_site
import notification.urls
from regluit.core.sitemaps import WorkSitemap, PublisherSitemap
sitemaps = {