Skip to content

Commit

Permalink
feat[backend]: add s3 storage
Browse files Browse the repository at this point in the history
chore[backend]: update requirements.txt, rename image path
  • Loading branch information
rahulgpt committed Aug 1, 2022
1 parent 2009232 commit 2577d8d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 67 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ STRIPE_TEST_PUBLIC_KEY=
STRIPE_TEST_SECRET_KEY=

EMAIL_HOST_USER=email_for_sending_emails
EMAIL_HOST_PASSWORD=email_password
EMAIL_HOST_PASSWORD=email_password

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_STORAGE_BUCKET_NAME=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,4 @@ config.py

.vscode/
.DS_Store
static/
2 changes: 1 addition & 1 deletion about/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class AboutDetail(models.Model):
image = models.ImageField(upload_to='about_images')
image = models.ImageField(upload_to='about-images')
heading1 = models.CharField(max_length=30)
heading2 = models.CharField(max_length=30)
paragraph = models.TextField()
Expand Down
46 changes: 16 additions & 30 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
Expand All @@ -41,7 +40,8 @@
'gallery.apps.GalleryConfig',
'shop.apps.ShopConfig',
'about.apps.AboutConfig',
'emailverification'
'emailverification',
'storages',
]

SITE_ID = 3
Expand Down Expand Up @@ -128,6 +128,7 @@
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "frontend/build/static"),
Expand Down Expand Up @@ -160,33 +161,18 @@
]
}

# S3 BUCKET CONFIG

AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
AWS_QUERYSTRING_AUTH = False

AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None
AWS_S3_REGION_NAME = 'ap-south-1'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

STRIPE_PUBLIC_KEY = config('STRIPE_TEST_PUBLIC_KEY')
STRIPE_SECRET_KEY = config('STRIPE_TEST_SECRET_KEY')

SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'


SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'METHOD': 'oauth2',
'SDK_URL': '//connect.facebook.net/{locale}/sdk.js',
'SCOPE': ['email', 'public_profile'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'first_name',
'last_name',
'middle_name',
'name',
'name_format',
'picture',
'short_name'
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': 'path.to.callable',
'VERIFIED_EMAIL': False,
'VERSION': 'v7.0',
}
}
STRIPE_SECRET_KEY = config('STRIPE_TEST_SECRET_KEY')
2 changes: 1 addition & 1 deletion gallery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class GalleryImage(models.Model):
title = models.CharField(max_length=30)
imagesrc = models.ImageField(upload_to='gallery_images')
imagesrc = models.ImageField(upload_to='gallery-images')
date_uploaded = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)

Expand Down
83 changes: 52 additions & 31 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
asgiref==3.2.10
autopep8==1.5.3
certifi==2020.6.20
chardet==3.0.4
DateTime==4.3
defusedxml==0.6.0
dj-rest-auth==1.0.9
Django==3.0.7
django-admin-interface==0.12.2
django-allauth==0.42.0
django-colorfield==0.3.1
django-cors-headers==3.4.0
django-flat-responsive==2.0
django-flat-theme==1.1.4
django-rest-framework==0.1.0
djangorestframework==3.11.0
idna==2.10
oauthlib==3.1.0
pycodestyle==2.6.0
python-decouple==3.3
python3-openid==3.2.0
pytz==2020.1
requests==2.24.0
requests-oauthlib==1.3.0
six==1.15.0
sqlparse==0.3.1
stripe==2.49.0
toml==0.10.1
urllib3==1.25.9
zope.interface==5.1.0
Pillow==9.2.0
asgiref==3.2.10
async-generator==1.10
attrs==21.2.0
autopep8==1.5.3
boto3==1.24.42
botocore==1.27.42
certifi==2020.6.20
cffi==1.15.0
chardet==3.0.4
cryptography==36.0.1
DateTime==4.3
defusedxml==0.6.0
dj-rest-auth==1.0.9
Django==3.0.7
django-admin-interface==0.12.2
django-colorfield==0.3.1
django-cors-headers==3.4.0
django-flat-responsive==2.0
django-flat-theme==1.1.4
django-rest-framework==0.1.0
django-storages==1.12.3
djangorestframework==3.11.0
greenlet==1.1.2
h11==0.12.0
idna==2.10
jmespath==1.0.1
msgpack==1.0.3
oauthlib==3.1.0
outcome==1.1.0
Pillow==9.2.0
pycodestyle==2.6.0
pycparser==2.21
pynvim==0.4.3
pyOpenSSL==21.0.0
python-dateutil==2.8.2
python-decouple==3.3
python3-openid==3.2.0
pytz==2020.1
requests==2.24.0
requests-oauthlib==1.3.0
s3transfer==0.6.0
six==1.15.0
sniffio==1.2.0
sortedcontainers==2.4.0
sqlparse==0.3.1
stripe==2.49.0
toml==0.10.1
trio==0.19.0
trio-websocket==0.9.2
urllib3==1.25.9
wsproto==1.0.0
zope.interface==5.1.0
6 changes: 3 additions & 3 deletions shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def __str__(self):

class Item(models.Model):
title = models.CharField(max_length=30)
keyimage = models.ImageField(upload_to='shop_images')
subimage1 = models.ImageField(upload_to='shop_images')
subimage2 = models.ImageField(upload_to='shop_images', blank=True)
keyimage = models.ImageField(upload_to='shop-images')
subimage1 = models.ImageField(upload_to='shop-images')
subimage2 = models.ImageField(upload_to='shop-images', blank=True)
price = models.FloatField()
discount_price = models.FloatField(blank=True, null=True)
designed_by = models.CharField(max_length=30)
Expand Down

0 comments on commit 2577d8d

Please sign in to comment.