Merge pull request #557 from Gluejar/dj16

Django 1.6+ compatibility
pull/1/head
Raymond Yee 2016-05-10 09:22:19 -07:00
commit bff6092565
33 changed files with 199 additions and 149 deletions

View File

@ -5,8 +5,9 @@ from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.resources import ModelResource, Resource, Bundle from tastypie.resources import ModelResource, Resource, Bundle
from tastypie.utils import trailing_slash from tastypie.utils import trailing_slash
from tastypie.authentication import ApiKeyAuthentication, Authentication from tastypie.authentication import ApiKeyAuthentication, Authentication
from tastypie.exceptions import BadRequest
from django.conf.urls.defaults import url from django.conf.urls import url
from django.contrib import auth from django.contrib import auth
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -135,22 +136,22 @@ class FreeResource(ModelResource):
bundle.data["href"]=reverse('download_ebook',kwargs={'ebook_id':bundle.obj.id}) bundle.data["href"]=reverse('download_ebook',kwargs={'ebook_id':bundle.obj.id})
return bundle return bundle
def obj_get_list(self, request=None, **kwargs): def obj_get_list(self, bundle, **kwargs):
request = bundle.request
isbn ="" isbn =""
if hasattr(request, 'GET'): if hasattr(request, 'GET'):
isbn = request.GET.get("isbn","") isbn = request.GET.get("isbn","")
isbn = isbn.replace('-','') isbn = isbn.replace('-','')
if len(isbn)==10: if len(isbn)==10:
isbn=regluit.core.isbn.convert_10_to_13(isbn) isbn=regluit.core.isbn.convert_10_to_13(isbn)
try: try:
work=models.Identifier.objects.get(type='isbn',value=isbn,).work work=models.Identifier.objects.get(type='isbn',value=isbn,).work
base_object_list = models.Ebook.objects.filter(edition__work=work) base_object_list = models.Ebook.objects.filter(edition__work=work)
return self.apply_authorization_limits(request, base_object_list) return base_object_list
except ValueError: except ValueError:
raise BadRequest("Invalid resource lookup data provided (mismatched type).") raise BadRequest("Invalid resource lookup data provided (mismatched type).")
except models.Identifier.DoesNotExist: except models.Identifier.DoesNotExist:
return self.apply_authorization_limits(request, models.Ebook.objects.none()) return models.Ebook.objects.none()
class Meta: class Meta:
authentication = ApiKeyAuthentication() authentication = ApiKeyAuthentication()

View File

@ -21,6 +21,7 @@ from regluit.utils.localdatetime import now
from regluit.api import models as apimodels from regluit.api import models as apimodels
class ApiTests(TestCase): class ApiTests(TestCase):
fixtures = ['initial_data.json']
work_id=None work_id=None
def setUp(self): def setUp(self):
@ -135,6 +136,13 @@ class ApiTests(TestCase):
}) })
j = json.loads(r.content) j = json.loads(r.content)
self.assertEqual(j['objects'][0]['filetype'], 'epub') self.assertEqual(j['objects'][0]['filetype'], 'epub')
r = self.client.get('/api/v1/free/', data={
'format': 'xml',
'isbn': '0441007465',
'username': self.user.username,
'api_key': self.user.api_key.key
})
self.assertTrue(r.content.find('<rights>CC BY</rights>')>0)
def test_widget(self): def test_widget(self):
r = self.client.get('/api/widget/0441007465/') r = self.client.get('/api/widget/0441007465/')

View File

@ -1,6 +1,6 @@
from tastypie.api import Api from tastypie.api import Api
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from regluit.api import resources from regluit.api import resources

View File

@ -1,4 +1,4 @@
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
urlpatterns = patterns("", urlpatterns = patterns("",
url(r"^tree$", "regluit.bisac.views.tree"), url(r"^tree$", "regluit.bisac.views.tree"),

View File

@ -1751,7 +1751,7 @@ class Edition(models.Model):
publication_date = models.CharField(max_length=50, null=True, blank=True, db_index=True,) publication_date = models.CharField(max_length=50, null=True, blank=True, db_index=True,)
work = models.ForeignKey("Work", related_name="editions", null=True) work = models.ForeignKey("Work", related_name="editions", null=True)
cover_image = models.URLField(null=True, blank=True) cover_image = models.URLField(null=True, blank=True)
unglued = models.BooleanField(blank=True) unglued = models.BooleanField(default=False)
def __unicode__(self): def __unicode__(self):
if self.isbn_13: if self.isbn_13:

View File

@ -22,6 +22,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.core.files import File as DjangoFile from django.core.files import File as DjangoFile
from django.db import IntegrityError from django.db import IntegrityError
from django.db import transaction
from django.http import Http404 from django.http import Http404
from django.test import TestCase from django.test import TestCase
from django.test.client import Client from django.test.client import Client
@ -485,7 +486,7 @@ class SearchTests(TestCase):
class CampaignTests(TestCase): class CampaignTests(TestCase):
fixtures = ['initial_data.json']
def test_b2u(self): def test_b2u(self):
w = Work() w = Work()
w.save() w.save()
@ -511,15 +512,16 @@ class CampaignTests(TestCase):
def test_required_fields(self): def test_required_fields(self):
# a campaign must have a target, deadline and a work # a campaign must have a target, deadline and a work
# see http://stackoverflow.com/questions/21458387/transactionmanagementerror-you-cant-execute-queries-until-the-end-of-the-atom
c = Campaign() with transaction.atomic():
self.assertRaises(IntegrityError, c.save) c = Campaign()
self.assertRaises(IntegrityError, c.save)
c = Campaign(target=D('1000.00')) with transaction.atomic():
self.assertRaises(IntegrityError, c.save) c = Campaign(target=D('1000.00'))
self.assertRaises(IntegrityError, c.save)
c = Campaign(target=D('1000.00'), deadline=datetime(2013, 1, 1)) with transaction.atomic():
self.assertRaises(IntegrityError, c.save) c = Campaign(target=D('1000.00'), deadline=datetime(2013, 1, 1))
self.assertRaises(IntegrityError, c.save)
w = Work() w = Work()
w.save() w.save()
@ -815,6 +817,7 @@ class WorkTests(TestCase):
class DownloadPageTest(TestCase): class DownloadPageTest(TestCase):
fixtures = ['initial_data.json']
def test_download_page(self): def test_download_page(self):
w = models.Work() w = models.Work()
w.save() w.save()
@ -902,7 +905,7 @@ class MailingListTests(TestCase):
@override_settings(LOCAL_TEST=True) @override_settings(LOCAL_TEST=True)
class EbookFileTests(TestCase): class EbookFileTests(TestCase):
fixtures = ['initial_data.json']
def test_badepub_errors(self): def test_badepub_errors(self):
textfile = NamedTemporaryFile(delete=False) textfile = NamedTemporaryFile(delete=False)
textfile.write("bad text file") textfile.write("bad text file")
@ -1041,7 +1044,7 @@ class MobigenTests(TestCase):
from .signals import handle_transaction_charged from .signals import handle_transaction_charged
@override_settings(LOCAL_TEST=True) @override_settings(LOCAL_TEST=True)
class LibTests(TestCase): class LibTests(TestCase):
fixtures = ['initial_data.json']
class transaction: class transaction:
pass pass

View File

@ -2,8 +2,8 @@
import os import os
import django.core.handlers.wsgi os.environ.setdefault("DJANGO_SETTINGS_MODULE", "regluit.settings.please")
os.environ['CELERY_LOADER'] = 'django' os.environ['CELERY_LOADER'] = 'django'
os.environ['DJANGO_SETTINGS_MODULE'] = 'regluit.settings.please'
application = django.core.handlers.wsgi.WSGIHandler() from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

2
fabfile.py vendored
View File

@ -95,7 +95,7 @@ def email_addresses():
def selenium(): def selenium():
"""setting up selenium to run in the background on RY's laptop""" """setting up selenium to run in the background on RY's laptop"""
with cd('/Users/raymondyee/D/Document/Gluejar/Gluejar.github/regluit'): with cd('/Users/raymondyee/D/Document/Gluejar/Gluejar.github/regluit'):
local("java -jar test/selenium-server-standalone-2.50.0.jar > selenium-rc.log 2>&1 &") local("java -jar test/selenium-server-standalone-2.53.0.jar > selenium-rc.log 2>&1 &")
def test(): def test():
"""run regluit tests locally""" """run regluit tests locally"""

View File

@ -184,7 +184,7 @@ class EditionForm(forms.ModelForm):
class Meta: class Meta:
model = Edition model = Edition
exclude = 'created', 'work' exclude = ('created', 'work')
widgets = { widgets = {
'title': forms.TextInput(attrs={'size': 40}), 'title': forms.TextInput(attrs={'size': 40}),
'add_author': forms.TextInput(attrs={'size': 30}), 'add_author': forms.TextInput(attrs={'size': 30}),
@ -269,7 +269,7 @@ def UserClaimForm ( user_instance, *args, **kwargs ):
class Meta: class Meta:
model = Claim model = Claim
exclude = 'status' exclude = ('status',)
widgets = { widgets = {
'user': forms.HiddenInput, 'user': forms.HiddenInput,
'work': forms.HiddenInput, 'work': forms.HiddenInput,

View File

@ -211,7 +211,8 @@ class PledgingUiTests(TestCase):
pass pass
class UnifiedCampaignTests(TestCase): class UnifiedCampaignTests(TestCase):
fixtures=['basic_campaign_test.json'] fixtures=['initial_data.json','basic_campaign_test.json']
def test_setup(self): def test_setup(self):
# testing basics: are there 3 users? # testing basics: are there 3 users?

View File

@ -1,11 +1,11 @@
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.views.generic import ListView, DetailView from django.views.generic import ListView, DetailView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.simple import direct_to_template #from django.views.generic.simple import direct_to_template
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from regluit.core.feeds import SupporterWishlistFeed from regluit.core.feeds import SupporterWishlistFeed
@ -138,9 +138,9 @@ urlpatterns = patterns(
url(r"^subjects/map/$", login_required(MapSubjectView.as_view()), name="map_subject"), url(r"^subjects/map/$", login_required(MapSubjectView.as_view()), name="map_subject"),
url(r"^librarything/$", LibraryThingView.as_view(), name="librarything"), url(r"^librarything/$", LibraryThingView.as_view(), name="librarything"),
url(r"^librarything/load/$","librarything_load", name="librarything_load"), url(r"^librarything/load/$","librarything_load", name="librarything_load"),
url('^404testing/$', direct_to_template, {'template': '404.html'}), url('^404testing/$', TemplateView.as_view(template_name='404.html') ),
url('^500testing/$', direct_to_template, {'template': '500.html'}), url('^500testing/$', TemplateView.as_view(template_name='500.html')),
url('^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}), url('^robots.txt$', TemplateView.as_view(template_name='robots.txt',content_type='text/plain')),
url(r"^emailshare/(?P<action>\w*)/?$", "emailshare", name="emailshare"), url(r"^emailshare/(?P<action>\w*)/?$", "emailshare", name="emailshare"),
url(r"^feedback/campaign/(?P<campaign_id>\d+)/?$", "ask_rh", name="ask_rh"), url(r"^feedback/campaign/(?P<campaign_id>\d+)/?$", "ask_rh", name="ask_rh"),
url(r"^feedback/$", "feedback", name="feedback"), url(r"^feedback/$", "feedback", name="feedback"),
@ -166,7 +166,7 @@ urlpatterns = patterns(
url(r"^accounts/edit/kindle_config/$", "kindle_config", name="kindle_config"), url(r"^accounts/edit/kindle_config/$", "kindle_config", name="kindle_config"),
url(r"^accounts/edit/kindle_config/(?P<work_id>\d+)/$", "kindle_config", name="kindle_config_download"), url(r"^accounts/edit/kindle_config/(?P<work_id>\d+)/$", "kindle_config", name="kindle_config_download"),
url(r"^send_to_kindle/(?P<work_id>\d+)/(?P<javascript>\d)/$", "send_to_kindle", name="send_to_kindle"), url(r"^send_to_kindle/(?P<work_id>\d+)/(?P<javascript>\d)/$", "send_to_kindle", name="send_to_kindle"),
url(r"^marc/$", direct_to_template, {'template': 'marc.html'}, name="marc"), url(r"^marc/$", TemplateView.as_view(template_name='marc.html'), name="marc"),
url(r"^accounts/edit/marc_config/$", login_required(LibModeView.as_view()), name="marc_config"), url(r"^accounts/edit/marc_config/$", login_required(LibModeView.as_view()), name="marc_config"),
) )

View File

@ -1687,7 +1687,7 @@ class FundCompleteView(TemplateView):
self.transaction.user.wishlist.add_work(work, 'pledging', notify=True) self.transaction.user.wishlist.add_work(work, 'pledging', notify=True)
#put info into session for download page to pick up. #put info into session for download page to pick up.
self.request.session['amount']= self.transaction.amount self.request.session['amount']= int(self.transaction.amount * 100)
if self.transaction.receipt: if self.transaction.receipt:
self.request.session['receipt']= self.transaction.receipt self.request.session['receipt']= self.transaction.receipt
@ -2834,7 +2834,7 @@ def lockss(request, work_id):
ebooks = work.ebooks().filter(edition__unglued=True) ebooks = work.ebooks().filter(edition__unglued=True)
except: except:
ebooks = None ebooks = None
authors = list(models.Author.objects.filter(editions__work=work).all()) authors = work.authors.all()
return render(request, "lockss.html", {'work':work, 'ebooks':ebooks, 'authors':authors}) return render(request, "lockss.html", {'work':work, 'ebooks':ebooks, 'authors':authors})
@ -2993,7 +2993,7 @@ class DownloadView(PurchaseView):
'action': "Contribution", 'action': "Contribution",
'user_license': self.user_license, 'user_license': self.user_license,
'lib_thanked': self.lib_thanked, 'lib_thanked': self.lib_thanked,
'amount': self.request.session.pop('amount') if self.request.session.has_key('amount') else None, 'amount': Decimal(self.request.session.pop('amount')/100) if self.request.session.has_key('amount') else None,
'testmode': self.request.REQUEST.has_key('testmode'), 'testmode': self.request.REQUEST.has_key('testmode'),
'source': self.request.REQUEST.get('source', ''), 'source': self.request.REQUEST.get('source', ''),

View File

@ -47,7 +47,7 @@ class ip:
class admin_form(forms.ModelForm): class admin_form(forms.ModelForm):
class Meta: class Meta:
model = Block model = Block
exclude = "library" exclude = ("library",)
class cardnum: class cardnum:
def authenticate(self,request, library): def authenticate(self,request, library):
@ -70,7 +70,7 @@ class cardnum:
class admin_form(forms.ModelForm): class admin_form(forms.ModelForm):
class Meta: class Meta:
model = CardPattern model = CardPattern
exclude = "library" exclude = ("library",)
class form(forms.ModelForm): class form(forms.ModelForm):
credential = forms.RegexField( credential = forms.RegexField(
@ -119,4 +119,4 @@ class email:
class admin_form(forms.ModelForm): class admin_form(forms.ModelForm):
class Meta: class Meta:
model = EmailPattern model = EmailPattern
exclude = "library" exclude = ("library",)

View File

@ -4,6 +4,7 @@ from django.test import TestCase
from django.contrib.auth.models import User from django.contrib.auth.models import User
class TestLibraryAuth(TestCase): class TestLibraryAuth(TestCase):
fixtures=['initial_data.json']
def setUp(self): def setUp(self):
pass pass

View File

@ -1,32 +1,46 @@
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.views.generic.simple import direct_to_template #from django.views.generic.simple import direct_to_template
from django.views.generic.base import TemplateView
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from . import views, models, forms from . import views, models, forms
from .views import superlogin, CustomRegistrationView from .views import superlogin, CustomRegistrationView
# class to reproduce django 1.4 funtionality
class ExtraContextTemplateView(TemplateView):
extra_context = None
def get_context_data(self, **kwargs):
context = super(self.__class__, self).get_context_data(**kwargs)
if self.extra_context is not None:
for key, value in self.extra_context.items():
if callable(value):
context[key] = value()
else:
context[key] = value
return context
urlpatterns = patterns( urlpatterns = patterns(
"", "",
url(r"^libraryauth/(?P<library_id>\d+)/join/$", views.join_library, name="join_library"), url(r"^libraryauth/(?P<library_id>\d+)/join/$", views.join_library, name="join_library"),
url(r"^libraryauth/(?P<library_id>\d+)/deny/$", direct_to_template, {'template':'libraryauth/denied.html'}, name="bad_library"), url(r"^libraryauth/(?P<library_id>\d+)/deny/$", TemplateView.as_view(template_name='libraryauth/denied.html'), name="bad_library"),
url(r"^libraryauth/(?P<library_id>\d+)/users/$", views.library, {'template':'libraryauth/users.html'}, name="library_users"), url(r"^libraryauth/(?P<library_id>\d+)/users/$", views.library, {'template':'libraryauth/users.html'}, name="library_users"),
url(r"^libraryauth/(?P<library_id>\d+)/admin/$", login_required(views.UpdateLibraryView.as_view()), name="library_admin"), url(r"^libraryauth/(?P<library_id>\d+)/admin/$", login_required(views.UpdateLibraryView.as_view()), name="library_admin"),
url(r"^libraryauth/(?P<library_id>\d+)/login/$", views.login_as_library, name="library_login"), url(r"^libraryauth/(?P<library_id>\d+)/login/$", views.login_as_library, name="library_login"),
url(r"^libraryauth/create/$", login_required(views.CreateLibraryView.as_view()), name="library_create"), url(r"^libraryauth/create/$", login_required(views.CreateLibraryView.as_view()), name="library_create"),
url(r"^libraryauth/list/$", direct_to_template, { url(r"^libraryauth/list/$", ExtraContextTemplateView.as_view(
'template':'libraryauth/list.html', template_name='libraryauth/list.html',
'extra_context':{'libraries_to_show':'approved'}}, extra_context={'libraries_to_show':'approved'}
name="library_list"), ), name="library_list"),
url(r"^libraryauth/unapproved/$", direct_to_template, { url(r"^libraryauth/unapproved/$", ExtraContextTemplateView.as_view(
'template':'libraryauth/list.html', template_name='libraryauth/list.html',
'extra_context':{'libraries_to_show':'new'}}, extra_context={'libraries_to_show':'new'}
name="new_libraries"), ), name="new_libraries"),
url(r'^accounts/register/$', CustomRegistrationView.as_view(), name='registration_register'), url(r'^accounts/register/$', CustomRegistrationView.as_view(), name='registration_register'),
url(r'^accounts/superlogin/$', views.superlogin, name='superlogin'), url(r'^accounts/superlogin/$', views.superlogin, name='superlogin'),
url(r"^accounts/superlogin/welcome/$", direct_to_template, url(r"^accounts/superlogin/welcome/$", ExtraContextTemplateView.as_view(
{'template': 'registration/welcome.html', template_name='registration/welcome.html',
'extra_context': {'suppress_search_box': True,} extra_context={'suppress_search_box': True,}
}), ) ),
url(r'^accounts/login/pledge/$',superlogin, url(r'^accounts/login/pledge/$',superlogin,
{'template_name': 'registration/from_pledge.html'}), {'template_name': 'registration/from_pledge.html'}),
url(r'^accounts/login/purchase/$',superlogin, url(r'^accounts/login/purchase/$',superlogin,
@ -38,10 +52,10 @@ urlpatterns = patterns(
url(r'^accounts/login-error/$',superlogin, url(r'^accounts/login-error/$',superlogin,
{'template_name': 'registration/from_error.html'}), {'template_name': 'registration/from_error.html'}),
url(r'^accounts/edit/$', 'regluit.frontend.views.edit_user'), url(r'^accounts/edit/$', 'regluit.frontend.views.edit_user'),
url(r"^accounts/login/welcome/$", direct_to_template, { url(r"^accounts/login/welcome/$", ExtraContextTemplateView.as_view(
'template': 'registration/welcome.html', template_name='registration/welcome.html',
'extra_context': {'suppress_search_box': True,} extra_context={'suppress_search_box': True,}
}), ) ),
url(r'^socialauth/', include('social.apps.django_app.urls', namespace='social')), url(r'^socialauth/', include('social.apps.django_app.urls', namespace='social')),
url('accounts/', include('email_change.urls')), url('accounts/', include('email_change.urls')),
url(r'^accounts/', include('registration.backends.default.urls')), url(r'^accounts/', include('registration.backends.default.urls')),

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
from django.core.management import execute_manager import os
import sys
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
execute_manager(settings) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "regluit.settings.me")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View File

@ -1,4 +1,4 @@
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from . import views from . import views

View File

@ -108,7 +108,7 @@ class Transaction(models.Model):
extra = JSONField(null=True, default={}) extra = JSONField(null=True, default={})
# whether the user wants to be not listed publicly # whether the user wants to be not listed publicly
anonymous = models.BooleanField(null=False) anonymous = models.BooleanField(default=False)
@property @property
def tier(self): def tier(self):
@ -254,7 +254,7 @@ class Receiver(models.Model):
status = models.CharField(max_length=64) status = models.CharField(max_length=64)
local_status = models.CharField(max_length=64, null=True) local_status = models.CharField(max_length=64, null=True)
reason = models.CharField(max_length=64) reason = models.CharField(max_length=64)
primary = models.BooleanField() primary = models.BooleanField(default=True)
txn_id = models.CharField(max_length=64) txn_id = models.CharField(max_length=64)
transaction = models.ForeignKey(Transaction) transaction = models.ForeignKey(Transaction)

View File

@ -157,7 +157,8 @@ def payAmazonSandbox(sel):
#print "len(payment_confirm)", len(payment_confirm) #print "len(payment_confirm)", len(payment_confirm)
#time.sleep(1) #time.sleep(1)
#payment_confirm[-1].click() #payment_confirm[-1].click()
@unittest.skip("skipping PledgeTest (selenium)")
class PledgeTest(TestCase): class PledgeTest(TestCase):
def setUp(self): def setUp(self):
@ -188,7 +189,8 @@ class PledgeTest(TestCase):
def tearDown(self): def tearDown(self):
self.selenium.quit() self.selenium.quit()
@unittest.skip("skipping AuthorizeTest (selenium)")
class AuthorizeTest(TestCase): class AuthorizeTest(TestCase):
def setUp(self): def setUp(self):
@ -262,6 +264,7 @@ class CreditTest(TestCase):
self.assertEqual(self.user1.credit.balance, 0) self.assertEqual(self.user1.credit.balance, 0)
self.assertEqual(self.user2.credit.balance, 50) self.assertEqual(self.user2.credit.balance, 50)
@unittest.skip("skipping ExtraTest")
class ExtraTest(TestCase): class ExtraTest(TestCase):
def testPledgeExtra(self): def testPledgeExtra(self):
@ -275,6 +278,7 @@ class ExtraTest(TestCase):
class TransactionTest(TestCase): class TransactionTest(TestCase):
fixtures=['initial_data.json']
def setUp(self): def setUp(self):
""" """
""" """
@ -353,31 +357,31 @@ class TransactionTest(TestCase):
self.assertEqual(t.type, EXECUTE_TYPE_CHAINED_INSTANT) self.assertEqual(t.type, EXECUTE_TYPE_CHAINED_INSTANT)
self.assertEqual(t.amount, D('12.34')) self.assertEqual(t.amount, D('12.34'))
class BasicGuiTest(TestCase): # class BasicGuiTest(TestCase):
def setUp(self): # def setUp(self):
self.verificationErrors = [] # self.verificationErrors = []
# This is an empty array where we will store any verification errors # # This is an empty array where we will store any verification errors
# we find in our tests # # we find in our tests
setup_selenium() # setup_selenium()
self.TEST_SERVER_URL = "http://ry-dev.dyndns.org" # self.TEST_SERVER_URL = "http://ry-dev.dyndns.org"
self.selenium = webdriver.Firefox() # self.selenium = webdriver.Firefox()
set_test_logging() # set_test_logging()
def testFrontPage(self): # def testFrontPage(self):
sel = self.selenium # sel = self.selenium
sel.get(self.TEST_SERVER_URL) # sel.get(self.TEST_SERVER_URL)
# if we click on the learn more, does the panel expand? # # if we click on the learn more, does the panel expand?
# click on a id=readon -- or the Learn More span # # click on a id=readon -- or the Learn More span
#sel.find_elements_by_css_selector('a#readon')[0].click() # #sel.find_elements_by_css_selector('a#readon')[0].click()
#time.sleep(2.0) # #time.sleep(2.0)
# the learn more panel should be displayed # # the learn more panel should be displayed
#self.assertTrue(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed()) # #self.assertTrue(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed())
# click on the panel again -- and panel should not be displayed # # click on the panel again -- and panel should not be displayed
#sel.find_elements_by_css_selector('a#readon')[0].click() # #sel.find_elements_by_css_selector('a#readon')[0].click()
#time.sleep(2.0) # #time.sleep(2.0)
#self.assertFalse(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed()) # #self.assertFalse(sel.find_elements_by_css_selector('div#user-block-hide')[0].is_displayed())
def tearDown(self): # def tearDown(self):
self.selenium.quit() # self.selenium.quit()
class AccountTest(TestCase): class AccountTest(TestCase):

View File

@ -1,5 +1,5 @@
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from regluit.payment.views import StripeView from regluit.payment.views import StripeView

View File

@ -1,4 +1,4 @@
Django==1.4.22 Django==1.6.11
Fabric==1.6.0 Fabric==1.6.0
MySQL-python==1.2.3 MySQL-python==1.2.3
Pillow==2.5.3 Pillow==2.5.3
@ -7,39 +7,40 @@ PyPDF2==1.23
PyGithub==1.15.0 PyGithub==1.15.0
PyYAML==3.11 PyYAML==3.11
git+git://github.com/urschrei/pyzotero.git@v0.9.51 git+git://github.com/urschrei/pyzotero.git@v0.9.51
South==0.7.6 South==0.8.4
SPARQLWrapper==1.6.4 SPARQLWrapper==1.6.4
WebOb==1.2.3 WebOb==1.2.3
WebTest==1.4.0 WebTest==1.4.0
amqplib==1.0.2 amqp==1.4.9
anyjson==0.3.3 anyjson==0.3.3
billiard==3.3.0.23
awscli==1.10.26 awscli==1.10.26
billiard==2.7.3.12
boto==2.8.0 boto==2.8.0
#git+ssh://git@github.com/Gluejar/boto.git@2.3.0 #git+ssh://git@github.com/Gluejar/boto.git@2.3.0
celery==3.0.9 celery==3.1.23
certifi==2015.04.28
# pip installing pillow seems to delete distribute # pip installing pillow seems to delete distribute
# but having distribute in requirements starting to cause problems # but having distribute in requirements starting to cause problems
# distribute==0.6.28 # distribute==0.6.28
django-celery==3.0.9 django-celery==3.1.17
django-ckeditor==4.5.1 django-ckeditor==4.5.1
#django-email-change==0.2.3 #django-email-change==0.2.3
git+git://github.com/novagile/django-email-change.git@0d7cb91b987a0505a9c4bde126d452233dea266d git+git://github.com/eshellman/django-email-change.git@582112797466b9fb427ba3c4da3b14b426a28132
django-compat==1.0.10 django-compat==1.0.10
django-endless-pagination==2.0 django-endless-pagination==2.0
django-extensions==0.9 django-extensions==1.6.1
django-jsonfield==0.9.10 django-jsonfield==0.9.10
django-kombu==0.9.4 #django-kombu==0.9.4
django-maintenancemode==0.10 django-maintenancemode==0.10
django-mptt==0.7.4 django-mptt==0.7.4
django-nose-selenium==0.7.3 django-nose-selenium==0.7.3
#django-notification==0.2 #django-notification==0.2
git+git://github.com/aladagemre/django-notification.git@2927346f4c513a217ac8ad076e494dd1adbf70e1 git+git://github.com/eshellman/django-notification.git@8bb7afbbb07e8cad74bc1cf17e0ac6fc117c0497
django-registration==1.0 django-registration==1.0
django-selectable==0.7.0 django-selectable==0.7.0
django-smtp-ssl==1.0 django-smtp-ssl==1.0
django-storages==1.1.6 django-storages==1.1.6
django-tastypie==0.9.11 django-tastypie==0.12.2
django-transmeta==0.7.3 django-transmeta==0.7.3
feedparser==5.1.2 feedparser==5.1.2
freebase==1.0.8 freebase==1.0.8
@ -49,37 +50,39 @@ github3.py==0.9.5
html5lib==1.0b3 html5lib==1.0b3
httplib2==0.7.5 httplib2==0.7.5
isodate==0.5.1 isodate==0.5.1
kombu==2.4.5 kombu==3.0.35
lxml==2.3.5 lxml==2.3.5
defusedxml==0.4.1
mechanize==0.2.5 mechanize==0.2.5
mimeparse==0.1.3 mimeparse==0.1.3
nose==1.1.2 nose==1.1.2
oauth2==1.5.211 oauth2==1.5.211
oauthlib==0.7.2 oauthlib==0.7.2
paramiko==1.7.7.2 paramiko==1.14.1
postmonkey==1.0a4 postmonkey==1.0b
pyasn1==0.1.4 pyasn1==0.1.4
pycrypto==2.6 pycrypto==2.6
pymarc==3.0.2 pymarc==3.0.2
pyparsing==2.0.3 pyparsing==2.0.3
python-dateutil==2.1 python-dateutil==2.1
python-mimeparse==0.1.4
python-openid==2.2.5 python-openid==2.2.5
python-social-auth==0.2.6 python-social-auth==0.2.6
pytz==2012d pytz==2012d
rdflib==4.2.0 rdflib==4.2.0
rdflib-jsonld==0.3 rdflib-jsonld==0.3
redis==2.6.2 redis==2.10.3
reportlab==3.1.8 reportlab==3.1.8
requests==2.6.0 requests==2.7.0
requests-oauthlib==0.4.2 requests-oauthlib==0.4.2
selenium==2.50.0 selenium==2.53.1
six==1.9.0 six==1.9.0
sorl-thumbnail==12.3 sorl-thumbnail==12.3
ssh==1.7.14 ssh==1.7.14
stevedore==0.4 stevedore==1.12.0
stripe==1.9.1 stripe==1.9.1
virtualenv==1.4.9 virtualenv==1.4.9
# virtualenv-clone==0.2.4 not sure why I have this in my env # virtualenv-clone==0.2.4 not sure why I have this in my env
virtualenvwrapper==3.6 #virtualenvwrapper==3.6
wsgiref==0.1.2 wsgiref==0.1.2
xhtml2pdf==0.0.6 xhtml2pdf==0.0.6

View File

@ -12,6 +12,7 @@ LANGUAGES = (
('en', 'English'), ('en', 'English'),
) )
LOCAL_TEST = False LOCAL_TEST = False
ALLOWED_HOSTS = ['.unglue.it', '.unglueit.com',]
WISHED_LANGS = ('en','fr','es','de','el','pt','it','ru','cs','ja','zh','nl','ut','ar','la','id','ca','fa','sv','sl','ko','tr') WISHED_LANGS = ('en','fr','es','de','el','pt','it','ru','cs','ja','zh','nl','ut','ar','la','id','ca','fa','sv','sl','ko','tr')
@ -88,7 +89,7 @@ STATICFILES_FINDERS = (
) )
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = 'a+bo0@3$n18e(newe7og6hmq$r#bkib73z(+s*n25%6q3+22jo' SECRET_KEY = u'a+bo0@3$n18e(newe7og6hmq$r#bkib73z(+s*n25%6q3+22jo'
# List of callables that know how to import templates from various sources. # List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS = (
@ -190,9 +191,15 @@ LOGGING = {
'format': '%(asctime)s %(levelname)s %(name)s[%(funcName)s]: %(message)s', 'format': '%(asctime)s %(levelname)s %(name)s[%(funcName)s]: %(message)s',
}, },
}, },
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': { 'handlers': {
'mail_admins': { 'mail_admins': {
'level': 'ERROR', 'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler' 'class': 'django.utils.log.AdminEmailHandler'
}, },
'file': { 'file': {
@ -352,12 +359,6 @@ UPDATE_ACTIVE_CAMPAIGN_STATUSES = {
"args": () "args": ()
} }
EMIT_NOTIFICATIONS_JOB = {
"task": "regluit.core.tasks.emit_notifications",
"schedule": datetime.timedelta(seconds=60),
"args": ()
}
EBOOK_NOTIFICATIONS_JOB = { EBOOK_NOTIFICATIONS_JOB = {
"task": "regluit.core.tasks.report_new_ebooks", "task": "regluit.core.tasks.report_new_ebooks",
"schedule": crontab(hour=0, minute=30), "schedule": crontab(hour=0, minute=30),
@ -472,8 +473,11 @@ DROPBOX_KEY = '4efhwty5aph52bd' #for unglue.it, just.unglue.it
# generated from rdhyee account # generated from rdhyee account
GITHUB_PUBLIC_TOKEN = 'f702409f913d7f9046f93c677710f829e2b599c9' GITHUB_PUBLIC_TOKEN = 'f702409f913d7f9046f93c677710f829e2b599c9'
# https://github.com/celery/django-celery/blob/master/docs/introduction.rst#for-django-17-and-newer
SOUTH_MIGRATION_MODULES = { SOUTH_MIGRATION_MODULES = {
'default': 'social.apps.django_app.default.south_migrations' 'default': 'social.apps.django_app.default.south_migrations',
'tastypie': 'tastypie.south_migrations',
'djcelery': 'djcelery.south_migrations',
} }
MOBIGEN_URL = "https://docker.gluejar.com:5001/mobigen" MOBIGEN_URL = "https://docker.gluejar.com:5001/mobigen"

View File

@ -1,5 +1,6 @@
from regluit.settings.common import * from regluit.settings.common import *
ALLOWED_HOSTS = ['.unglue.it']
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
@ -29,7 +30,7 @@ DATABASES = {
} }
TIME_ZONE = 'America/New_York' TIME_ZONE = 'America/New_York'
SECRET_KEY = '_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t' SECRET_KEY = b'_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t'
# settings for outbout email # settings for outbout email
# if you have a gmail account you can use your email address and password # if you have a gmail account you can use your email address and password
@ -120,10 +121,9 @@ MAINTENANCE_MODE = False
# decide which of the period tasks to add to the schedule # decide which of the period tasks to add to the schedule
#CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB #CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB
#CELERYBEAT_SCHEDULE['emit_notifications'] = EMIT_NOTIFICATIONS_JOB
CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB
try: try:
from regluit.settings.local import * from regluit.settings.local import *
except ImportError: except ImportError:
pass pass

View File

@ -24,7 +24,7 @@ DATABASES = {
} }
TIME_ZONE = 'America/New_York' TIME_ZONE = 'America/New_York'
SECRET_KEY = '_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t' SECRET_KEY = u'_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t'
# settings for outbout email # settings for outbout email
# if you have a gmail account you can use your email address and password # if you have a gmail account you can use your email address and password

View File

@ -1,5 +1,6 @@
from regluit.settings.common import * from regluit.settings.common import *
ALLOWED_HOSTS = ['.unglue.it']
DEBUG = False DEBUG = False
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
@ -25,7 +26,7 @@ DATABASES = {
} }
TIME_ZONE = 'America/New_York' TIME_ZONE = 'America/New_York'
SECRET_KEY = '_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t' SECRET_KEY = u'_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t'
# settings for outbout email # settings for outbout email
# if you have a gmail account you can use your email address and password # if you have a gmail account you can use your email address and password
@ -116,8 +117,6 @@ IS_PREVIEW = False
CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB
CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB
# doing emit_notifications in crontab right now
#CELERYBEAT_SCHEDULE['emit_notifications'] = EMIT_NOTIFICATIONS_JOB
CELERYBEAT_SCHEDULE['update_account_statuses'] = UPDATE_ACCOUNT_STATUSES CELERYBEAT_SCHEDULE['update_account_statuses'] = UPDATE_ACCOUNT_STATUSES
CELERYBEAT_SCHEDULE['notify_expiring_accounts'] = NOTIFY_EXPIRING_ACCOUNTS CELERYBEAT_SCHEDULE['notify_expiring_accounts'] = NOTIFY_EXPIRING_ACCOUNTS

View File

@ -106,7 +106,6 @@ IS_PREVIEW = False
#CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB #CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB
CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB
CELERYBEAT_SCHEDULE['emit_notifications'] = EMIT_NOTIFICATIONS_JOB
# local settings for maintenance mode # local settings for maintenance mode

View File

@ -1,5 +1,6 @@
from regluit.settings.common import * from regluit.settings.common import *
ALLOWED_HOSTS = ['.unglue.it']
DEBUG = False DEBUG = False
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
@ -26,7 +27,7 @@ DATABASES = {
TIME_ZONE = 'America/New_York' TIME_ZONE = 'America/New_York'
SECRET_KEY = '_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t' SECRET_KEY = u'_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t'
# settings for outbout email # settings for outbout email
# if you have a gmail account you can use your email address and password # if you have a gmail account you can use your email address and password
@ -103,7 +104,6 @@ IS_PREVIEW = False
#CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB #CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB
CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB
CELERYBEAT_SCHEDULE['emit_notifications'] = EMIT_NOTIFICATIONS_JOB
# local settings for maintenance mode # local settings for maintenance mode

View File

@ -1,5 +1,6 @@
from regluit.settings.common import * from regluit.settings.common import *
ALLOWED_HOSTS = ['.unglue.it']
DEBUG = False DEBUG = False
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
# we are launched! # we are launched!
@ -27,7 +28,7 @@ DATABASES = {
} }
TIME_ZONE = 'America/New_York' TIME_ZONE = 'America/New_York'
SECRET_KEY = '_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t' SECRET_KEY = u'_^_off!8zsj4+)%qq623m&$7_m-q$iau5le0w!mw&n5tgt#x=t'
# settings for outbout email # settings for outbout email
# if you have a gmail account you can use your email address and password # if you have a gmail account you can use your email address and password
@ -112,7 +113,6 @@ STATIC_ROOT = '/var/www/static'
# decide which of the period tasks to add to the schedule # decide which of the period tasks to add to the schedule
CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB CELERYBEAT_SCHEDULE['send_test_email'] = SEND_TEST_EMAIL_JOB
#CELERYBEAT_SCHEDULE['emit_notifications'] = EMIT_NOTIFICATIONS_JOB
# update the statuses of campaigns # update the statuses of campaigns
CELERYBEAT_SCHEDULE['update_active_campaign_statuses'] = UPDATE_ACTIVE_CAMPAIGN_STATUSES CELERYBEAT_SCHEDULE['update_active_campaign_statuses'] = UPDATE_ACTIVE_CAMPAIGN_STATUSES
CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB CELERYBEAT_SCHEDULE['report_new_ebooks'] = EBOOK_NOTIFICATIONS_JOB

View File

@ -1,4 +1,4 @@
from django.conf.urls.defaults import * from django.conf.urls import patterns, url, include
from .views import SurveyView from .views import SurveyView

View File

@ -351,10 +351,8 @@ def test_relaunch(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True,
def successful_campaign_signal(): def successful_campaign_signal():
"""fire off a success_campaign signal and send notifications""" """fire off a success_campaign signal and send notifications"""
import regluit import regluit
from notification.engine import send_all
c = regluit.core.models.Campaign.objects.get(id=3) c = regluit.core.models.Campaign.objects.get(id=3)
regluit.core.signals.successful_campaign.send(sender=None, campaign=c) regluit.core.signals.successful_campaign.send(sender=None, campaign=c)
send_all()
def berkeley_search(): def berkeley_search():

View File

@ -1,6 +1,4 @@
import notification.urls from django.conf.urls import patterns, url, include
from django.conf.urls.defaults import *
from frontend.views import social_auth_reset_password from frontend.views import social_auth_reset_password
from regluit.admin import admin_site from regluit.admin import admin_site
@ -22,7 +20,7 @@ urlpatterns = patterns('',
url(r'^selectable/', include('selectable.urls')), url(r'^selectable/', include('selectable.urls')),
url(r'^admin/', include(admin_site.urls)), url(r'^admin/', include(admin_site.urls)),
url(r'^comments/', include('django.contrib.comments.urls')), url(r'^comments/', include('django.contrib.comments.urls')),
url(r'^notification/', include(notification.urls)), url(r"^notification/", include('notification.urls')),
url(r'^ckeditor/', include('ckeditor.urls')), url(r'^ckeditor/', include('ckeditor.urls')),
# questionnaire urls # questionnaire urls
url(r'^survey/', include('regluit.questionnaire.urls')), url(r'^survey/', include('regluit.questionnaire.urls')),

3
vagrant/Vagrantfile vendored
View File

@ -6,8 +6,6 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "jenkins"
config.vm.define "please" do |node| config.vm.define "please" do |node|
# Every Vagrant virtual environment requires a box to build off of. # Every Vagrant virtual environment requires a box to build off of.
@ -53,6 +51,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# alestic 2015.05.05 # alestic 2015.05.05
aws.instance_type="t1.micro" aws.instance_type="t1.micro"
#aws.instance_type="m3.medium"
aws.region = "us-east-1" aws.region = "us-east-1"
aws.availability_zone = "us-east-1c" aws.availability_zone = "us-east-1c"

View File

@ -54,10 +54,10 @@
tasks: tasks:
# sudo add repo to get latest version of python 2.7 # add repo to get latest version of python 2.7
- name: add-apt-repository ppa:fkrull/deadsnakes-python2.7 - name: add-apt-repository ppa:fkrull/deadsnakes-python2.7
apt_repository: repo='ppa:fkrull/deadsnakes-python2.7' state=present update_cache=true apt_repository: repo='ppa:fkrull/deadsnakes-python2.7' state=present update_cache=true
when: class in [] when: class in ['please', 'just', 'prod']
- name: do apt-get update --fix-missing - name: do apt-get update --fix-missing
command: apt-get update --fix-missing command: apt-get update --fix-missing
@ -437,6 +437,26 @@
- name: put an empty file in main dir to help identify this instance - name: put an empty file in main dir to help identify this instance
command: touch "/home/{{user}}/{{class}}_{{ ansible_date_time.iso8601 }}" command: touch "/home/{{user}}/{{class}}_{{ ansible_date_time.iso8601 }}"
- name: apply upgrade
command: sudo unattended-upgrade
- name: check whether reboot needed
stat: path=/var/run/reboot-required
register: reboot_required
- name: restart machine
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
async: 1
poll: 0
sudo: true
ignore_errors: true
when: reboot_required
- name: waiting for server to come back
local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=300
sudo: false
when: reboot_required
handlers: handlers:
- name: restart apache2 - name: restart apache2