Skip to content

Commit

Permalink
Merge branch 'release-v3.3.1.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sboh1214 committed Jul 14, 2023
2 parents 527bf21 + 59d18c0 commit a48e580
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
/.github/
/.idea/

**/node_modules/
**/build/

/volumes/db

.pylintrc
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ react/node_modules
htmlcov/

/volumes/
/react/
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ docker compose down
rm -rf ./volumes/db
```

### TroubleShooting

#### (Windows) git clone시 유의사항

local window에 clone 후, wsl shell로 실행하면 오류가 발생합니다.
(local window에 clone하면 `user@desktop:mnt/` 에서 실행됩니다.)

wsl2 shell을 실행한 뒤, wsl2 shell 상에서 git clone을 해야 합니다.

#### (Windows) wsl 상에서 docker compose up 시 유의사항

docker 명령어 없다는 콘솔창이 뜨면 아래 명령어를 입력하여 wsl version이 1인 distro를 확인 한 뒤, wsl version 2로 바꾸어줍니다.

```cmd
wsl.exe -l -v
wsl.exe --set-version (distro name) 2
```

## 개발 환경 설정 (Deprecated)

2023.5.5. 까지 사용했던 Docker Compose 없는 개발 환경입니다.
Expand Down
31 changes: 31 additions & 0 deletions apps/graduation/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.core.cache import cache

from apps.subject.models import Department

Expand Down Expand Up @@ -26,7 +27,15 @@ class GeneralTrack(models.Model):
class Meta:
unique_together = [["start_year", "is_foreign"], ["end_year", "is_foreign"]]

def get_cache_key(self):
return "generaltrack:%d-%d-%s" % (self.start_year, self.end_year, self.is_foreign)

def to_json(self):
cache_id = self.get_cache_key()
result_cached = cache.get(cache_id)
if result_cached is not None:
return result_cached

result = {
"id": self.id,
"start_year": self.start_year,
Expand All @@ -44,6 +53,8 @@ def to_json(self):
"humanities_doublemajor": self.humanities_doublemajor,
}

cache.set(cache_id, result, 60 * 60)

return result


Expand All @@ -60,7 +71,15 @@ class MajorTrack(models.Model):
class Meta:
unique_together = [["start_year", "department"], ["end_year", "department"]]

def get_cache_key(self):
return "majortrack:%d-%d-%d" % (self.start_year, self.end_year, self.department.id)

def to_json(self):
cache_id = self.get_cache_key()
result_cached = cache.get(cache_id)
if result_cached is not None:
return result_cached

result = {
"id": self.id,
"start_year": self.start_year,
Expand All @@ -71,6 +90,8 @@ def to_json(self):
"major_elective": self.major_elective,
}

cache.set(cache_id, result, 60 * 60)

return result


Expand All @@ -95,7 +116,15 @@ class AdditionalTrack(models.Model):
class Meta:
unique_together = [["start_year", "type", "department"], ["end_year", "type", "department"]]

def get_cache_key(self):
return "additionaltrack:%d-%d-%s-%d" % (self.start_year, self.end_year, self.type, self.department.id if self.department else 0)

def to_json(self):
cache_id = self.get_cache_key()
result_cached = cache.get(cache_id)
if result_cached is not None:
return result_cached

result = {
"id": self.id,
"start_year": self.start_year,
Expand All @@ -106,4 +135,6 @@ def to_json(self):
"major_elective": self.major_elective,
}

cache.set(cache_id, result, 60 * 60)

return result
10 changes: 10 additions & 0 deletions apps/review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ def post(self, request, review_id):
ReviewVote.objects.create(review=review, userprofile=user_profile)
return HttpResponse()

def delete(self, request, review_id):
review = get_object_or_404(Review, id=review_id)
user_profile = request.user.userprofile

if review.votes.filter(userprofile=user_profile).exists():
ReviewVote.objects.filter(review=review, userprofile=user_profile).delete()
return HttpResponse()
else:
return HttpResponseBadRequest("Not Liked")


@method_decorator(login_required_ajax, name="dispatch")
class UserInstanceLikedReviewsView(View):
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ services:
volumes:
- ./volumes/db:/var/lib/mysql
- ./volumes/dump:/dump
command: --sql_mode=NO_ENGINE_SUBSTITUTION --default_storage_engine=InnoDB --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
command: |
--sql_mode=NO_ENGINE_SUBSTITUTION --default_storage_engine=InnoDB
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
back:
depends_on:
wait-for-db:
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.back
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ EXPOSE 8000

ADD ./volumes/config /root/.ssh/config
ADD ./volumes/key.pem /root/key.pem
RUN chown -R root:root /root && chmod 400 /root/key.pem && echo "StrictHostKeyChecking no" >> /etc/ssh_config
ADD ./volumes/wheel-2021.pem /root/wheel-2021.pem
RUN chown -R root:root /root && chmod 400 /root/key.pem && chmod 400 /root/wheel-2021.pem && echo "StrictHostKeyChecking no" >> /etc/ssh_config

CMD ["gunicorn", "otlplus.wsgi", "--bind", "0.0.0.0:8000"]
21 changes: 6 additions & 15 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ services:
- MYSQL_ROOT_HOSTS=%
- MYSQL_ROOT_PASSWORD=${OTLPLUS_DB_PASSWORD}
- MYSQL_DATABASE=otlplus
- TZ=Asia/Seoul
volumes:
- ../volumes/db:/var/lib/mysql
- ../volumes/dump:/dump
command: --sql_mode=NO_ENGINE_SUBSTITUTION --default_storage_engine=InnoDB --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
command: |
--sql_mode=NO_ENGINE_SUBSTITUTION --default_storage_engine=InnoDB
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
back:
depends_on:
- db
Expand All @@ -28,21 +31,9 @@ services:
tty: true
ports:
- "58000:8000"
- "8022:22"
volumes:
- "/etc/timezone:/etc/timezone:ro"
- ../volumes/scripts:/var/www/otlplus/scripts:ro
- ../volumes/logs:/var/www/otlplus/logs
working_dir: /var/www/otlplus
front:
container_name: otlplus-front
platform: linux/amd64
build:
context: ..
dockerfile: ./docker/Dockerfile.front
restart: always
tty: true
ports:
- "58080:80"
volumes:
- ../volumes/scripts:/var/www/otlplus/scripts:ro
- ../volumes/logs:/var/www/otlplus/logs
working_dir: /var/www/otlplus/react
2 changes: 2 additions & 0 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ services:
tty: true
ports:
- "58000:8000"
- "8022:22"
volumes:
- "/etc/timezone:/etc/timezone:ro"
- ../volumes/scripts:/var/www/otlplus/scripts:ro
- ../volumes/logs:/var/www/otlplus/logs
working_dir: /var/www/otlplus
5 changes: 4 additions & 1 deletion otlplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
'PASSWORD': 'p@ssw0rd',
'HOST': 'db',
'PORT': '3306',
"OPTIONS": {
"charset": "utf8mb4",
},
}
}

Expand Down Expand Up @@ -154,7 +157,7 @@ def ugettext(s):
LOGIN_URL = "/session/login/"
LOGOUT_URL = "/session/logout/"

VERSION = "3.3.0.0"
VERSION = "3.3.1.0"

try:
from settings_local import * # pylint: disable=wildcard-import, unused-wildcard-import
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pyasn1==0.4.8
pyasn1-modules==0.2.8
pyjade==4.0.0
pytz==2019.1
requests==2.25.1
requests==2.31.0
rsa==4.7.2
six==1.16.0
uritemplate==3.0.0
Expand Down
9 changes: 4 additions & 5 deletions scholardb_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ def execute(host, port, user, password, query):
f.write("%s\n%s\n%s\n%s\n%s" % (host, port, user, password, query))
f.close()

os.system("scp -oStrictHostKeyChecking=no -i ~/key.pem -P 8022 /tmp/otl_db_ssh_args wheel@143.248.234.126:/tmp > /dev/null")
os.system("scp /tmp/otl_db_ssh_args xen:/tmp > /dev/null")
os.remove("/tmp/otl_db_ssh_args")
os.system(
"ssh -oStrictHostKeyChecking=no -i ~/key.pem -p 8022 wheel@143.248.234.126 python db.py > /dev/null")
os.system("scp -oStrictHostKeyChecking=no -i ~/key.pem -P 8022 wheel@143.248.234.126:/tmp/otl_db_dump_result /tmp > /dev/null")
os.system("ssh -oStrictHostKeyChecking=no -i ~/key.pem -p 8022 wheel@143.248.234.126 rm /tmp/otl_db_dump_result > /dev/null")
os.system("ssh xen python db.py > /dev/null")
os.system("scp xen:/tmp/otl_db_dump_result /tmp > /dev/null")
os.system("ssh xen rm /tmp/otl_db_dump_result > /dev/null")
result = pickle.load(open("/tmp/otl_db_dump_result", "rb"), encoding="bytes")
os.remove("/tmp/otl_db_dump_result")

Expand Down

0 comments on commit a48e580

Please sign in to comment.