Fakultas Ilmu Komputer UI

Commit 18ecaf60 authored by Naufal Alauddin Hilmi's avatar Naufal Alauddin Hilmi 🍦
Browse files

Merge branch 'PBI-16-TASK-configure-media-upload' into 'PBI-16-pencatatan_mustahik'

PBI 16 TASK Configure Media Upload

See merge request !22
parents c1715945 e9140eb0
Pipeline #51979 passed with stage
in 44 minutes and 29 seconds
......@@ -8,7 +8,7 @@ ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt .
RUN apk add --no-cache --virtual .build-deps \
gcc postgresql-dev libpq musl-dev \
gcc postgresql-dev libpq musl-dev jpeg-dev zlib-dev\
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& find /usr/local \
......
......@@ -9,6 +9,7 @@ services:
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- staticfiles:/var/www/html/static/
- mediafiles:/var/www/html/media/
depends_on:
- backend
......@@ -20,6 +21,7 @@ services:
volumes:
- ./:/app/backend/
- staticfiles:/app/backend/staticfiles/
- mediafiles:/app/backend/mediafiles/
env_file:
- .env
environment:
......@@ -39,3 +41,4 @@ services:
volumes:
postgres_data:
staticfiles:
mediafiles:
......@@ -5,6 +5,10 @@ server {
root /var/www/html/;
}
location /media/ {
root /var/www/html/;
}
location / {
proxy_pass http://backend:8000;
proxy_set_header Host $http_host;
......
......@@ -6,5 +6,6 @@ django-graphql-jwt==0.3.1
graphene-django==2.10.1
gunicorn==20.0.4
psycopg2-binary==2.8.5
Pillow==7.2.0
pytz==2020.1
sqlparse==0.3.1
# Generated by Django 3.0.7 on 2020-09-04 11:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mustahik', '0002_auto_20200816_1347'),
]
operations = [
migrations.AlterField(
model_name='mustahik',
name='photo',
field=models.ImageField(default='images/default_photo.jpg', upload_to='images/mustahik'),
),
]
......@@ -33,7 +33,7 @@ class Mustahik(models.Model):
birthdate = models.DateField()
status = models.CharField(max_length=32, choices=Status.choices)
gender = models.CharField(max_length=1, choices=Gender.choices)
photo = models.FileField(
photo = models.ImageField(
upload_to=os.path.join('images', 'mustahik'),
default=os.path.join('images', 'default_photo.jpg')
)
......
......@@ -13,6 +13,9 @@ class MustahikType(DjangoObjectType):
age = graphene.Int(source='calculate_age')
def resolve_photo(self, info, **kwargs):
return self.photo and info.context.build_absolute_uri(self.photo.url)
class DataSourceInstitusiType(DjangoObjectType):
class Meta:
......
......@@ -141,5 +141,5 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = '/img/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'images')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment