Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACCESS_KEY=
SECRET_KEY=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ backups
.ds_store
core/staticfiles
venv
.env
18 changes: 18 additions & 0 deletions codechallenges/migrations/0015_question_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.4 on 2021-08-12 20:05

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("codechallenges", "0014_auto_20210731_1954"),
]

operations = [
migrations.AddField(
model_name="question",
name="image",
field=models.ImageField(blank=True, null=True, upload_to="questions"),
),
]
1 change: 1 addition & 0 deletions codechallenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Question(models.Model):

categories = models.ManyToManyField(Category, blank=True)
authors = models.ManyToManyField(Author, blank=True)
image = models.ImageField(upload_to="questions", null=True, blank=True)

def __str__(self):
return self.title
Expand Down
15 changes: 15 additions & 0 deletions core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

from pathlib import Path
import os
from dotenv import load_dotenv

load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -169,3 +172,15 @@
}

CELERY_IMPORTS = "core.tasks"

# S3 configuration
ACCESS_KEY = str(os.getenv("ACCESS_KEY"))
SECRET_KEY = str(os.getenv("SECRET_KEY"))

DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

AWS_S3_ENDPOINT_URL = "http://minio.discretemath.ca/"
AWS_ACCESS_KEY_ID = os.environ.get("ACCESS_KEY", "access-key")
DEBUG = bool(os.environ.get("DJANGO_DEBUG", True))
AWS_SECRET_ACCESS_KEY = os.environ.get("SECRET_KEY", "secret-key")
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME", "core")
25 changes: 25 additions & 0 deletions polls/migrations/0003_auto_20210812_1958.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.4 on 2021-08-12 19:58

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("polls", "0002_auto_20210731_2003"),
]

operations = [
migrations.AlterField(
model_name="multiplechoicequestion",
name="poll",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="multiple_choice_questions",
to="polls.poll",
),
),
]
7 changes: 6 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ sqlparse==0.4.1
toml==0.10.2
vine==5.0.0
wcwidth==0.2.5
drf-yasg
python-dotenv==0.19.0
drf-yasg==1.20.0
Pillow==8.3.1
django-storages==1.11.1
boto3==1.18.6
botocore==1.21.6