Snippet List
Wrote this some time ago when I couldn't find one already completed. Came up in the IRC channel so I decided to post it.
Easy enough to use.
`from ssldecorator import ssl_required`
`@ssl_required`
`def your_view(request):`
` ''' your code here '''`
You can place a variable in your settings.py to change the SSL domain (ie, if you have SSL running on secure.yourdomain.com instead of www.yourdomain.com)..
`SSL_DOMAIN = 'https://secure.yourdomain.com'`
Note: please include a proper URL. If https isn't used, the decorator will add it.
I couldn't find a Python implementation of this, so I threw this class together real quick.
This will let you share "private" files on S3 via a signed request. It will also have an expiration on the link, so it is only valid until a certain time period.
Example Usage:
s3 = SecureS3('AWS_ACCESS_KEY', 'AWS_SECRET_ACCESS_KEY')
s3.get_auth_link('your_bucket', 'your_file')
That would return your secure link. eg,
http://your_bucket.s3.amazonaws.com/your_file?AWSAccessKeyId=AWS_ACCESS_KEY&Expires=1226198694&Signature=IC5ifWgiuOZ1IcWXRltHoETYP1A%3D
As users would login to their accounts to update their CC info, the expiration date always threw them off. The default format for displaying a datetime.date object is
>YYYY-MM-DD
Obviously the expiration date on your credit card uses the MM/YY format. I finally got around to creating a custom field/widget to handle this particular piece of data.
Use like so...
class CustomerForm(forms.ModelForm):
cc_exp = DateFieldCCEXP()
class Meta:
model = Customer
- datefield
- credit-card
- expiration-date
pjs has posted 3 snippets.