Skip to content

Commit

Permalink
Merge pull request #1523 from DDMAL/develop
Browse files Browse the repository at this point in the history
Merge develop into staging, 13 June 2024
  • Loading branch information
dchiller authored Jun 13, 2024
2 parents 668dd22 + 6266757 commit 7c94d6c
Show file tree
Hide file tree
Showing 50 changed files with 961 additions and 399 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/django_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: django-tests
on:
pull_request:
types: [opened, synchronize]
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: mkdir -p config/envs
- uses: SpicyPizza/[email protected]
with:
envkey_POSTGRES_DB: test_cantusdb
envkey_POSTGRES_USER: test_user
envkey_POSTGRES_HOST: postgres
envkey_POSTGRES_PORT: 5432
envkey_PROJECT_ENVIRONMENT: PRODUCTION
envkey_CANTUSDB_STATIC_ROOT: /path/to/static
envkey_CANTUSDB_MEDIA_ROOT: /path/to/media
envkey_CANTUSDB_HOST: somehost
envkey_CANTUSDB_SECRET_KEY: "hereisakey1234"
envkey_POSTGRES_PASSWORD: woahagreatpasswordabc
envkey_AWS_EMAIL_HOST_USER: test_user
envkey_AWS_EMAIL_HOST_PASSWORD: test_password
directory: config/envs
file_name: dev_env
- run: docker compose -f docker-compose-development.yml build
- run: docker compose -f docker-compose-development.yml up -d
- run: docker compose -f docker-compose-development.yml exec -T django python manage.py test main_app.tests
16 changes: 4 additions & 12 deletions config/nginx/conf.d/cantusdb.conf.development
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,9 @@ server {
alias /resources/api_cache/concordances.json;
expires modified +24h;
}

location = /style.css {
root /;
}
location = /background.jpg {
root /;
}
location = /CantusLogoSmall.gif {
root /;
}
location = /favicon.ico {

error_page 500 /500.html;
location = /500.html {
root /;
}

Expand All @@ -45,4 +37,4 @@ server {
location = /504.html {
root /;
}
}
}
2 changes: 1 addition & 1 deletion cron/management/manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
DOCKER_COMPOSE_FILE=$1 # This is the path to the docker-compose file.
COMMAND=$2 # This is the command to execute.

/usr/local/bin/docker compose -f $DOCKER_COMPOSE_FILE exec -T django python manage.py $COMMAND
/usr/bin/docker compose -f $DOCKER_COMPOSE_FILE exec -T django python manage.py $COMMAND
9 changes: 6 additions & 3 deletions django/cantusdb_project/cantusindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ def get_suggested_chant(
# mostly, in case of a timeout within get_json_from_ci_api
return None

fulltext: str = json["info"]["field_full_text"]
incipit: str = " ".join(fulltext.split(" ")[:5])
genre_name: str = json["info"]["field_genre"]
try:
fulltext: str = json["info"]["field_full_text"]
incipit: str = " ".join(fulltext.split(" ")[:5])
genre_name: str = json["info"]["field_genre"]
except TypeError:
return None
genre_id: Optional[int] = None
try:
genre_id = Genre.objects.get(name=genre_name).id
Expand Down
236 changes: 0 additions & 236 deletions django/cantusdb_project/main_app/admin.py

This file was deleted.

14 changes: 14 additions & 0 deletions django/cantusdb_project/main_app/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from main_app.admin.century import CenturyAdmin
from main_app.admin.chant import ChantAdmin
from main_app.admin.differentia import DifferentiaAdmin
from main_app.admin.feast import FeastAdmin
from main_app.admin.genre import GenreAdmin
from main_app.admin.notation import NotationAdmin
from main_app.admin.office import OfficeAdmin
from main_app.admin.provenance import ProvenanceAdmin
from main_app.admin.rism_siglum import RismSiglumAdmin
from main_app.admin.segment import SegmentAdmin
from main_app.admin.sequence import SequenceAdmin
from main_app.admin.source import SourceAdmin
from main_app.admin.institution import InstitutionAdmin
from main_app.admin.institution_identifier import InstitutionIdentifierAdmin
27 changes: 27 additions & 0 deletions django/cantusdb_project/main_app/admin/base_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from reversion.admin import VersionAdmin


# these fields should not be editable by all classes
EXCLUDE = ("json_info",)


READ_ONLY = (
"created_by",
"last_updated_by",
"date_created",
"date_updated",
)


class BaseModelAdmin(VersionAdmin):
exclude = EXCLUDE
readonly_fields = READ_ONLY

# if an object is created in the admin interface, assign the user to the created_by field
# else if an object is updated in the admin interface, assign the user to the last_updated_by field
def save_model(self, request, obj, form, change):
if change:
obj.last_updated_by = request.user
else:
obj.created_by = request.user
super().save_model(request, obj, form, change)
11 changes: 11 additions & 0 deletions django/cantusdb_project/main_app/admin/century.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin

from main_app.admin.base_admin import BaseModelAdmin
from main_app.forms import AdminCenturyForm
from main_app.models import Century


@admin.register(Century)
class CenturyAdmin(BaseModelAdmin):
search_fields = ("name",)
form = AdminCenturyForm
Loading

0 comments on commit 7c94d6c

Please sign in to comment.