This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AwsUploader | |
CLIENT = Aws::S3::Client.new | |
BUCKET = Rails.configuration.x.aws["output_bucket"] | |
def self.upload(file, key) | |
CLIENT.put_object({ | |
bucket: BUCKET, | |
key: key, | |
body: file, | |
content_length: file.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def formatted_datetime_range(start_datetime, end_datetime) | |
start_date = start_datetime.to_date rescue nil | |
end_date = end_datetime.to_date rescue nil | |
return "" if start_date.nil? | |
is_all_day = (start_datetime == start_datetime.beginning_of_day) | |
is_this_year = (start_datetime.year == Time.zone.today.year) | |
if end_date && start_date != end_date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Source | |
# shell: | |
pg_dump -U username --data-only --table=tablename dbname > tablename.sql | |
### Target | |
# psql: | |
delete from tablename *; | |
# shell: | |
psql -U username dbname < tablename.sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Middleware component that wraps the login_required decorator around all URL patterns be default, with exceptions. | |
Define PUBLIC_URLS and ADMIN_URLS using regex in settings.py, where: | |
PUBLIC_URLS do not require user to be logged in. | |
ADMIN_URLS require user to be in admin group. | |
Source: http://stackoverflow.com/a/2164224/720054 | |
""" | |
# settings.py | |
PUBLIC_URLS = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings.py | |
EMAIL_BACKEND = 'backends.SMTPEmailBackend' | |
# backends.py | |
"""Custom SMTP email backend class""" | |
import smtplib | |
from django.core.mail.utils import DNS_NAME | |
from django.core.mail.backends.smtp import EmailBackend | |
class SMTPEmailBackend(EmailBackend): |