def get(self): config = Configuration.get_instance() matches = re.match( r"/(?P<hash>[0-9a-z]+)", self.request.path) if matches: file_hash = matches.group("hash") current_conversion = get_conversion_from_hash(file_hash) if current_conversion: path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html') colors = current_conversion.get_palette() self.response.out.write(template.render(path, {'show_file': True, 'key': current_conversion.hash, 'filename': current_conversion.filename, 'palette': simplejson.dumps( {'filename': current_conversion.filename, 'colors': colors}), 'web_debug': config.web_debug})) return path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/error.html') self.response.out.write(template.render(path, {'status': '404', 'message': "We don't have what you're looking for."})) self.response.status = 404
def post(self): config = Configuration.get_instance() stripe.api_key = config.private_stripe_key # Get the credit card details submitted by the form token = self.request.POST['stripeToken'] file_hash = self.request.POST['key'] current_conversion = get_conversion_from_hash(file_hash) if current_conversion: # Create the charge on Stripe's servers - this will charge the user's card try: charge = stripe.Charge.create( amount=200, currency="usd", card=token, description=current_conversion.filename ) current_conversion.paid_date = datetime.datetime.now() current_conversion.put() except stripe.CardError, e: # The card has been declined logging.error('Card payment declined' + e.message) pass self.redirect("/" + file_hash)
def get(self): config = Configuration.get_instance() path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html') self.response.out.write(template.render(path, {'show_file': False, 'stripe_key': config.public_stripe_key, 'web_debug': config.web_debug}))
def get(self): config = Configuration.get_instance() example_palette = [{"name": "Sugar Hearts You", "hex": "#fe4365", "safeName": "sugar-hearts-you"}, {"name": "Party Confetti", "hex": "#fc9d9a", "safeName": "party-confetti"}, {"name": "Sugar Champagne", "hex": "#f9cdad", "safeName": "sugar-champagne"}, {"name": "Bursts Of Euphoria", "hex": "#c8c8a9", "safeName": "bursts-of-euphoria"}, {"name": "Happy Balloons", "hex": "#83af9b", "safeName": "happy-balloons"}] path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html') self.response.out.write(template.render(path, {'show_file': False, 'web_debug': config.web_debug, 'palette': simplejson.dumps({'filename': 'Example from <a href="http://www.colourlovers.com/palettes/most-loved/all-time/meta">ColourLovers.com</a>', 'colors': example_palette})}))
def get(self): config = Configuration.get_instance() matches = re.match( r"/(?P<hash>[0-9a-z]+)", self.request.path) if matches: file_hash = matches.group("hash") current_conversion = get_conversion_from_hash(file_hash) if current_conversion: path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/main.html') first_ten_events = current_conversion.get_first_ten_events() first_ten_events = format_events_for_html(first_ten_events) items_view_title = generate_items_title(current_conversion.event_count) self.response.out.write(template.render(path, {'show_file': True, 'stripe_key': config.public_stripe_key, 'paid': current_conversion.paid_date is not None, 'event_count': current_conversion.event_count, 'event_count_minus_ten': current_conversion.event_count - 10, 'key': current_conversion.hash, 'filename': current_conversion.filename, 'full_filename': current_conversion.full_filename, 'events': first_ten_events, 'items_view_title': items_view_title, 'web_debug': config.web_debug})) return path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../templates/error.html') self.response.out.write(template.render(path, {'status': '404', 'message': "We don't have what you're looking for."})) self.response.status = 404