Changeset - 2453aa60244a
[Not reviewed]
0 1 0
Christopher Neugebauer - 5 years ago 2018-11-01 00:45:23
chrisjrn@gmail.com
Remove those monkey patches again
1 file changed with 0 insertions and 8 deletions:
0 comments (0 inline, 0 general)
pinaxcon/monkey_patch.py
Show inline comments
...
 
@@ -8,54 +8,46 @@ from django.core.mail import EmailMultiAlternatives
 
from functools import wraps
 

	
 

	
 
class MonkeyPatchMiddleware(object):
 
    ''' Ensures that our monkey patching only gets called after it is safe to do so.'''
 

	
 
    def process_request(self, request):
 
        do_monkey_patch()
 

	
 

	
 
def do_monkey_patch():
 
    patch_stripe_card_defaults()
 
    patch_registrasion_views()
 
    patch_conference_schedule()
 

	
 
    # Remove this function from existence
 
    global do_monkey_patch
 
    do_monkey_patch = lambda: None
 

	
 

	
 
def patch_stripe_card_defaults():
 
    from pinax.stripe.actions import sources
 
    from collections import defaultdict
 

	
 
    old_sync_card = sources.sync_card
 

	
 
    @wraps(old_sync_card)
 
    def sync_card(customer, source):
 
        d = defaultdict(str)
 
        d.update(source)
 
        return old_sync_card(customer, d)
 

	
 
    sources.sync_card = sync_card
 

	
 

	
 
def patch_registrasion_views():
 
    from registrasion import views as registrasion_views
 
    from django.views.decorators.csrf import csrf_exempt
 

	
 
    registrasion_views.invoice_mailout = csrf_exempt(registrasion_views.invoice_mailout)
 

	
 

	
 
def patch_conference_schedule():
 
    from symposion.schedule import views as sv
 
    from symposion.schedule import models as sm
 

	
 
    old_schedule_json = sv._schedule_json
 

	
 
    @wraps(old_schedule_json)
 
    def schedule_json(request):
 
        schedule = old_schedule_json(request)
 

	
 
        for slot_data in schedule:
 
            slot = sm.Slot.objects.get(id=slot_data["conf_key"])
0 comments (0 inline, 0 general)